SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TEnv Class Reference

#include <env.h>

Public Member Functions

 TEnv ()
 
 TEnv (const TEnv &)
 
 TEnv (const int &_Args, char **_ArgV, const PNotify &_Notify=NULL)
 
 TEnv (const TStr &_ArgStr, const PNotify &_Notify=NULL)
 
TEnvoperator= (const TEnv &Env)
 
int GetArgs () const
 
TStr GetArg (const int &ArgN) const
 
TStr GetExeFNm () const
 
TStr GetExeFPath () const
 
TStr GetCmLn (const int &FromArgN=1) const
 
bool IsSilent () const
 
int GetPrefixArgN (const TStr &PrefixStr) const
 
bool IsArgPrefix (const TStr &PrefixStr) const
 
TStr GetArgPostfix (const TStr &PrefixStr) const
 
void PrepArgs (const TStr &_HdStr=TStr(), const int &_MnArgs=1, const bool &SilentP=false)
 
TStr GetHdStr () const
 
int GetMnArgs () const
 
bool IsEndOfRun () const
 
bool IsArgStr (const TStr &ArgStr)
 
bool IsArgStr (const TStr &ArgStr, const TStr &DNm)
 
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
 
TStrSet GetIfArgPrefixStrSet (const TStr &PrefixStr, TStrV &DfValV, const TStr &DNm="") const
 
TStrSet GetIfArgPrefixStrSet (const TStr &PrefixStr, const TStr &DNm="") const
 
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
 
double GetIfArgPrefixFlt (const TStr &PrefixStr, const double &DfVal=0, const TStr &DNm="") const
 
TStr GetVarVal (const TStr &VarNm) const
 
void GetVarNmV (TStrV &VarNmV)
 
void GetVarNmValV (TStrV &NmValV)
 

Static Public Member Functions

static void PutVarVal (const TStr &VarNm, const TStr &VarVal)
 

Private Attributes

TStrV ArgV
 
TStr HdStr
 
int MnArgs
 
bool SilentP
 
PNotify Notify
 

Detailed Description

Definition at line 3 of file env.h.

Constructor & Destructor Documentation

TEnv::TEnv ( )
inline

Definition at line 13 of file env.h.

13 : /*Args(0), ArgV(NULL)*/ ArgV(), HdStr(), MnArgs(1), SilentP(false), Notify(){}
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TStrV ArgV
Definition: env.h:7
PNotify Notify
Definition: env.h:11
TEnv::TEnv ( const TEnv )
TEnv::TEnv ( const int &  _Args,
char **  _ArgV,
const PNotify _Notify = NULL 
)

Definition at line 3 of file env.cpp.

3  :
4  ArgV(), HdStr(), MnArgs(1), SilentP(false), Notify(_Notify) {
5  for (int ArgN = 0; ArgN < _Args; ArgN++)
6  ArgV.Add(TStr(_ArgV[ArgN]));
7 }
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TStrV ArgV
Definition: env.h:7
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
TEnv::TEnv ( const TStr _ArgStr,
const PNotify _Notify = NULL 
)

Definition at line 9 of file env.cpp.

9  :
10  ArgV(), HdStr(), MnArgs(1), SilentP(false), Notify(_Notify) {
11  _ArgStr.SplitOnAllCh(' ', ArgV);
12 }
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TStrV ArgV
Definition: env.h:7
PNotify Notify
Definition: env.h:11
void SplitOnAllCh(const char &SplitCh, TStrV &StrV, const bool &SkipEmpty=true) const
Definition: dt.cpp:926

Member Function Documentation

TStr TEnv::GetArg ( const int &  ArgN) const
inline

Definition at line 28 of file env.h.

28  {
29  IAssert((0<=ArgN)&&(ArgN<GetArgs())); return ArgV[ArgN];}
#define IAssert(Cond)
Definition: bd.h:262
TStrV ArgV
Definition: env.h:7
int GetArgs() const
Definition: env.h:25
TStr TEnv::GetArgPostfix ( const TStr PrefixStr) const

Definition at line 40 of file env.cpp.

40  {
41  int ArgN=GetPrefixArgN(PrefixStr); IAssert(ArgN!=-1);
42  TStr ArgStr=GetArg(ArgN);
43  return ArgStr.GetSubStr(PrefixStr.Len(), ArgStr.Len());
44 }
#define IAssert(Cond)
Definition: bd.h:262
int Len() const
Definition: dt.h:487
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
int GetPrefixArgN(const TStr &PrefixStr) const
Definition: env.cpp:31
Definition: dt.h:412
TStr GetArg(const int &ArgN) const
Definition: env.h:28
int TEnv::GetArgs ( ) const
inline

Definition at line 25 of file env.h.

25 {return ArgV.Len();}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TStrV ArgV
Definition: env.h:7
TStr TEnv::GetCmLn ( const int &  FromArgN = 1) const

Definition at line 22 of file env.cpp.

22  {
23  TChA CmLnChA;
24  for (int ArgN=FromArgN; ArgN<GetArgs(); ArgN++){
25  if (ArgN>FromArgN){CmLnChA+=' ';}
26  CmLnChA+=GetArg(ArgN);
27  }
28  return CmLnChA;
29 }
Definition: dt.h:201
int GetArgs() const
Definition: env.h:25
TStr GetArg(const int &ArgN) const
Definition: env.h:28
TStr TEnv::GetExeFNm ( ) const

Definition at line 14 of file env.cpp.

14  {
15  TStr ExeFNm=GetArg(0);
16  if (ExeFNm.IsPrefix("//?")){ // observed on Win64 CGI
17  ExeFNm=ExeFNm.GetSubStr(3, ExeFNm.Len());
18  }
19  return ExeFNm;
20 }
int Len() const
Definition: dt.h:487
bool IsPrefix(const char *Str) const
Definition: dt.cpp:1081
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
Definition: dt.h:412
TStr GetArg(const int &ArgN) const
Definition: env.h:28
TStr TEnv::GetExeFPath ( ) const
inline

Definition at line 31 of file env.h.

31 {return GetExeFNm().GetFPath();}
TStr GetFPath() const
Definition: dt.cpp:1389
TStr GetExeFNm() const
Definition: env.cpp:14
TStr TEnv::GetHdStr ( ) const
inline

Definition at line 44 of file env.h.

44 {return HdStr;}
TStr HdStr
Definition: env.h:8
bool TEnv::GetIfArgPrefixBool ( const TStr PrefixStr,
const bool &  DfVal = false,
const TStr DNm = "" 
) const

Definition at line 178 of file env.cpp.

179  {
180  if (Env.GetArgs()<=MnArgs){
181  // 'usage' argument message
182  if (!SilentP){
183  printf(" %s%s (default:'%s')\n",
184  PrefixStr.CStr(), DNm.CStr(), TBool::GetStr(DfVal).CStr());}
185  return DfVal;
186  } else {
187  // argument & value message
188  bool Val;
189  if ((PrefixStr.Len()>0)&&(PrefixStr.LastCh()==':')){
190  if (Env.IsArgPrefix(PrefixStr)){
191  // try to find one of boolean string value representations
192  TStr ValStr=Env.GetArgPostfix(PrefixStr);
193  Val=TBool::GetValFromStr(ValStr, DfVal);
194  } else {
195  // remove ':' and try to find option
196  TStr RedPrefixStr=PrefixStr;
197  RedPrefixStr.DelSubStr(PrefixStr.Len()-1, PrefixStr.Len()-1);
198  if (Env.IsArgPrefix(RedPrefixStr)){Val=true;} else {Val=DfVal;}
199  }
200  } else {
201  if (Env.IsArgPrefix(PrefixStr)){Val=true;} else {Val=DfVal;}
202  }
203  TStr MsgStr=DNm+" ("+PrefixStr+")="+TBool::GetYesNoStr(Val);
204  if (!SilentP){TNotify::OnStatus(Notify, MsgStr);}
205  return Val;
206  }
207 }
int Len() const
Definition: dt.h:487
bool SilentP
Definition: env.h:10
static TStr GetYesNoStr(const bool &Val)
Definition: dt.h:924
static bool GetValFromStr(const TStr &Str)
Definition: dt.cpp:1850
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool IsArgPrefix(const TStr &PrefixStr) const
Definition: env.h:37
char LastCh() const
Definition: dt.h:484
void DelSubStr(const int &BChN, const int &EChN)
Definition: dt.cpp:850
TStr GetArgPostfix(const TStr &PrefixStr) const
Definition: env.cpp:40
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
static TStr GetStr(const bool &Val)
Definition: dt.h:918
char * CStr()
Definition: dt.h:476
double TEnv::GetIfArgPrefixFlt ( const TStr PrefixStr,
const double &  DfVal = 0,
const TStr DNm = "" 
) const

Definition at line 250 of file env.cpp.

251  {
252  if (Env.GetArgs()<=MnArgs){
253  // 'usage' argument message
254  if (!SilentP){
255  printf(" %s%s (default:%g)\n", PrefixStr.CStr(), DNm.CStr(), DfVal);}
256  return DfVal;
257  } else {
258  // argument & value message
259  double Val;
260  if (Env.IsArgPrefix(PrefixStr)){
261  TStr ValStr=Env.GetArgPostfix(PrefixStr);
262  Val=ValStr.GetFlt(DfVal);
263  } else {
264  Val=DfVal;
265  }
266  TStr MsgStr=DNm+" ("+PrefixStr+")="+TFlt::GetStr(Val);
267  if (!SilentP){TNotify::OnStatus(Notify, MsgStr);}
268  return Val;
269  }
270 }
bool SilentP
Definition: env.h:10
double GetFlt() const
Definition: dt.h:628
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool IsArgPrefix(const TStr &PrefixStr) const
Definition: env.h:37
TStr GetArgPostfix(const TStr &PrefixStr) const
Definition: env.cpp:40
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
TStr GetStr() const
Definition: dt.h:1369
char * CStr()
Definition: dt.h:476
int TEnv::GetIfArgPrefixInt ( const TStr PrefixStr,
const int &  DfVal = 0,
const TStr DNm = "" 
) const

Definition at line 209 of file env.cpp.

210  {
211  if (Env.GetArgs()<=MnArgs){
212  // 'usage' argument message
213  if (!SilentP){
214  printf(" %s%s (default:%d)\n", PrefixStr.CStr(), DNm.CStr(), DfVal);}
215  return DfVal;
216  } else {
217  // argument & value message
218  int Val;
219  if (Env.IsArgPrefix(PrefixStr)){
220  TStr ValStr=Env.GetArgPostfix(PrefixStr);
221  Val=ValStr.GetInt(DfVal);
222  } else {
223  Val=DfVal;
224  }
225  TStr MsgStr=DNm+" ("+PrefixStr+")="+TInt::GetStr(Val);
226  if (!SilentP){TNotify::OnStatus(Notify, MsgStr);}
227  return Val;
228  }
229 }
int GetInt() const
Definition: dt.h:578
TStr GetStr() const
Definition: dt.h:1107
bool SilentP
Definition: env.h:10
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool IsArgPrefix(const TStr &PrefixStr) const
Definition: env.h:37
TStr GetArgPostfix(const TStr &PrefixStr) const
Definition: env.cpp:40
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
char * CStr()
Definition: dt.h:476
TIntV TEnv::GetIfArgPrefixIntV ( const TStr PrefixStr,
TIntV DfValV,
const TStr DNm = "" 
) const

Definition at line 231 of file env.cpp.

232  {
233  // convert default-integer-values to default-string-values
234  TStrV DfValStrV;
235  for (int ValN=0; ValN<DfValV.Len(); ValN++){
236  DfValStrV.Add(TInt::GetStr(DfValV[ValN]));}
237  // get string-values
238  TStrV ValStrV=GetIfArgPrefixStrV(PrefixStr, DfValStrV, DNm);
239  // convert string-values to integer-values
240  TIntV ValV;
241  for (int ValN=0; ValN<ValStrV.Len(); ValN++){
242  int Val;
243  if (ValStrV[ValN].IsInt(Val)){
244  ValV.Add(Val);}
245  }
246  // return value-vector
247  return ValV;
248 }
TStr GetStr() const
Definition: dt.h:1107
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TStrV GetIfArgPrefixStrV(const TStr &PrefixStr, TStrV &DfValV, const TStr &DNm="") const
Definition: env.cpp:136
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
TIntV TEnv::GetIfArgPrefixIntV ( const TStr PrefixStr,
const TStr DNm = "" 
) const
inline

Definition at line 62 of file env.h.

62  {
63  TIntV DfValV; return GetIfArgPrefixIntV(PrefixStr, DfValV, DNm);}
TIntV GetIfArgPrefixIntV(const TStr &PrefixStr, TIntV &DfValV, const TStr &DNm="") const
Definition: env.cpp:231
TStr TEnv::GetIfArgPrefixStr ( const TStr PrefixStr,
const TStr DfVal = "",
const TStr DNm = "" 
) const

Definition at line 110 of file env.cpp.

111  {
112  if (Env.GetArgs()<=MnArgs){
113  // 'usage' argument message
114  if (!SilentP){
115  printf(" %s%s (default:'%s')\n", PrefixStr.CStr(), DNm.CStr(), DfVal.CStr());}
116  return DfVal;
117  } else {
118  // argument & value message
119  TStr Val;
120  if (Env.IsArgPrefix(PrefixStr)){
121  Val=Env.GetArgPostfix(PrefixStr);
122  if (Val.Len()>1){
123  if ((Val[0]=='\"')&&(Val.LastCh()=='\"')){
124  Val=Val.GetSubStr(1, Val.Len()-2);
125  }
126  }
127  } else {
128  Val=DfVal;
129  }
130  TStr MsgStr=DNm+" ("+PrefixStr+")="+Val;
131  if (!SilentP){TNotify::OnStatus(Notify, MsgStr);}
132  return Val;
133  }
134 }
int Len() const
Definition: dt.h:487
bool SilentP
Definition: env.h:10
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool IsArgPrefix(const TStr &PrefixStr) const
Definition: env.h:37
char LastCh() const
Definition: dt.h:484
TStr GetArgPostfix(const TStr &PrefixStr) const
Definition: env.cpp:40
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
char * CStr()
Definition: dt.h:476
TStrSet TEnv::GetIfArgPrefixStrSet ( const TStr PrefixStr,
TStrV DfValV,
const TStr DNm = "" 
) const
inline

Definition at line 55 of file env.h.

55  {
56  return TStrSet(GetIfArgPrefixStrV(PrefixStr, DfValV, DNm));}
TStrV GetIfArgPrefixStrV(const TStr &PrefixStr, TStrV &DfValV, const TStr &DNm="") const
Definition: env.cpp:136
THashSet< TStr > TStrSet
Definition: shash.h:1385
TStrSet TEnv::GetIfArgPrefixStrSet ( const TStr PrefixStr,
const TStr DNm = "" 
) const
inline

Definition at line 57 of file env.h.

57  {
58  return TStrSet(GetIfArgPrefixStrV(PrefixStr, DNm));}
TStrV GetIfArgPrefixStrV(const TStr &PrefixStr, TStrV &DfValV, const TStr &DNm="") const
Definition: env.cpp:136
THashSet< TStr > TStrSet
Definition: shash.h:1385
TStrV TEnv::GetIfArgPrefixStrV ( const TStr PrefixStr,
TStrV DfValV,
const TStr DNm = "" 
) const

Definition at line 136 of file env.cpp.

137  {
138  TStrV ArgValV;
139  if (Env.GetArgs()<=MnArgs){
140  // 'usage' argument message
141  if (!SilentP){
142  printf(" %s%s (default:", PrefixStr.CStr(), DNm.CStr());
143  for (int DfValN=0; DfValN<DfValV.Len(); DfValN++){
144  if (DfValN>0){printf(", ");}
145  printf("'%s'", DfValV[DfValN].CStr());
146  }
147  printf(")\n");
148  }
149  return ArgValV;
150  } else {
151  // argument & value message
152  TStr ArgValVChA;
153  for (int ArgN=0; ArgN<GetArgs(); ArgN++){
154  // get argument string
155  TStr ArgStr=GetArg(ArgN);
156  if (ArgStr.GetSubStr(0, PrefixStr.Len()-1)==PrefixStr){
157  // extract & add argument value
158  TStr ArgVal=ArgStr.GetSubStr(PrefixStr.Len(), ArgStr.Len());
159  ArgValV.Add(ArgVal);
160  // add to message string
161  if (ArgValV.Len()>1){ArgValVChA+=", ";}
162  ArgValVChA+=ArgValV.Last();
163  }
164  }
165  if (ArgValV.Empty()){ArgValV=DfValV;}
166  // output argument values
167  TChA MsgChA;
168  MsgChA+=DNm; MsgChA+=" ("; MsgChA+=PrefixStr; MsgChA+=")=";
169  for (int ArgValN=0; ArgValN<ArgValV.Len(); ArgValN++){
170  if (ArgValN>0){MsgChA+=", ";}
171  MsgChA+="'"; MsgChA+=ArgValV[ArgValN]; MsgChA+="'";
172  }
173  if (!SilentP){TNotify::OnStatus(Notify, MsgChA);}
174  return ArgValV;
175  }
176 }
int Len() const
Definition: dt.h:487
bool SilentP
Definition: env.h:10
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
TStr GetSubStr(const int &BChN, const int &EChN) const
Definition: dt.cpp:811
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:542
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:551
Definition: dt.h:201
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
TStr GetArg(const int &ArgN) const
Definition: env.h:28
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
TStrV TEnv::GetIfArgPrefixStrV ( const TStr PrefixStr,
const TStr DNm = "" 
) const
inline

Definition at line 53 of file env.h.

53  {
54  TStrV DfValV; return GetIfArgPrefixStrV(PrefixStr, DfValV, DNm);}
TStrV GetIfArgPrefixStrV(const TStr &PrefixStr, TStrV &DfValV, const TStr &DNm="") const
Definition: env.cpp:136
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429
int TEnv::GetMnArgs ( ) const
inline

Definition at line 45 of file env.h.

45 {return MnArgs;}
int MnArgs
Definition: env.h:9
int TEnv::GetPrefixArgN ( const TStr PrefixStr) const

Definition at line 31 of file env.cpp.

31  {
32  int ArgN=0;
33  while (ArgN<GetArgs()){
34  if (GetArg(ArgN).GetSubStr(0, PrefixStr.Len()-1)==PrefixStr){return ArgN;}
35  ArgN++;
36  }
37  return -1;
38 }
int Len() const
Definition: dt.h:487
int GetArgs() const
Definition: env.h:25
TStr GetArg(const int &ArgN) const
Definition: env.h:28
void TEnv::GetVarNmV ( TStrV VarNmV)

Definition at line 272 of file env.cpp.

272  {
273  VarNmV.Clr(); int VarN=0;
274  while (_environ[VarN]!=NULL){
275  TStr VarNmVal=_environ[VarN++];
276  TStr VarNm; TStr VarVal; VarNmVal.SplitOnCh(VarNm, '=', VarVal);
277  VarNmV.Add(VarNm);
278  }
279 }
void SplitOnCh(TStr &LStr, const char &SplitCh, TStr &RStr) const
Definition: dt.cpp:901
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:971
Definition: dt.h:412
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
void TEnv::GetVarNmValV ( TStrV NmValV)

Definition at line 281 of file env.cpp.

281  {
282  VarNmValV.Clr(); int VarN=0;
283  while (_environ[VarN]!=NULL){
284  VarNmValV.Add(_environ[VarN++]);
285  }
286 }
TStr TEnv::GetVarVal ( const TStr VarNm) const

Definition at line 293 of file env.cpp.

293  {
294  return TStr(getenv(VarNm.CStr()));
295 }
Definition: dt.h:412
char * CStr()
Definition: dt.h:476
bool TEnv::IsArgPrefix ( const TStr PrefixStr) const
inline

Definition at line 37 of file env.h.

37  {
38  return GetPrefixArgN(PrefixStr)!=-1;}
int GetPrefixArgN(const TStr &PrefixStr) const
Definition: env.cpp:31
bool TEnv::IsArgStr ( const TStr ArgStr)

Definition at line 86 of file env.cpp.

86  {
87  int ArgN=0;
88  while (ArgN<GetArgs()){
89  if (GetArg(ArgN)==ArgStr){return true;}
90  ArgN++;
91  }
92  return false;
93 }
int GetArgs() const
Definition: env.h:25
TStr GetArg(const int &ArgN) const
Definition: env.h:28
bool TEnv::IsArgStr ( const TStr ArgStr,
const TStr DNm 
)

Definition at line 95 of file env.cpp.

95  {
96  if (Env.GetArgs()<=MnArgs){
97  // 'usage' argument message
98  if (!SilentP){
99  printf(" %s %s \n", ArgStr.CStr(), DNm.CStr());}
100  return false;
101  } else {
102  // argument & value message
103  bool Val=Env.IsArgStr(ArgStr);
104  TStr MsgStr=DNm+" ("+ArgStr+(Val?")=YES":")=NO");
105  if (!SilentP){TNotify::OnStatus(Notify, MsgStr);}
106  return Val;
107  }
108 }
bool SilentP
Definition: env.h:10
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool IsArgStr(const TStr &ArgStr)
Definition: env.cpp:86
Definition: dt.h:412
PNotify Notify
Definition: env.h:11
virtual void OnStatus(const TStr &)
Definition: ut.h:39
int GetArgs() const
Definition: env.h:25
char * CStr()
Definition: dt.h:476
bool TEnv::IsEndOfRun ( ) const

Definition at line 72 of file env.cpp.

72  {
73  if (!SilentP){
74  // print line in length of header-line
75  if (HdStr.Empty()){
76  printf("========================================\n");
77  } else {
78  for (int ChN=0; ChN<HdStr.Len(); ChN++){printf("=");}
79  printf("\n");
80  }
81  }
82  // return
83  return Env.GetArgs()<=MnArgs;
84 }
int Len() const
Definition: dt.h:487
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool Empty() const
Definition: dt.h:488
int GetArgs() const
Definition: env.h:25
bool TEnv::IsSilent ( ) const
inline

Definition at line 33 of file env.h.

33 {return SilentP;}
bool SilentP
Definition: env.h:10
TEnv& TEnv::operator= ( const TEnv Env)
inline

Definition at line 19 of file env.h.

19  {
20  /*Args=Env.Args;*/ ArgV=Env.ArgV; HdStr=Env.HdStr;
21  MnArgs=Env.MnArgs; SilentP=Env.SilentP; Notify=Env.Notify; return *this;}
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TStrV ArgV
Definition: env.h:7
PNotify Notify
Definition: env.h:11
void TEnv::PrepArgs ( const TStr _HdStr = TStr(),
const int &  _MnArgs = 1,
const bool &  SilentP = false 
)

Definition at line 46 of file env.cpp.

46  {
47  // put environment state
48  HdStr=_HdStr;
49  MnArgs=_MnArgs;
50  // silence
51  SilentP=true;
52  SilentP=Env.GetIfArgPrefixBool("-silent:", false, "Silence");
53  // start header
54  if (!SilentP){
55  // print header
56  if (!HdStr.Empty()){
57  // print header-string
58  TStr DateStr=__DATE__;
59  printf("%s [%s]\n", HdStr.CStr(), DateStr.CStr());
60  // print header-line
61  for (int ChN=0; ChN<HdStr.Len()+DateStr.Len()+3; ChN++){printf("=");}
62  printf("\n");
63  }
64  // print start of 'usage' message if not enough arguments
65  if (Env.GetArgs()<=MnArgs){
66  TStr ExeFNm=Env.GetArg(0).GetFBase();
67  printf("usage: %s\n", ExeFNm.CStr());
68  }
69  }
70 }
int Len() const
Definition: dt.h:487
bool SilentP
Definition: env.h:10
TStr HdStr
Definition: env.h:8
int MnArgs
Definition: env.h:9
TEnv Env
Definition: env.cpp:297
bool GetIfArgPrefixBool(const TStr &PrefixStr, const bool &DfVal=false, const TStr &DNm="") const
Definition: env.cpp:178
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
int GetArgs() const
Definition: env.h:25
char * CStr()
Definition: dt.h:476
TStr GetFBase() const
Definition: dt.cpp:1396
TStr GetArg(const int &ArgN) const
Definition: env.h:28
void TEnv::PutVarVal ( const TStr VarNm,
const TStr VarVal 
)
static

Definition at line 288 of file env.cpp.

288  {
289  const int RetVal = putenv(TStr::Fmt("%s=%s", VarNm.CStr(), VarVal.CStr()).CStr());
290  IAssert(RetVal==0);
291 }
#define IAssert(Cond)
Definition: bd.h:262
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476

Member Data Documentation

TStrV TEnv::ArgV
private

Definition at line 7 of file env.h.

TStr TEnv::HdStr
private

Definition at line 8 of file env.h.

int TEnv::MnArgs
private

Definition at line 9 of file env.h.

PNotify TEnv::Notify
private

Definition at line 11 of file env.h.

bool TEnv::SilentP
private

Definition at line 10 of file env.h.


The documentation for this class was generated from the following files: