MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VArguments.h
Go to the documentation of this file.
1 /* -*- mode:C++ -*-
2  VArguments.h Command Line Argument registry
3  Copyright (C) 2014 The Regents of the University of New Mexico. All rights reserved.
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
28 #ifndef VARGUMENTS_H
29 #define VARGUMENTS_H
30 
31 #include "itype.h"
32 
33 namespace MFM
34 {
35 #define VARGUMENTS_MAX_SIZE 64
36 
41  typedef void (*VArgumentHandleValue)(const char*, void* arg);
42 
48  class VArguments
49  {
50  private:
51 
56  struct VArg
57  {
58 
62  const char* m_description;
63 
71  const char* m_filter;
72 
76  const char* m_value;
77 
82  bool m_argsNeeded;
83 
87  bool m_appeared;
88 
92  void* m_handlerArg;
93 
97  VArgumentHandleValue m_function;
98 
99  VArg() : m_description(0), m_filter(0), m_value(0),
100  m_argsNeeded(false), m_appeared(false),
101  m_handlerArg(0), m_function(0)
102  {
103 
104  }
105 
106 
107 
108  };
109 
113  VArg m_argDescriptors[VARGUMENTS_MAX_SIZE];
114 
119  u32 m_heldArguments;
120 
121  public:
122 
126  VArguments();
127 
135  void Die(const char * format, ...);
136 
160  void RegisterArgument(const char* description, const char* filter,
161  VArgumentHandleValue func, void* handlerArg,
162  bool runFunc);
163 
173  void RegisterSection(const char* label);
174 
183  void ProcessArguments(u32 argc, const char** argv);
184 
196  const char* Get(const char* argName) const;
197 
211  u32 GetInt(const char* argName) const;
212 
223  bool Appeared(const char* argName) const;
224 
229  void Usage() const;
230  };
231 }
232 
233 #endif /* VARGUMENTS_H */
void RegisterArgument(const char *description, const char *filter, VArgumentHandleValue func, void *handlerArg, bool runFunc)
Definition: VArguments.cpp:25
VArguments()
Definition: VArguments.cpp:13
void Usage() const
Definition: VArguments.cpp:162
void Die(const char *format,...)
Definition: VArguments.cpp:16
void ProcessArguments(u32 argc, const char **argv)
Definition: VArguments.cpp:91
const char * Get(const char *argName) const
Definition: VArguments.cpp:132
void RegisterSection(const char *label)
Definition: VArguments.cpp:43
Definition: VArguments.h:48
u32 GetInt(const char *argName) const
Definition: VArguments.cpp:127
bool Appeared(const char *argName) const
Definition: VArguments.cpp:147