-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.h
executable file
·74 lines (66 loc) · 2.82 KB
/
env.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/////////////////////////////////////////////////
// Environment
class TEnv{
private:
//int Args;
//char** ArgV;
TStrV ArgV;
TStr HdStr;
int MnArgs;
bool SilentP;
PNotify Notify;
public:
TEnv(): /*Args(0), ArgV(NULL)*/ ArgV(), HdStr(), MnArgs(1), SilentP(false), Notify(){}
TEnv(const TEnv&);
TEnv(const int& _Args, char** _ArgV, const PNotify& _Notify=NULL);
//Args(_Args), ArgV(_ArgV), HdStr(), MnArgs(1), SilentP(false), Notify(_Notify){}
TEnv(const TStr& _ArgStr, const PNotify& _Notify=NULL);
TEnv& operator=(const TEnv& Env){
/*Args=Env.Args;*/ ArgV=Env.ArgV; HdStr=Env.HdStr;
MnArgs=Env.MnArgs; SilentP=Env.SilentP; Notify=Env.Notify; return *this;}
// basic arguments & command line
//int GetArgs() const {return Args;}
int GetArgs() const {return ArgV.Len();}
//TStr GetArg(const int& ArgN) const {
// IAssert((0<=ArgN)&&(ArgN<Args)); return TStr(ArgV[ArgN]);}
TStr GetArg(const int& ArgN) const {
IAssert((0<=ArgN)&&(ArgN<GetArgs())); return ArgV[ArgN];}
TStr GetExeFNm() const;
TStr GetExeFPath() const {return GetExeFNm().GetFPath();}
TStr GetCmLn(const int& FromArgN=1) const;
bool IsSilent() const {return SilentP;}
// arguments prefix & postfix
int GetPrefixArgN(const TStr& PrefixStr) const;
bool IsArgPrefix(const TStr& PrefixStr) const {
return GetPrefixArgN(PrefixStr)!=-1;}
TStr GetArgPostfix(const TStr& PrefixStr) const;
// top level arguments handling
void PrepArgs(
const TStr& _HdStr=TStr(), const int& _MnArgs=1, const bool& SilentP=false);
TStr GetHdStr() const {return HdStr;}
int GetMnArgs() const {return MnArgs;}
bool IsEndOfRun() const;
// arguments value retrieval
TStr GetIfArgPrefixStr(
const TStr& PrefixStr, const TStr& DfVal="", const TStr& DNm="") const;
TStrV GetIfArgPrefixStrV(
const TStr& PrefixStr, TStrV& DfValV, const TStr& DNm="") const;
TStrV GetIfArgPrefixStrV(const TStr& PrefixStr, const TStr& DNm="") const {
TStrV DfValV; return GetIfArgPrefixStrV(PrefixStr, DfValV, DNm);}
bool GetIfArgPrefixBool(
const TStr& PrefixStr, const bool& DfVal=false, const TStr& DNm="") const;
int GetIfArgPrefixInt(
const TStr& PrefixStr, const int& DfVal=0, const TStr& DNm="") const;
TIntV GetIfArgPrefixIntV(
const TStr& PrefixStr, TIntV& DfValV, const TStr& DNm="") const;
TIntV GetIfArgPrefixIntV(const TStr& PrefixStr, const TStr& DNm="") const {
TIntV DfValV; return GetIfArgPrefixIntV(PrefixStr, DfValV, DNm);}
double GetIfArgPrefixFlt(
const TStr& PrefixStr, const double& DfVal=0, const TStr& DNm="") const;
// environment variables
static void PutVarVal(const TStr& VarNm, const TStr& VarVal);
TStr GetVarVal(const TStr& VarNm) const;
void GetVarNmV(TStrV& VarNmV);
void GetVarNmValV(TStrV& NmValV);
};
extern TEnv Env;