Stroika Library 3.0d20
 
Loading...
Searching...
No Matches
CommandLine.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
6
7 /*
8 ********************************************************************************
9 ************************** CommandLine::Option *********************************
10 ********************************************************************************
11 */
13 {
14 return not fSingleCharName.has_value () and not fLongName.has_value ();
15 }
16
17 /*
18 ********************************************************************************
19 ********************************** CommandLine *********************************
20 ********************************************************************************
21 */
22 inline CommandLine::CommandLine (const Sequence<String>& cmdLine)
23 : fArgs_{cmdLine}
24 {
25 }
26 inline CommandLine::CommandLine (int argc, char* argv[])
27 : CommandLine{argc, (const char**)argv}
28 {
29 }
30 inline CommandLine::CommandLine (int argc, wchar_t* argv[])
31 : CommandLine{argc, (const wchar_t**)argv}
32 {
33 }
34 inline bool CommandLine::Has (const Option& o) const
35 {
36 for (Traversal::Iterator<String> argi = fArgs_.begin () + 1; argi != fArgs_.end (); ++argi) {
37 if (auto oRes = ParseOneArg_ (o, &argi); oRes and *oRes) {
38 return true;
39 }
40 }
41 return false;
42 }
43 inline optional<String> CommandLine::GetArgument (const Option& o) const
44 {
45 auto r = get<Sequence<String>> (Get (o));
46 return r.empty () ? optional<String>{} : r[0];
47 }
49 {
50 return this->fArgs_;
51 }
52 inline Sequence<String> CommandLine::GetArguments (const Option& o) const
53 {
54 return get<Sequence<String>> (Get (o));
55 }
56 inline auto CommandLine::GetStringShellQuoting () const -> optional<StringShellQuoting>
57 {
58 return fShellStyleQuoting_;
59 }
60 inline void CommandLine::SetStringShellQuoting (const optional<StringShellQuoting>& s)
61 {
62 fShellStyleQuoting_ = s;
63 }
64
65 ////---deprecated
66 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (const String& cmdLine)
67 {
68 return CommandLine{cmdLine}.GetArguments ();
69 }
70 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, char* argv[])
71 {
72 return CommandLine{argc, argv}.GetArguments ();
73 }
74 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, const char* argv[])
75 {
76 return CommandLine{argc, argv}.GetArguments ();
77 }
78 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, wchar_t* argv[])
79 {
80 return CommandLine{argc, argv}.GetArguments ();
81 }
82 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, const wchar_t* argv[])
83 {
84 return CommandLine{argc, argv}.GetArguments ();
85 }
86
87 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] bool MatchesCommandLineArgument (const String& actualArg, const String& matchesArgPattern);
88 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] bool MatchesCommandLineArgument (const Iterable<String>& argList,
89 const String& matchesArgPattern);
90 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] optional<String>
91 MatchesCommandLineArgumentWithValue (const String& actualArg, const String& matchesArgPattern);
92 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] optional<String>
93 MatchesCommandLineArgumentWithValue (const Iterable<String>& argList, const String& matchesArgPattern);
94
95}
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual Sequence< String > GetArguments() const
nonvirtual optional< String > GetArgument(const Option &o) const
An Iterator<T> is a copyable object which allows traversing the contents of some container....
Definition Iterator.h:225