MAK Data Logger API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
replacedCmdUnlabledMultiArg.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * file: ReplacedUnlabeledMultiArg.h
5  *
6  * Copyright (c) 2003, Michael E. Smoot.
7  * All rights reverved.
8  *
9  * See the file COPYING in the top directory of this distribution for
10  * more information.
11  *
12  * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS
13  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18  * DEALINGS IN THE SOFTWARE.
19  *
20  *****************************************************************************/
21 
22 #ifndef replacedCmdUnlabledMultiArg_H_
23 #define replacedCmdUnlabledMultiArg_H_
24 
27 
28 #include <string>
29 #include <vector>
30 
31 #include <cmdLine/cmdMultiArg.h>
32 
33 namespace MAKLogger
34 {
35 
41 template<class T>
42 class ReplacedUnlabeledMultiArg : public DtCmdLine::MultiArg<T>
43 {
44 
45  public:
46 
47 #ifndef __solaris__
48  using DtCmdLine::MultiArg<T>::_ignoreable;
51  using DtCmdLine::MultiArg<T>::_hasBlanks;
52  using DtCmdLine::MultiArg<T>::_extractValue;
53  using DtCmdLine::MultiArg<T>::_typeDesc;
54  using DtCmdLine::MultiArg<T>::_name;
55  using DtCmdLine::MultiArg<T>::_description;
56 #endif
57 
58 
59 
75  ReplacedUnlabeledMultiArg( const std::string& name,
76  const std::string& desc,
77  const std::string& typeDesc,
78  bool ignoreable = false,
79  DtCmdLine::Visitor* v = NULL );
96  ReplacedUnlabeledMultiArg( const std::string& name,
97  const std::string& desc,
98  const std::string& typeDesc,
99  DtCmdLine::CmdLineInterface& parser,
100  bool ignoreable = false,
101  DtCmdLine::Visitor* v = NULL );
102 
116  ReplacedUnlabeledMultiArg( const std::string& name,
117  const std::string& desc,
118  const std::vector<T>& allowed,
119  bool ignoreable = false,
120  DtCmdLine::Visitor* v = NULL );
121 
136  ReplacedUnlabeledMultiArg( const std::string& name,
137  const std::string& desc,
138  const std::vector<T>& allowed,
139  DtCmdLine::CmdLineInterface& parser,
140  bool ignoreable = false,
141  DtCmdLine::Visitor* v = NULL );
142 
151  virtual bool processArg(int* i, std::vector<std::string>& args);
152 
157  virtual std::string shortID(const std::string& val) const;
158 
163  virtual std::string longID(const std::string& val) const;
164 
169  virtual void addToList( std::list<DtCmdLine::Arg*>& argList ) const;
170 };
171 
172 template<class T>
174  const std::string& desc,
175  const std::string& typeDesc,
176  bool ignoreable,
177  DtCmdLine::Visitor* v)
178 : DtCmdLine::MultiArg<T>("", name, desc, false, typeDesc, v)
179 {
180  _ignoreable = ignoreable;
181 }
182 
183 template<class T>
185  const std::string& desc,
186  const std::string& typeDesc,
187  DtCmdLine::CmdLineInterface& parser,
188  bool ignoreable,
189  DtCmdLine::Visitor* v)
190 : DtCmdLine::MultiArg<T>("", name, desc, false, typeDesc, v)
191 {
192  _ignoreable = ignoreable;
193  parser.add( this );
194 }
195 
196 
197 template<class T>
199  const std::string& desc,
200  const std::vector<T>& allowed,
201  bool ignoreable,
202  DtCmdLine::Visitor* v)
203 : DtCmdLine::MultiArg<T>("", name, desc, false, allowed, v)
204 {
205  _ignoreable = ignoreable;
206 }
207 
208 template<class T>
210  const std::string& desc,
211  const std::vector<T>& allowed,
212  DtCmdLine::CmdLineInterface& parser,
213  bool ignoreable,
214  DtCmdLine::Visitor* v)
215 : DtCmdLine::MultiArg<T>("", name, desc, false, allowed, v)
216 {
217  _ignoreable = ignoreable;
218  parser.add( this );
219 }
220 
221 
222 template<class T>
223 bool ReplacedUnlabeledMultiArg<T>::processArg(int *i, std::vector<std::string>& args)
224 {
225 
226  if ( _hasBlanks( args[*i] ) )
227  return false;
228 
230 
231  _extractValue( args[*i] );
232  return true;
233 }
234 
235 template<class T>
236 std::string ReplacedUnlabeledMultiArg<T>::shortID(const std::string& val) const
237 {
238  std::string id = "<" + _typeDesc + "> ...";
239 
240  return id;
241 }
242 
243 template<class T>
244 std::string ReplacedUnlabeledMultiArg<T>::longID(const std::string& val) const
245 {
246  std::string id = "<" + _typeDesc + ">";
247 
248  return id;
249 }
250 
259 
260 template<class T>
261 void ReplacedUnlabeledMultiArg<T>::addToList( std::list<DtCmdLine::Arg*>& argList ) const
262 {
263  argList.push_back( (DtCmdLine::Arg*)this );
264 }
265 
266 }
267 
268 #endif
virtual std::string shortID(const std::string &val) const
Returns the a short id string.
Definition: replacedCmdUnlabledMultiArg.h:236
virtual void addToList(std::list< DtCmdLine::Arg * > &argList) const
Pushes this to back of list rather than front.
Definition: replacedCmdUnlabledMultiArg.h:261
ReplacedUnlabeledMultiArg(const std::string &name, const std::string &desc, const std::string &typeDesc, bool ignoreable=false, DtCmdLine::Visitor *v=NULL)
Constructor.
Definition: replacedCmdUnlabledMultiArg.h:173
Just like a MultiArg, except that the DtCmdLine::Arguments are unlabeled.
Definition: replacedCmdUnlabledMultiArg.h:42
virtual bool processArg(int *i, std::vector< std::string > &args)
Handles the processing of the DtCmdLine::Argument.
Definition: replacedCmdUnlabledMultiArg.h:223
virtual std::string longID(const std::string &val) const
Returns the a long id string.
Definition: replacedCmdUnlabledMultiArg.h:244

Document ID: Generated on Thu Dec 18 15:35:09 EST 2025 from SVN revision 282494
Copyright © 2024 MAK Technologies. All Rights Reserved (www.mak.com)