Stroika Library 3.0d16
 
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 *********************************
10 ********************************************************************************
11 */
12 inline CommandLine::CommandLine (const Sequence<String>& cmdLine)
13 : fArgs_{cmdLine}
14 {
15 }
16 inline CommandLine::CommandLine (int argc, char* argv[])
17 : CommandLine{argc, (const char**)argv}
18 {
19 }
20 inline CommandLine::CommandLine (int argc, wchar_t* argv[])
21 : CommandLine{argc, (const wchar_t**)argv}
22 {
23 }
24 inline bool CommandLine::Has (const Option& o) const
25 {
26 for (Traversal::Iterator<String> argi = fArgs_.begin () + 1; argi != fArgs_.end (); ++argi) {
27 if (optional<pair<bool, optional<String>>> oRes = ParseOneArg_ (o, &argi)) {
28 if (oRes->first) {
29 return true;
30 }
31 }
32 }
33 return false;
34 }
35 inline optional<String> CommandLine::GetArgument (const Option& o) const
36 {
37 Require (o.fSupportsArgument);
38 auto r = get<Sequence<String>> (Get (o));
39 return r.empty () ? optional<String>{} : r[0];
40 }
41 inline Sequence<String> CommandLine::GetArguments () const
42 {
43 return this->fArgs_;
44 }
45 inline Sequence<String> CommandLine::GetArguments (const Option& o) const
46 {
47 Require (o.fSupportsArgument);
48 return get<Sequence<String>> (Get (o));
49 }
50 inline auto CommandLine::GetStringShellQuoting () const -> optional<StringShellQuoting>
51 {
52 return fShellStyleQuoting_;
53 }
54 inline void CommandLine::SetStringShellQuoting (const optional<StringShellQuoting>& s)
55 {
56 fShellStyleQuoting_ = s;
57 }
58
59 ////---deprecated
60 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (const String& cmdLine)
61 {
62 return CommandLine{cmdLine}.GetArguments ();
63 }
64 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, char* argv[])
65 {
66 return CommandLine{argc, argv}.GetArguments ();
67 }
68 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, const char* argv[])
69 {
70 return CommandLine{argc, argv}.GetArguments ();
71 }
72 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, wchar_t* argv[])
73 {
74 return CommandLine{argc, argv}.GetArguments ();
75 }
76 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] inline Sequence<String> ParseCommandLine (int argc, const wchar_t* argv[])
77 {
78 return CommandLine{argc, argv}.GetArguments ();
79 }
80
81 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] bool MatchesCommandLineArgument (const String& actualArg, const String& matchesArgPattern);
82 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] bool MatchesCommandLineArgument (const Iterable<String>& argList,
83 const String& matchesArgPattern);
84 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] optional<String>
85 MatchesCommandLineArgumentWithValue (const String& actualArg, const String& matchesArgPattern);
86 [[deprecated ("Since Stroika v3.0d6 use CommandLine class")]] optional<String>
87 MatchesCommandLineArgumentWithValue (const Iterable<String>& argList, const String& matchesArgPattern);
88
89}
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187