cmdline.hxx (ed2f6d3b) cmdline.hxx (0ba0bc4a)
1/**************************************************************
1/**************************************************************
2 *
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
19 *
20 *************************************************************/
21
20 *************************************************************/
21
22
23
22#ifndef _CMDLINE_HXX_
23#define _CMDLINE_HXX_
24
25#include "defs.hxx"
26
24#ifndef _CMDLINE_HXX_
25#define _CMDLINE_HXX_
26
27#include "defs.hxx"
28
27//---------------------------------
29//---------------------------------
28/** Simple command line abstraction
29*/
30
31class CommandLine
32{
33public:
34
35 //################################

--- 8 unchanged lines hidden (view full) ---

44 // Query
45 //################################
46
47
48 /** Return the argument count
49 */
50 size_t get_arg_count() const;
51
30/** Simple command line abstraction
31*/
32
33class CommandLine
34{
35public:
36
37 //################################

--- 8 unchanged lines hidden (view full) ---

46 // Query
47 //################################
48
49
50 /** Return the argument count
51 */
52 size_t get_arg_count() const;
53
52 /** Return an argument by index
54 /** Return an argument by index
53 This method doesn't skip argument
54 names if any, so if the second
55 This method doesn't skip argument
56 names if any, so if the second
55 argument is an argument name the
57 argument is an argument name the
56 function nevertheless returns it.
57
58 @precond 0 <= Index < GetArgumentCount
59
58 function nevertheless returns it.
59
60 @precond 0 <= Index < GetArgumentCount
61
60 @throws std::out_of_range exception
62 @throws std::out_of_range exception
61 if the given index is to high
62 */
63 std::string get_arg(size_t Index) const;
64
63 if the given index is to high
64 */
65 std::string get_arg(size_t Index) const;
66
65 /** Returns all argument name found in the
67 /** Returns all argument name found in the
66 command line. An argument will be identified
67 by a specified prefix. The standard prefix
68 is '-'.
68 command line. An argument will be identified
69 by a specified prefix. The standard prefix
70 is '-'.
69 If there are no argument names the returned
71 If there are no argument names the returned
70 container is empty.
71 */
72 StringListPtr_t get_arg_names() const;
73
72 container is empty.
73 */
74 StringListPtr_t get_arg_names() const;
75
74 /** Returns an argument by name. If there are
76 /** Returns an argument by name. If there are
75 duplicate argument names in the command line,
76 the first one wins.
77 duplicate argument names in the command line,
78 the first one wins.
77 Argument name an the argument value must be separated
78 by spaces. If the argument value starts with an
79 Argument name and the argument value must be separated
80 by spaces. If the argument value starts with an
79 argument prefix use quotes else the return value is
81 argument prefix use quotes else the return value is
80 an empty string because the value will be interpreted
82 an empty string because the value will be interpreted
81 as the next argument name.
83 as the next argument name.
82 If an argument value contains spaces use quotes.
84 If an argument value contains spaces use quotes.
83
84 @precond GetArgumentNames() -> has element ArgumentName
85
85
86 @precond GetArgumentNames() -> has element ArgumentName
87
86 @throws std::invalid_argument exception
87 if the specified argument could not be
88 @throws std::invalid_argument exception
89 if the specified argument could not be
88 found
89 */
90 std::string get_arg(const std::string& ArgumentName) const;
91
92
93 //################################
94 // Command
95 //################################
96
97
90 found
91 */
92 std::string get_arg(const std::string& ArgumentName) const;
93
94
95 //################################
96 // Command
97 //################################
98
99
98 /** Set the prefix used to identify arguments in
100 /** Set the prefix used to identify arguments in
99 the command line.
100
101 @precond prefix is not empty
102
103 @throws std::invalid_argument exception if
104 the prefix is empty
105 */
106 void set_arg_prefix(const std::string& Prefix);

--- 11 unchanged lines hidden (view full) ---

118
119// prevent copy and assignment
120private:
121 CommandLine(const CommandLine&);
122 CommandLine& operator=(const CommandLine&);
123};
124
125#endif
101 the command line.
102
103 @precond prefix is not empty
104
105 @throws std::invalid_argument exception if
106 the prefix is empty
107 */
108 void set_arg_prefix(const std::string& Prefix);

--- 11 unchanged lines hidden (view full) ---

120
121// prevent copy and assignment
122private:
123 CommandLine(const CommandLine&);
124 CommandLine& operator=(const CommandLine&);
125};
126
127#endif
128
129/* vim: set noet sw=4 ts=4: */