本文整理汇总了C++中Http::get_i方法的典型用法代码示例。如果您正苦于以下问题:C++ Http::get_i方法的具体用法?C++ Http::get_i怎么用?C++ Http::get_i使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::get_i方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
int exec() {
int n = res.get_i("queries=");
if(n<1) n = 1;
if(n>500) n = 500;
vw array;
while(n--) {
id = rand()%10000;
newNumber = rand()%10000+1;
// reset statement for reuse
if(mysql_stmt_reset(stmt)) throw runtime_error(mysql_stmt_error(stmt));
if(mysql_stmt_reset(ustmt)) throw runtime_error(mysql_stmt_error(ustmt));
// create and use input parameter
memset(param, 0, sizeof(param));
param[0].buffer_type = MYSQL_TYPE_LONG;
param[0].buffer = (char *)&id;
param[0].buffer_length = sizeof(id);
param[0].is_null = 0;
param[0].length = NULL;
if(mysql_stmt_bind_param(stmt,param)) throw runtime_error(mysql_stmt_error(stmt));
// create and fill result buffer
memset(results, 0, sizeof(results));
results[0].buffer_type= MYSQL_TYPE_LONG;
results[0].buffer = &randomNumber;
results[0].buffer_length = sizeof(randomNumber);
results[0].is_null = 0;
results[0].length = &len1;
if(mysql_stmt_bind_result(stmt, results)) throw runtime_error(mysql_stmt_error(stmt));
// create and use update parameter
memset(param_update, 0, sizeof(param_update));
param_update[0].buffer_type = MYSQL_TYPE_LONG;
param_update[0].buffer = (char *)&newNumber;
param_update[0].buffer_length = sizeof(newNumber);
param_update[0].is_null = 0;
param_update[0].length = 0;
param_update[1].buffer_type = MYSQL_TYPE_LONG;
param_update[1].buffer = (char *)&id;
param_update[1].buffer_length = sizeof(id);
param_update[1].is_null = 0;
param_update[1].length = 0;
// execute statement
if(mysql_stmt_execute(stmt)) throw runtime_error(mysql_stmt_error(stmt));
if(mysql_stmt_bind_param(ustmt,param_update)) throw runtime_error(mysql_stmt_error(ustmt));
if(mysql_stmt_fetch(stmt)) randomNumber = 0;
// add to array (required by specification)
array.push_back(World(id,newNumber));
}
// output json
res << '[';
for(unsigned z=0;z<array.size();++z) {
if(z>0) res << ',';
World &az = array[z];
JsonObj obj;
obj.add("id",az.id);
obj.add("randomNumber",az.randomNumber);
res << obj.to_s();
}
res << ']';
return res.end();
}