#include <varpath.h>
Public Member Functions | |
CVarPath (const std::string &raw) | |
void | decode () |
void | display () |
bool | empty () |
bool | isFinal () |
returns true if there s no more . in the path | |
Data Fields | |
std::vector< std::pair< std::string, std::string > > | Destination |
Private Member Functions | |
std::string | getToken () |
Private Attributes | |
std::string | RawVarPath |
uint32 | TokenPos |
|
Definition at line 35 of file varpath.h. References decode(), and RawVarPath.
00035 : RawVarPath(raw) 00036 { 00037 decode (); 00038 } |
|
Definition at line 101 of file varpath.cpp. References getToken(), nlwarning, RawVarPath, TokenPos, and uint. Referenced by CVarPath().
00102 { 00103 vector<string> dest; 00104 TokenPos = 0; 00105 Destination.clear (); 00106 00107 string val = getToken (); 00108 00109 if (val == "") 00110 return; 00111 00112 if (val == "[" ) 00113 { 00114 do 00115 { 00116 uint osbnb = 0; 00117 string d; 00118 do 00119 { 00120 val = getToken (); 00121 if (val == "[") 00122 osbnb++; 00123 00124 // end of token 00125 if (val == "") 00126 { 00127 nlwarning ("VP: Bad VarPath '%s', suppose it s an empty varpath", RawVarPath.c_str()); 00128 Destination.clear (); 00129 return; 00130 } 00131 00132 if (osbnb == 0 && (val == "," || val == "]")) 00133 break; 00134 00135 if (val == "]") 00136 osbnb--; 00137 00138 d += val; 00139 } 00140 while (true); 00141 dest.push_back (d); 00142 if (val == "]") 00143 break; 00144 } 00145 while (true); 00146 } 00147 else if (val != "." && val != "," && val != "]") 00148 { 00149 dest.push_back (val); 00150 } 00151 else 00152 { 00153 nlwarning ("VP: Malformated VarPath '%s' before position %d", RawVarPath.c_str (), TokenPos); 00154 return; 00155 } 00156 00157 // must the a . or end of string 00158 val = getToken (); 00159 if (val == " ") 00160 { 00161 // special case, there s a space that means that everything after is not really part of the varpath. 00162 Destination.push_back (make_pair(RawVarPath, string(""))); 00163 return; 00164 } 00165 else if (val != "." && val != "" && val != "=") 00166 { 00167 nlwarning ("VP: Malformated VarPath '%s' before position %d", RawVarPath.c_str (), TokenPos); 00168 return; 00169 } 00170 00171 for (uint i = 0; i < dest.size(); ++i) 00172 { 00173 string srv, var; 00174 uint pos; 00175 00176 if ((pos = dest[i].find ('.')) != string::npos) 00177 { 00178 srv = dest[i].substr(0, pos); 00179 var = dest[i].substr(pos+1); 00180 if (TokenPos < RawVarPath.size()) 00181 var += val + RawVarPath.substr (TokenPos); 00182 } 00183 else 00184 { 00185 srv = dest[i]; 00186 if (val == "=") 00187 { 00188 srv += val + RawVarPath.substr (TokenPos); 00189 var = ""; 00190 } 00191 else 00192 var = RawVarPath.substr (TokenPos); 00193 } 00194 00195 Destination.push_back (make_pair(srv, var)); 00196 } 00197 00198 //display (); 00199 } |
|
Definition at line 208 of file varpath.cpp.
00209 { 00210 nlinfo ("VP: VarPath dest = %d", Destination.size ()); 00211 for (uint i = 0; i < Destination.size (); i++) 00212 { 00213 nlinfo ("VP: > '%s' '%s'", Destination[i].first.c_str(), Destination[i].second.c_str()); 00214 } 00215 } |
|
Definition at line 49 of file varpath.h. Referenced by NLNET::serviceGetView().
00050 { 00051 return Destination.empty(); 00052 } |
|
VarPath ::= [bloc '.']* bloc bloc ::= '[' [VarPath ',']* VarPath ']' | name name ::= [ascii]* ['*'] Definition at line 77 of file varpath.cpp. References RawVarPath, res, and TokenPos. Referenced by decode().
00078 { 00079 string res; 00080 00081 if (TokenPos >= RawVarPath.size()) 00082 return res; 00083 00084 res += RawVarPath[TokenPos]; 00085 00086 switch (RawVarPath[TokenPos++]) 00087 { 00088 case '.': case '*': case '[': case ']': case ',': case '=': case ' ': 00089 break; 00090 default : 00091 while (TokenPos < RawVarPath.size() && RawVarPath[TokenPos] != '.' && RawVarPath[TokenPos] != '[' && RawVarPath[TokenPos] != ']' && RawVarPath[TokenPos] != ',' && RawVarPath[TokenPos] != '=' && RawVarPath[TokenPos] != ' ') 00092 { 00093 res += RawVarPath[TokenPos++]; 00094 } 00095 break; 00096 } 00097 return res; 00098 } |
|
returns true if there s no more . in the path
Definition at line 201 of file varpath.cpp. Referenced by NLNET::serviceGetView().
00202 { 00203 if(Destination.size() == 0) return true; 00204 if(Destination[0].second.size() == 0) return true; 00205 return false; 00206 } |
|
Definition at line 42 of file varpath.h. Referenced by NLMISC_COMMAND(), NLNET::serviceGetView(), and NLNET::setInformations(). |
|
Definition at line 58 of file varpath.h. Referenced by CVarPath(), decode(), and getToken(). |
|
Definition at line 60 of file varpath.h. Referenced by decode(), and getToken(). |