9 #include <boost/tokenizer.hpp>
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 assert (isSuccess ==
true);
144 }
else if (lastKey == keyDBUser) {
145 const bool isSuccess =
146 oStrMap.insert (std::make_pair (
"user", keyStr)).second;
147 assert (isSuccess ==
true);
150 }
else if (lastKey == keyDBPasswd) {
151 const bool isSuccess =
152 oStrMap.insert (std::make_pair (
"password", keyStr)).second;
153 assert (isSuccess ==
true);
163 const StringMap_T::const_iterator itDBName = oStrMap.find (
"db");
164 if (itDBName == oStrMap.end()) {
165 std::ostringstream errStr;
166 errStr <<
"Error when parsing the SQL database connection string ('"
167 << iSQLDBConnStr <<
"'), the 'db' value cannot be found";
173 const StringMap_T::const_iterator itDBUser = oStrMap.find (
"user");
174 if (itDBUser == oStrMap.end()) {
175 std::ostringstream errStr;
176 errStr <<
"Error when parsing the SQL database connection string ('"
177 << iSQLDBConnStr <<
"'), the 'user' value cannot be found";
183 const StringMap_T::const_iterator itDBPasswd = oStrMap.find (
"password");
184 if (itDBPasswd == oStrMap.end()) {
185 std::ostringstream errStr;
186 errStr <<
"Error when parsing the SQL database connection string ('"
187 << iSQLDBConnStr <<
"'), the 'password' value cannot be found";
196 SQLDBConnectionString_T
199 std::ostringstream oStr;
202 const StringMap_T::const_iterator itDBName = iStringMap.find (
"db");
203 assert (itDBName != iStringMap.end());
204 const std::string& lDBName = itDBName->second;
207 const StringMap_T::const_iterator itDBUser = iStringMap.find (
"user");
208 assert (itDBUser != iStringMap.end());
209 const std::string& lDBUser = itDBUser->second;
212 const StringMap_T::const_iterator itDBPasswd = iStringMap.find (
"password");
213 assert (itDBPasswd != iStringMap.end());
214 const std::string& lDBPasswd = itDBPasswd->second;
217 oStr <<
"db=" << lDBName;
218 if (lDBName !=
"mysql") {
219 oStr << iDeploymentNumber;
223 oStr <<
" user=" << lDBUser;
226 oStr <<
" password=" << lDBPasswd;
235 std::ostringstream oStr;
237 for (StringMap_T::const_iterator itDBKV = iStringMap.begin();
238 itDBKV != iStringMap.end(); ++itDBKV) {
239 const std::string& lDBKey = itDBKV->first;
240 const std::string& lDBValue = itDBKV->second;
241 oStr << lDBKey <<
"=";
243 if (lDBKey ==
"db" && lDBValue !=
"mysql"
245 oStr << iDeploymentNumber;
256 const std::string& iSQLDBConnStr,
258 std::ostringstream oStr;
265 oStr << iSQLDBConnStr << iDeploymentNumber;
274 const std::string& lNewSQLDBConnStr =
276 oStr << lNewSQLDBConnStr;