1 #ifndef DRAMA2_GITARG_INC
2 #define DRAMA2_GITARG_INC
54 Upper=GIT_M_ARG_UPPER,
55 Lower=GIT_M_ARG_UPPER,
71 return Flags(
int(f1)|
int(f2));
80 if ((
int)(f1) & (
int)(f2))
103 class EnumLookupClass {
162 template <
typename LookupClass,
typename EnumType>
class Enum {
165 LookupClass lookupObject;
171 void SetValue(
const unsigned int i) {
172 if (i > lookupObject.GetMaxValue())
173 _value = InvalidValue();
175 _value = (EnumType)i;
180 EnumType InvalidValue()
const {
181 return (EnumType)(lookupObject.GetMaxValue()+1);
192 _value = InvalidValue();
200 Enum(EnumType InitialValue) : _value(InitialValue) {}
223 Enum(
const sds::Id& Id,
224 const std::string & Name=
"Argument1",
225 const int Position=1,
226 const std::string & Default=
"",
228 :_value(InvalidValue()) {
255 const std::string & Name=
"Argument1",
256 const int Position=1,
257 const std::string & Default=
"",
266 StatusType status = STATUS__OK;
267 GitArgGetS((SdsIdType)Id,Name.c_str(),Position,
268 lookupObject.GetStringArray(),
270 (int)(flags),
sizeof(string),
string,&index,&status);
272 if (status != STATUS__OK)
275 "Failed to fetch Enumerated Argument from SDS");
282 operator EnumType()
const {
287 operator std::string()
const {
288 return lookupObject.GetStringArray()[int(_value)];
322 template <
long int MinVal,
long int MaxVal,
long int DefaultVal=0>
class Real {
325 virtual const double * Range() {
326 static const double range[] = { MinVal, MaxVal };
336 Real(
const double def = (
double)DefaultVal) : _value(def) {
363 const std::string & Name=
"Argument1",
364 const int Position=1,
365 const double Default = (
double)DefaultVal,
394 const std::string & Name=
"Argument1",
395 const int Position=1,
396 const double Default = 0.0,
399 StatusType status = STATUS__OK;
400 GitArgGetD((SdsIdType)Id,Name.c_str(),
402 (int)(flags),&_value,&status);
404 if (status != STATUS__OK)
406 DramaTHROW(status,
"Failed to fetch real number Argument from SDS");
411 operator double()
const {
435 template <
long int MinVal=LONG_MIN,
436 long int MaxVal=LONG_MAX,
437 long int DefaultVal=0>
class Int {
440 virtual const long int * Range() {
441 static const long int range[] = { MinVal, MaxVal };
451 Int(
const long def = DefaultVal) : _value(def) { }
477 const std::string & Name =
"Argument1",
478 const int Position=1,
479 const long Default = DefaultVal,
482 Get(Id,Name,Position,Default,flags);
507 const std::string & Name=
"Argument1",
508 const int Position=1,
509 const long int Default = 0,
512 StatusType status = STATUS__OK;
513 GitArgGetI((SdsIdType)Id,Name.c_str(),Position,Range(),Default,
514 (int)(flags),&_value,&status);
516 if (status != STATUS__OK)
518 DramaTHROW(status,
"Failed to fetch integer Argument from SDS");
523 operator long int()
const {
543 class String :
public std::string {
544 using std::string::string;
547 static const unsigned _DefaultStringLength = 100;
549 void RawGet (
const sds::Id& Id,
const std::string &Name,
550 int Position,
const std::string &Default,
551 Flags flags, StatusType * status);
576 const std::string &Name =
"Argument1",
577 const int Position = 1,
578 const std::string &Default =
"",
580 this->
Get(Id, Name, Position, Default, flags);
608 const std::string &Name =
"Argument1",
609 const int Position = 1,
610 const std::string &Default =
"",
619 this->std::string::operator=(str);
627 this->std::string::operator=(str);
635 this->std::string::operator=(s);
645 this->std::string::operator=(c);
673 static const GitLogStrType lookupTable[];
686 virtual const GitLogStrType *
Lookup() {
693 Bool(
bool initVal=
false) : _value(initVal) { }
718 const std::string &Name=
"Argument1",
719 const int Position=1,
720 const bool Default =
false,
723 Get(Id,Name,Position,Default,flags);
749 const std::string &Name=
"Argument1",
750 const int Position=1,
751 const bool Default =
false,
754 long int actValue = 0;
755 StatusType status = STATUS__OK;
756 GitArgGetL((SdsIdType)Id,Name.c_str(),Position,
Lookup(),Default,
757 (int)(flags),&actValue,&status);
759 if (status != STATUS__OK)
762 "Failed to fetch boolean Argument from SDS");
765 _value = actValue ?
true :
false;
769 operator bool()
const {
797 class Id :
public sds::Id {
799 bool _readFromFile =
false;
800 bool _defaultUsed =
false;
801 std::string _actualName;
803 void UseDefaultIfReq(
const std::string &name,
805 const std::string &fileName,
808 const std::string &mess);
868 const std::string &Name=
"Argument1",
869 const int Position=1,
870 const std::string Default =
"",
873 Get(Id,Name,Position,Default,flags);
927 const std::string &Name=
"Argument1",
928 const int Position=1,
929 const std::string Default =
"",
Convert strings to lower case.
virtual ~Enum()
Destructor.
Definition: gitarg.hh:319
Bool operator=(const bool src)
Assign a bool to this gitarg::Bool item.
Definition: gitarg.hh:803
virtual ~EnumLookupClass()
Destructor.
Definition: gitarg.hh:159
Int(const long def=DefaultVal)
Simple constructor with a default value specified.
Definition: gitarg.hh:478
constexpr Flags operator|(Flags f1, Flags f2)
Operator to allow Flags values to be or-ed.
Definition: gitarg.hh:97
String operator=(const std::string str)
Assign a std::string to this gitarg::String.
Definition: gitarg.hh:645
virtual bool WasReadFromFile() const
Indicates if the structure was read from a file.
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string Default="", const Flags flags=(Flags::KeepErr))
Get the value of the object from an SDS structure or file.
Real(const double def=(double) DefaultVal)
Simple constructor with a default value specified.
Definition: gitarg.hh:363
Convert strings to upper case.
A class which reads integer values from an SDS argument structure.
Definition: gitarg.hh:464
A C++ Interface to the handling SDS structures.
Definition: sds.hh:412
String(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure.
Definition: gitarg.hh:602
virtual std::string ActualName() const
Return the actual name of the file or structure.
virtual const char ** GetStringArray() const =0
Return a pointer to an array of enum strings equivalents.
A class which reads real values from an SDS argument structure.
Definition: gitarg.hh:349
virtual ~Bool()
Destructor.
Definition: gitarg.hh:754
A class which reads an SDS structure from DRAMA SDS Command argument structures.
Definition: gitarg.hh:824
Bool(bool initVal=false)
Simple constructor with a default value of false.
Definition: gitarg.hh:720
bool IsFlagSet(const Flags f1, const Flags f2)
Operator to allow determination of if a Flag enum value set.
Definition: gitarg.hh:106
Value indicating no flags set.
virtual bool WasReadFromDefault() const
Indicates if the structure was read from the default.
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const long int Default=0, const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition: gitarg.hh:532
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const bool Default=false, const Flags flags=(Flags::Upper|Flags::Abbrev|Flags::KeepErr))
Get the value of the object from an SDS struture.
Definition: gitarg.hh:774
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition: exception.hh:82
Keep error status on return.
A class which reads a string item from an SDS structure.
Definition: gitarg.hh:570
Only consider Least significant bit of integer values when treating integers as logical.
virtual const GitLogStrType * Lookup()
Return a pointer to an array of enum strings equivalents.
Definition: gitarg.hh:713
virtual unsigned int GetMaxValue() const =0
This function should return the maximum normal value of the enumerated value.
Id()
Default constructor.
Definition: gitarg.hh:842
Flags
The various flags used in GIT operations.
Definition: gitarg.hh:79
Enum()
Default contructor for the object.
Definition: gitarg.hh:218
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition: drama.hh:89
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Fetch the value of this item from an SDS structure.
DRAMA 2 main include file.
void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition: gitarg.hh:281
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const double Default=0.0, const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition: gitarg.hh:419