本文整理汇总了C++中SubscriberRegistry::db方法的典型用法代码示例。如果您正苦于以下问题:C++ SubscriberRegistry::db方法的具体用法?C++ SubscriberRegistry::db怎么用?C++ SubscriberRegistry::db使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubscriberRegistry
的用法示例。
在下文中一共展示了SubscriberRegistry::db方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: table
void table(const char *tableName, vector<string> &cols, bool addButtonP, const char *note)
{
cout << "<h4>" << gDatabase << "." << tableName << " " << note << "</h4>\n";
initTable(cols);
ostringstream os;
os << "select id," << join(",", cols) << " from " << tableName;
sqlite3_stmt *stmt;
if (sqlite3_prepare_statement(gSubscriberRegistry.db(), &stmt,os.str().c_str())) {
LOG(ERR) << "sqlite3_prepare_statement problem - statement: " << os.str();
LOG(ERR) << " " << sqlite3_errmsg(gSubscriberRegistry.db());
return;
}
int src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
while (src == SQLITE_ROW) {
vector<string> values;
const char *id = (const char*)sqlite3_column_text(stmt, 0);
for (int i = 1; i <= (int)cols.size(); i++) {
const char *value = (const char*)sqlite3_column_text(stmt, i);
values.push_back(value ? value : "(null)");
}
tableRow(cols, values, UPDATE_BUTTON | DELETE_BUTTON, id);
src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
}
sqlite3_finalize(stmt);
if (addButtonP) {
vector<string> dummy;
tableRow(cols, dummy, ADD_BUTTON, "0");
}
}
示例2: imsiSet
void imsiSet(string imsi, string key1, string value1, string key2, string value2)
{
string name = imsi.substr(0,4) == "IMSI" ? imsi : "IMSI" + imsi;
ostringstream os2;
os2 << "update sip_buddies set " << key1 << " = \"" << value1 << "\"," << key2 << " = \"" << value2 << "\" where username = \"" << name << "\"";
if (!sqlite3_command(gSubscriberRegistry.db(), os2.str().c_str())) {
LOG(ERR) << "sqlite3_command problem";
return;
}
}
示例3: getFields
void getFields(vector<string> *fields, vector<bool> *isSet)
{
vector<string> vsc;
split(' ', gVisibleSipColumns, &vsc);
sqlite3_stmt *stmt;
const char *cmd = "pragma table_info(sip_buddies)";
if (sqlite3_prepare_statement(gSubscriberRegistry.db(), &stmt, cmd)) {
LOG(ERR) << "sqlite3_prepare_statement problem - statement: " << cmd;
LOG(ERR) << " " << sqlite3_errmsg(gSubscriberRegistry.db());
return;
}
int src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
while (src == SQLITE_ROW) {
string field = (char*)sqlite3_column_text(stmt, 1);
fields->push_back(field);
isSet->push_back(find(vsc.begin(), vsc.end(), field) != vsc.end());
src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
}
sqlite3_finalize(stmt);
}
示例4: imsiGet
string imsiGet(string imsi, string key)
{
string name = imsi.substr(0,4) == "IMSI" ? imsi : "IMSI" + imsi;
char *value;
if (!sqlite3_single_lookup(gSubscriberRegistry.db(), "sip_buddies", "username", name.c_str(), key.c_str(), value)) {
return "";
}
if (!value) { return ""; }
string retValue = value;
free(value);
return retValue;
}
示例5: generateSqlResponse
// run an sql statement through sqlite3 to get a response
void generateSqlResponse()
{
string stmts = getArg("stmts");
vector<string> vstmts;
split(';', stmts, &vstmts);
vector<string>::iterator it;
for (it = vstmts.begin(); it != vstmts.end(); it++) {
sqlite3_stmt *stmt;
if (sqlite3_prepare_statement(gSubscriberRegistry.db(), &stmt, it->c_str())) {
LOG(ERR) << "sqlite3_prepare_statement problem - statement: " << it->c_str();
return;
}
int src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
while (src == SQLITE_ROW) {
string resp = "res=";
int cols = sqlite3_column_count(stmt);
for (int i = 0; i < cols; i++) {
resp.append((const char*)sqlite3_column_text(stmt, i));
}
gResponse.push_back(resp);
src = sqlite3_run_query(gSubscriberRegistry.db(), stmt);
}
}
}
示例6: doCmd
void doCmd(string cmd)
{
string table;
vector<string> cols;
if (gArgs.find("dial") == gArgs.end()) {
table = "sip_buddies";
split(' ', gVisibleSipColumns, &cols);
} else {
table = "dialdata_table";
split(' ', gVisibleExtColumns, &cols);
}
string id = gArgs["id"];
ostringstream os;
if (cmd == "add") {
string names = join(",", cols);
vector<string> values0;
vector<string>::iterator it;
for (it = cols.begin(); it != cols.end(); it++) {
values0.push_back(nullCheck(gArgs[*it]));
}
string values = join(",", values0);
os << "insert into " << table << " (" << names << ") values (" << values << ")";
} else if (cmd == "delete") {
os << "delete from " << table << " where id = " << id;
} else if (cmd == "update") {
vector<string> sets0;
vector<string>::iterator it;
for (it = cols.begin(); it != cols.end(); it++) {
sets0.push_back(*it + "=" + nullCheck(gArgs[*it]));
}
string sets = join(",", sets0);
os << "update " << table << " set " << sets << " where id = " << id;
} else {
LOG(ERR) << "internal error";
}
LOG(INFO) << os.str();
if (!sqlite3_command(gSubscriberRegistry.db(), os.str().c_str())) {
LOG(ERR) << "sqlite3_command problem - statement: " << os.str();
return;
}
mainTables();
}