25 typedef boost::tokenizer<boost::char_separator<char> > Tokeniser_T;
30 const boost::char_separator<char>
31 lSepatorList(
" .,;:|+-*/_=!@#$%`~^&(){}[]?'<>\"");
34 Tokeniser_T lTokens (iPhrase, lSepatorList);
35 for (Tokeniser_T::const_iterator tok_iter = lTokens.begin();
36 tok_iter != lTokens.end(); ++tok_iter) {
37 const std::string& lTerm = *tok_iter;
38 ioWordList.push_back (lTerm);
45 const bool iFromBeginningFlag) {
46 std::ostringstream oStr;
50 WordList_T::const_iterator itWord = iWordList.begin();
51 for ( ; itWord != iWordList.end(); ++itWord, ++idx) {
53 if (iFromBeginningFlag ==
true) {
58 if (iSplitIdx != 0 && idx >= iSplitIdx) {
67 const std::string& lWord = *itWord;
75 if (iSplitIdx == 0 || idx >= iSplitIdx) {
82 if (iFromBeginningFlag ==
true) {
87 assert (iFromBeginningFlag ==
false);
90 for ( ; itWord != iWordList.end(); ++itWord, ++idx) {
94 if (idx > iSplitIdx) {
98 const std::string& lWord = *itWord;
110 std::stringstream lConnStream (iSQLDBConnStr);
112 std::vector<std::string> kvList;
113 unsigned short keyDBName = 0;
114 unsigned short keyDBUser = 0;
115 unsigned short keyDBPasswd = 0;
116 unsigned short lastKey = 0;
118 while (std::getline (lConnStream, kvStr,
' ')) {
119 std::stringstream kvStream (kvStr);
122 while (std::getline (kvStream, keyStr,
'=')) {
123 if (keyStr ==
"db") {
128 }
else if (keyStr ==
"user") {
133 }
else if (keyStr ==
"password") {
135 keyDBPasswd = lastKey;
138 }
else if (lastKey == keyDBName) {
139 const bool isSuccess =
140 oStrMap.insert (std::make_pair (
"db", keyStr)).second;
141 if (isSuccess ==
false) {
142 std::ostringstream errStr;
143 errStr <<
"Internal error while inserting the SQL database name ('"
144 << keyDBName <<
"') into the internal STL map";
147 assert (isSuccess ==
true);
150 }
else if (lastKey == keyDBUser) {
151 const bool isSuccess =
152 oStrMap.insert (std::make_pair (
"user", keyStr)).second;
153 if (isSuccess ==
false) {
154 std::ostringstream errStr;
155 errStr <<
"Internal error while inserting the SQL database user ('"
156 << keyDBUser <<
"') into the internal STL map";
159 assert (isSuccess ==
true);
162 }
else if (lastKey == keyDBPasswd) {
163 const bool isSuccess =
164 oStrMap.insert (std::make_pair (
"password", keyStr)).second;
165 if (isSuccess ==
false) {
166 std::ostringstream errStr;
167 errStr <<
"Internal error while inserting the SQL database password "
168 <<
" into the internal STL map";
171 assert (isSuccess ==
true);
181 const StringMap_T::const_iterator itDBName = oStrMap.find (
"db");
182 if (itDBName == oStrMap.end()) {
183 std::ostringstream errStr;
184 errStr <<
"Error when parsing the SQL database connection string ('"
185 << iSQLDBConnStr <<
"'), the 'db' value cannot be found";
191 const StringMap_T::const_iterator itDBUser = oStrMap.find (
"user");
192 if (itDBUser == oStrMap.end()) {
193 std::ostringstream errStr;
194 errStr <<
"Error when parsing the SQL database connection string ('"
195 << iSQLDBConnStr <<
"'), the 'user' value cannot be found";
201 const StringMap_T::const_iterator itDBPasswd = oStrMap.find (
"password");
202 if (itDBPasswd == oStrMap.end()) {
203 std::ostringstream errStr;
204 errStr <<
"Error when parsing the SQL database connection string ('"
205 << iSQLDBConnStr <<
"'), the 'password' value cannot be found";
217 std::ostringstream oStr;
220 const StringMap_T::const_iterator itDBName = iStringMap.find (
"db");
221 assert (itDBName != iStringMap.end());
222 const std::string& lDBName = itDBName->second;
225 const StringMap_T::const_iterator itDBUser = iStringMap.find (
"user");
226 assert (itDBUser != iStringMap.end());
227 const std::string& lDBUser = itDBUser->second;
230 const StringMap_T::const_iterator itDBPasswd = iStringMap.find (
"password");
231 assert (itDBPasswd != iStringMap.end());
232 const std::string& lDBPasswd = itDBPasswd->second;
235 oStr <<
"db=" << lDBName;
236 if (lDBName !=
"mysql") {
237 oStr << iDeploymentNumber;
241 oStr <<
" user=" << lDBUser;
244 oStr <<
" password=" << lDBPasswd;
278 std::stringstream lConnStream (iSQLDBConnStr);
281 while (std::getline (lConnStream, kvStr,
' ')) {
286 const size_t eqPos = kvStr.find (
'=');
287 if (eqPos == std::string::npos) {
291 const std::string lKey = kvStr.substr (0, eqPos);
292 const std::string lVal = kvStr.substr (eqPos + 1);
293 oStrMap[lKey] = lVal;
297 if (oStrMap.find (
"dbname") == oStrMap.end()) {
298 std::ostringstream errStr;
299 errStr <<
"Error when parsing the PG connection string ('"
300 << iSQLDBConnStr <<
"'), the 'dbname' value cannot be found";
305 if (oStrMap.find (
"user") == oStrMap.end()) {
306 std::ostringstream errStr;
307 errStr <<
"Error when parsing the PG connection string ('"
308 << iSQLDBConnStr <<
"'), the 'user' value cannot be found";
313 if (oStrMap.find (
"password") == oStrMap.end()) {
314 std::ostringstream errStr;
315 errStr <<
"Error when parsing the PG connection string ('"
316 << iSQLDBConnStr <<
"'), the 'password' value cannot be found";
328 std::ostringstream oStr;
330 const StringMap_T::const_iterator itDBName = iStringMap.find (
"dbname");
331 assert (itDBName != iStringMap.end());
332 oStr <<
"dbname=" << itDBName->second << iDeploymentNumber;
334 const StringMap_T::const_iterator itDBUser = iStringMap.find (
"user");
335 assert (itDBUser != iStringMap.end());
336 oStr <<
" user=" << itDBUser->second;
338 const StringMap_T::const_iterator itDBPasswd = iStringMap.find (
"password");
339 assert (itDBPasswd != iStringMap.end());
340 oStr <<
" password=" << itDBPasswd->second;
343 const StringMap_T::const_iterator itHost = iStringMap.find (
"host");
344 if (itHost != iStringMap.end()) {
345 oStr <<
" host=" << itHost->second;
348 const StringMap_T::const_iterator itPort = iStringMap.find (
"port");
349 if (itPort != iStringMap.end()) {
350 oStr <<
" port=" << itPort->second;
381 const std::string& iSQLDBConnStr,
383 std::ostringstream oStr;
390 oStr << iSQLDBConnStr << iDeploymentNumber;
399 const std::string& lNewSQLDBConnStr =
401 oStr << lNewSQLDBConnStr;
410 const std::string& lNewSQLDBConnStr =
412 oStr << lNewSQLDBConnStr;