SNAP Library , Developer Reference  2013-01-07 14:03:36
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
env.h
Go to the documentation of this file.
00001 
00002 // Environment
00003 class TEnv{
00004 private:
00005   //int Args;
00006   //char** ArgV;
00007   TStrV ArgV;
00008   TStr HdStr;
00009   int MnArgs;
00010   bool SilentP;
00011   PNotify Notify;
00012 public:
00013   TEnv(): /*Args(0), ArgV(NULL)*/ ArgV(), HdStr(), MnArgs(1), SilentP(false), Notify(){}
00014   TEnv(const TEnv&);
00015   TEnv(const int& _Args, char** _ArgV, const PNotify& _Notify=NULL);
00016     //Args(_Args), ArgV(_ArgV), HdStr(), MnArgs(1), SilentP(false), Notify(_Notify){}
00017   TEnv(const TStr& _ArgStr, const PNotify& _Notify=NULL);
00018 
00019   TEnv& operator=(const TEnv& Env){
00020     /*Args=Env.Args;*/ ArgV=Env.ArgV; HdStr=Env.HdStr;
00021     MnArgs=Env.MnArgs; SilentP=Env.SilentP; Notify=Env.Notify; return *this;}
00022 
00023   // basic arguments & command line
00024   //int GetArgs() const {return Args;}
00025   int GetArgs() const {return ArgV.Len();}
00026   //TStr GetArg(const int& ArgN) const {
00027   //  IAssert((0<=ArgN)&&(ArgN<Args)); return TStr(ArgV[ArgN]);}
00028   TStr GetArg(const int& ArgN) const {
00029     IAssert((0<=ArgN)&&(ArgN<GetArgs())); return ArgV[ArgN];}
00030   TStr GetExeFNm() const;
00031   TStr GetExeFPath() const {return GetExeFNm().GetFPath();}
00032   TStr GetCmLn(const int& FromArgN=1) const;
00033   bool IsSilent() const {return SilentP;}
00034 
00035   // arguments prefix & postfix
00036   int GetPrefixArgN(const TStr& PrefixStr) const;
00037   bool IsArgPrefix(const TStr& PrefixStr) const {
00038     return GetPrefixArgN(PrefixStr)!=-1;}
00039   TStr GetArgPostfix(const TStr& PrefixStr) const;
00040 
00041   // top level arguments handling
00042   void PrepArgs(
00043    const TStr& _HdStr=TStr(), const int& _MnArgs=1, const bool& SilentP=false);
00044   TStr GetHdStr() const {return HdStr;}
00045   int GetMnArgs() const {return MnArgs;}
00046   bool IsEndOfRun() const;
00047 
00048   // arguments value retrieval
00049   bool IsArgStr(const TStr& ArgStr);
00050   TStr GetIfArgPrefixStr(
00051    const TStr& PrefixStr, const TStr& DfVal="", const TStr& DNm="") const;
00052   TStrV GetIfArgPrefixStrV(
00053    const TStr& PrefixStr, TStrV& DfValV, const TStr& DNm="") const;
00054   TStrV GetIfArgPrefixStrV(const TStr& PrefixStr, const TStr& DNm="") const {
00055     TStrV DfValV; return GetIfArgPrefixStrV(PrefixStr, DfValV, DNm);}
00056   bool GetIfArgPrefixBool(
00057    const TStr& PrefixStr, const bool& DfVal=false, const TStr& DNm="") const;
00058   int GetIfArgPrefixInt(
00059    const TStr& PrefixStr, const int& DfVal=0, const TStr& DNm="") const;
00060   TIntV GetIfArgPrefixIntV(
00061    const TStr& PrefixStr, TIntV& DfValV, const TStr& DNm="") const;
00062   TIntV GetIfArgPrefixIntV(const TStr& PrefixStr, const TStr& DNm="") const {
00063     TIntV DfValV; return GetIfArgPrefixIntV(PrefixStr, DfValV, DNm);}
00064   double GetIfArgPrefixFlt(
00065    const TStr& PrefixStr, const double& DfVal=0, const TStr& DNm="") const;
00066 
00067   // environment variables
00068   static void PutVarVal(const TStr& VarNm, const TStr& VarVal);
00069   TStr GetVarVal(const TStr& VarNm) const;
00070   void GetVarNmV(TStrV& VarNmV);
00071   void GetVarNmValV(TStrV& NmValV);
00072 };
00073 
00074 extern TEnv Env;
00075