18 #ifndef __egetopt_h_included 19 #define __egetopt_h_included 93 Void
setPrefix(cpStr path =
"") { m_prefix = path; }
125 LongLong
getCmdLine(cpStr path, LongLong def)
const;
131 ULong
getCmdLine(cpStr path, ULong def)
const;
137 ULongLong
getCmdLine(cpStr path, ULongLong def)
const;
143 Double
getCmdLine(cpStr path, Double def)
const;
149 cpStr
getCmdLine(cpStr path, cpStr def)
const;
164 std::vector<EString>
getMembers(cpStr path)
const;
166 std::vector<EString>
getMembers(UInt idx, cpStr path, cpStr member)
const;
173 Long
get(cpStr path, Long def)
const;
179 LongLong
get(cpStr path, LongLong def)
const;
185 ULong
get(cpStr path, ULong def)
const;
191 ULongLong
get(cpStr path, ULongLong def)
const;
197 Double
get(cpStr path, Double def)
const;
203 cpStr
get(cpStr path, cpStr def)
const;
209 Bool
get(cpStr path, Bool def)
const;
224 T
get(UInt idx, cpStr path, cpStr member, T def)
const 227 mbr.
format(
"%u/%s", idx, member);
228 EString pth = combinePath(path, mbr.c_str());
229 return get(pth, def);
236 std::vector<T>
getArray(cpStr path)
const;
245 std::vector<T>
getArray(UInt idx, cpStr path, cpStr member)
const 248 mbr.
format(
"%u/%s", idx, member);
249 EString pth = combinePath(path, mbr.c_str());
250 return getArray<T>(pth);
257 EString combinePath(cpStr path1, cpStr path2)
const;
258 const Option *findOption(cpStr name,
const Option *options);
268 class EGetOptError_MissingRequiredArgument :
public EError 271 EGetOptError_MissingRequiredArgument(cpStr pszFile);
272 virtual const cpStr Name()
const {
return "EGetOptError_MissingRequiredArgument"; }
275 class EGetOptError_UnsupportedArgType :
public EError 279 virtual const cpStr Name()
const {
return "EGetOptError_UnsupportedArgType"; }
282 class EGetOptError_UnsupportedDataType :
public EError 286 virtual const cpStr Name()
const {
return "EGetOptError_UnsupportedDataType"; }
289 class EGetOptError_UnsupportedBooleanValue :
public EError 292 EGetOptError_UnsupportedBooleanValue(cpStr val);
293 virtual const cpStr Name()
const {
return "EGetOptError_UnsupportedBooleanValue"; }
296 class EGetOptError_FileParsing :
public EError 299 EGetOptError_FileParsing(cpStr val);
300 virtual const cpStr Name()
const {
return "EGetOptError_FileParsing"; }
303 class EGetOptError_UnsupportedArrayType :
public EError 306 EGetOptError_UnsupportedArrayType(cpStr val);
307 virtual const cpStr Name()
const {
return "EGetOptError_UnsupportedArrayType"; }
310 class EGetOptError_UnexpectedArrayElementType :
public EError 313 EGetOptError_UnexpectedArrayElementType(cpStr rcvd, cpStr expctd);
314 virtual const cpStr Name()
const {
return "EGetOptError_UnexpectedArrayElementType"; }
317 class EGetOptError_NotArray :
public EError 320 EGetOptError_NotArray();
321 virtual const cpStr Name()
const {
return "EGetOptError_NotArray"; }
325 #endif // #define __egetopt_h_included Long getCmdLine(cpStr path, Long def) const
Returns the value of the specified command line argument as a 32-bit integer.
Definition: egetopt.cpp:320
Encapsulates and extends a std::string object.
DataType
The data type of the command line argument.
Definition: egetopt.h:46
32-bit unsigned integer
Definition: egetopt.h:57
EString shortName
the short name of the argument e.g.: -a
Definition: egetopt.h:70
32-bit integer
Definition: egetopt.h:53
Void loadCmdLine(Int argc, pStr *argv, const EGetOpt::Option *options)
Parses and loads the command line arguments.
Definition: egetopt.cpp:907
EString longName
the long name of the argument e.g.: –argument
Definition: egetopt.h:72
string
Definition: egetopt.h:51
no argument required
Definition: egetopt.h:38
ArgType argType
indicates if an argument is required or not
Definition: egetopt.h:74
DataType dataType
the data type of the argument
Definition: egetopt.h:76
8-byte floating point number
Definition: egetopt.h:61
EGetOpt()
Class constructor.
Definition: egetopt.cpp:278
an argument is required
Definition: egetopt.h:40
Void setPrefix(const EString &path)
Sets the search prefix.
Definition: egetopt.h:88
Describes the defined command line arguments.
Definition: egetopt.h:67
Defines base class for exceptions and declaration helper macros.
Void loadFile(cpStr filename)
Parses and loads configuration values from the specified JSON file.
Definition: egetopt.cpp:1042
boolean
Definition: egetopt.h:63
std::vector< T > getArray(UInt idx, cpStr path, cpStr member) const
Returns the values of an array.
Definition: egetopt.h:245
The base class for exceptions derived from std::exception.
Definition: eerror.h:94
ArgType
Indicates if an argument associated with a command line argument is required.
Definition: egetopt.h:35
64-bit unsigned integer
Definition: egetopt.h:59
std::vector< EString > getCmdLineRaw() const
Returns a std::vector containing the "raw" string command line arguments.
Definition: egetopt.cpp:453
std::vector< T > getArray(cpStr path) const
Returns the values of an array.
Definition: egetopt.cpp:793
~EGetOpt()
Class destructor.
Definition: egetopt.cpp:302
std::vector< EString > getCmdLineArgs() const
Returns a std::vector containing positional command line arguments.
Definition: egetopt.cpp:433
64-bit integer
Definition: egetopt.h:55
UInt getCount(cpStr path) const
returns the number of configuration entries specified in a JSON array.
Definition: egetopt.cpp:636
std::vector< EString > getMembers(cpStr path) const
Returns a std::vector containing the member names based on the provided path.
Definition: egetopt.cpp:473
Void setPrefix(cpStr path="")
Sets the search prefix.
Definition: egetopt.h:93
EString & format(cpChar pszFormat,...)
Sets the value to the string using a "printf" style format string and arguments.
Definition: estring.cpp:38
String class.
Definition: estring.h:31
the argument is optional *** NOT IMPLEMENTED ***
Definition: egetopt.h:42
no argument
Definition: egetopt.h:49
Void print() const
Prints the current loaded values (command line and file).
Definition: egetopt.cpp:315