Changeset 8741 for trunk/MagicSoft/Mars/mbase/MEnv.cc
- Timestamp:
- 09/05/07 20:36:37 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MEnv.cc
r8731 r8741 57 57 #include "MLog.h" 58 58 #include "MLogManip.h" 59 60 #include "MArgs.h" 59 61 60 62 ClassImp(MEnv); … … 978 980 //--------------------------------------------------------------------------- 979 981 // 982 // Check MArgs for all options "--rc=" and remove them. Options should be 983 // given like 984 // 985 // program --rc=Option1:Test1 --rc=Option2.SubOption:Test2 986 // 987 // If all resources could be interpeted corrctly kTRUE is returned. If 988 // there were problems kFALSE is returned. 989 // 990 Bool_t MEnv::TakeEnv(MArgs &arg, Bool_t print, Bool_t overwrite) 991 { 992 if (!GetTable()) 993 { 994 gLog << err << "ERROR - MEnv not yet initialized." << endl; 995 return kFALSE; 996 } 997 998 Bool_t ret = kTRUE; 999 while (1) 1000 { 1001 const TString rc = arg.GetStringAndRemove("--rc="); 1002 if (rc.IsNull()) 1003 break; 1004 1005 const Ssiz_t pos = rc.First(':'); 1006 if (pos<0) 1007 { 1008 gLog << warn << "WARNING - Resource '" << rc << "' doesn't contain a colon... ignored." << endl; 1009 ret=kFALSE; 1010 continue; 1011 } 1012 if (pos==0) 1013 { 1014 gLog << warn << "WARNING - Resource '" << rc << "' doesn't contain a name... ignored." << endl; 1015 ret=kFALSE; 1016 continue; 1017 } 1018 if (pos==rc.Length()-1) 1019 { 1020 gLog << warn << "WARNING - Resource '" << rc << "' empty... ignored." << endl; 1021 ret=kFALSE; 1022 continue; 1023 } 1024 1025 const TString name = rc(0, pos); 1026 const TString val = rc(pos+1, rc.Length()); 1027 1028 if (print) 1029 gLog << all << "Command line resource '" << name << "' with value '" << val << "'..."; 1030 1031 const Bool_t exists = Defined(name); 1032 if (!exists) 1033 { 1034 SetValue(name, val, kEnvLocal); 1035 if (print) 1036 gLog << "set." << endl; 1037 continue; 1038 } 1039 1040 if (overwrite) 1041 { 1042 SetValue(name, ""); 1043 SetValue(name, val, kEnvLocal); 1044 if (print) 1045 gLog << "changed." << endl; 1046 continue; 1047 } 1048 1049 if (print) 1050 gLog << "skipped/existing." << endl; 1051 } 1052 return ret; 1053 } 1054 1055 //--------------------------------------------------------------------------- 1056 // 980 1057 // Add name and full path to output 981 1058 //
Note:
See TracChangeset
for help on using the changeset viewer.