本文整理汇总了C++中StringParser::setServer方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::setServer方法的具体用法?C++ StringParser::setServer怎么用?C++ StringParser::setServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::setServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backupIncremental
ErrorCode _CCONV FSBase::backupIncremental(const char * path, unsigned * amountChanged)
{
if (path == nullptr)
return INVALIDARG;
StringParser otherParser;
if (!otherParser.initialize(path))
otherParser.setServer(path);
if (otherParser.getServer().empty())
return INVALIDARG;
if (!createDir(otherParser.getServer()))
return FAILEDTOGETWINDIR;
fstream file;
string data;
ErrorCode retVal = getLogFileData(otherParser.getServer(), file, data);
if (failed(retVal))
return retVal;
PathTimeLog log(parser.getServer(), data);
if (log.isCorrupted())
return LOG_CORRUPTED;
unsigned amountBackup = 0;
retVal = backupAux(parser.getServer(), otherParser.getServer(), &log.getLastBackupTime(), amountBackup);
if (failed(retVal))
return retVal;
replaceRecordInData(parser.getServer(), log.getNowTime(), data);
retVal = setLogFileData(otherParser.getServer(), file, data);
if (amountChanged != nullptr)
*amountChanged = amountBackup;
return retVal;
}
示例2: backupFull
ErrorCode _CCONV FSBase::backupFull(const char * path, unsigned * amountChanged)
{
if (path == nullptr)
return INVALIDARG;
StringParser otherParser;
if (!otherParser.initialize(path))
otherParser.setServer(path);
if (otherParser.getServer().empty())
return INVALIDARG;
if (!createDir(otherParser.getServer()))
return FAILEDTOGETWINDIR;
unsigned amountBackup = 0;
ErrorCode res = backupAux(parser.getServer(), otherParser.getServer(), NULL, amountBackup);
if (amountChanged != nullptr)
*amountChanged = amountBackup;
return res;
}
示例3: makeLogRecord
//storage,db,table, params[bcp ~ storage/table], elapsed_time, comment([local,global],[hierarhy],[amount backuped])
//params for export files ~ amount of exported files
void makeLogRecord(const char * init, const char * params, const unsigned indexStorage, const char method,
const double time_elapsed, const char * comment)
{
if (indexStorage > 6) return;
const char * methodNames[] = { "FSStorage", "SMBStorage", "FTPStorage", "MsSQLStorage",
"PostgreSQLStorage", "SQLiteStorage", "MongoDB" };
string rel_path = methodNames[indexStorage];
if (!createDir(rel_path))
{
cout << "Can't create dir";
return;
}
string method_name, method_params;
switch (tolower(method))
{
case 'a':
method_name = "add";
method_params = d_makeWithQuotes(string(params));
break;
case 'g':
method_name = "get";
method_params = d_makeWithQuotes(string(params));
break;
case 'e':
method_name = "export";
method_params = d_makeWithQuotes(string(comment));
comment = nullptr;
break;
case 'f':
case 'i':
{
method_name = tolower(method) == 'f' ? "backupFull" : "backupIncremental";
StringParser parser(params);
method_params = mergeServerDbTable(parser);
break;
}
default:
cout << "Can't log unknown method";
return;
}
StringParser parser;
//for FSStorage
if (!parser.initialize(init))
parser.setServer(init);
//1 column: storage/db/table
string new_record = mergeServerDbTable(parser) + ',';
//2 column: params
new_record += method_params + ',';
//3 column: time
string s_time(30,'\0');
sprintf_s(&s_time[0], 30, "%f", time_elapsed);
s_time.resize(s_time.find('\0'));
new_record += s_time;
//4 column[opt]: comment
if (comment != nullptr && strlen(comment)>0)
{
new_record += ',' + string(comment);
}
rel_path = makePathFile(rel_path, method_name + ".csv");
ofstream f(rel_path, ofstream::app | ofstream::out);
if (!f.is_open())
{
cout << "Can't create/open log file" << endl;
return;
}
f.write(new_record.data(), new_record.size());
f << endl;
}