本文整理汇总了C++中map_type::is_in_domain方法的典型用法代码示例。如果您正苦于以下问题:C++ map_type::is_in_domain方法的具体用法?C++ map_type::is_in_domain怎么用?C++ map_type::is_in_domain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_type
的用法示例。
在下文中一共展示了map_type::is_in_domain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAndGetParam
int Agent::checkAndGetParam(
string& result,
const map_type& queries,
const string& param,
const int defaultValue,
const int minValue,
bool minError,
const int maxValue
)
{
if (!queries.is_in_domain(param))
{
return defaultValue;
}
if (queries[param].empty())
{
result = printError("QUERY_ERROR", "'" + param + "' cannot be empty.");
return PARAM_ERROR;
}
if (!isNonNegativeInteger(queries[param]))
{
result = printError("QUERY_ERROR",
"'" + param + "' must be a positive integer.");
return PARAM_ERROR;
}
long int value = strtol(queries[param].c_str(), NULL, 10);
if (minValue != NO_VALUE && value < minValue)
{
if (minError)
{
result = printError("QUERY_ERROR",
"'" + param + "' must be greater than " + intToString(minValue) + ".");
return PARAM_ERROR;
}
return minValue;
}
if (maxValue != NO_VALUE && value > maxValue)
{
result = printError("QUERY_ERROR",
"'" + param + "' must be less than " + intToString(maxValue) + ".");
return PARAM_ERROR;
}
return value;
}
示例2: handleCall
/* Agent protected methods */
bool Agent::handleCall(
ostream& out,
const string& path,
string& result,
const map_type& queries,
const string& call,
const string& device
)
{
string deviceName;
if (!device.empty())
{
deviceName = device;
}
else if (queries.is_in_domain("device"))
{
deviceName = queries["device"];
}
if (call == "current")
{
const string path = queries.is_in_domain("path") ? queries["path"] : "";
int freq = checkAndGetParam(result, queries, "frequency", NO_FREQ,
FASTEST_FREQ, false, SLOWEST_FREQ);
if (freq == PARAM_ERROR)
{
return true;
}
return handleStream(out, result, devicesAndPath(path, deviceName), true,
freq);
}
else if (call == "probe" || call.empty())
{
result = handleProbe(deviceName);
return true;
}
else if (call == "sample")
{
string path = queries.is_in_domain("path") ?
queries["path"] : "";
int count = checkAndGetParam(result, queries, "count", DEFAULT_COUNT,
1, true, SLIDING_BUFFER_SIZE);
int freq = checkAndGetParam(result, queries, "frequency", NO_FREQ,
FASTEST_FREQ, false, SLOWEST_FREQ);
int start = checkAndGetParam(result, queries, "start", NO_START);
if (start == NO_START) // If there was no data in queries
{
start = checkAndGetParam(result, queries, "from", 1);
}
if (freq == PARAM_ERROR || count == PARAM_ERROR || start == PARAM_ERROR)
{
return true;
}
return handleStream(out, result, devicesAndPath(path, deviceName), false,
freq, start, count);
}
else if ((mDeviceMap[call] != NULL) && device.empty())
{
result = handleProbe(call);
return true;
}
else
{
result = printError("UNSUPPORTED",
"The following path is invalid: " + path);
return true;
}
}
示例3: on_request
void on_request (
const std::string& path,
std::string& result,
const map_type& queries,
const map_type& cookies,
queue_type& new_cookies,
const map_type& incoming_headers,
map_type& response_headers,
const std::string& foreign_ip,
const std::string& local_ip,
unsigned short foreign_port,
unsigned short local_port
)
{
try
{
ostringstream sout;
// We are going to send back a page that contains an HTML form with two text input fields.
// One field called name. The HTML form uses the post method but could also use the get
// method (just change method='post' to method='get').
if (path == "/form_handler") {
int top_k = 10;
if (queries.is_in_domain("k") && !queries["k"].empty() && atoi(queries["k"].c_str()) > 0) {
top_k = atoi(queries["k"].c_str());
}
int query_mode = 0;
int index = 0;
std::string postfix = "";
std::string feature_string = "";
if (queries.is_in_domain("postfix") && !queries["postfix"].empty()) {
postfix = queries["postfix"].c_str();
}
if (queries.is_in_domain("flickr_id") && !queries["flickr_id"].empty()) {
if (queries.is_in_domain("sample")) {
feature_string = ann_component.query_test_sample_feature_by_id((queries["flickr_id"] + postfix).c_str());
query_mode = 2;
}
else {
index = ann_component.query_feature_point_by_id((queries["flickr_id"] + postfix).c_str());
query_mode = 1;
}
}
else if (queries.is_in_domain("query_id") && !queries["query_id"].empty()) {
index = atoi(queries["query_id"].c_str());
query_mode = 1;
}
if (queries.is_in_domain("feature") && !queries["feature"].empty()) {
feature_string = queries["feature"];
query_mode = 2;
}
std::string ret;
if (query_mode == 1) {
ret = ann_component.query_by_index(top_k, index);
}
else if (query_mode == 2) {
ret = ann_component.query_by_feature_vector(top_k, feature_string);
}
//sout << queries["flickr_id"] << " " << queries["query_id"] << " " << queries["k"] << endl;
//sout << index << " " << top_k << endl;
sout << ret.c_str() << endl;
}
else {
sout << " <html> <body> "
<< "<form action='/form_handler' method='post'> "
<< "Top K: <input name='k' type='text'><br> "
<< "Sample point: <input name='query_id' type='text'>"
<< "Flickr photo id: <input name='flickr_id' type='text'> <input name='postfix' type='hidden' value='.jpg'><br>"
<< "Feature vector string: <input name='feature' type='text'> <input type='submit'> "
<< " </form>" << endl;
sout << "<br> path = " << path << endl;
sout << "<br> foreign_ip = " << foreign_ip << endl;
sout << "<br> foreign_port = " << foreign_port << endl;
sout << "<br> local_ip = " << local_ip << endl;
sout << "<br> local_port = " << local_port << endl;
sout << "</body> </html>";
}
/*
if (path == "/form_handler")
{
sout << "<h2> Stuff from the query string </h2>" << endl;
sout << "<br> user = " << queries["user"] << endl;
sout << "<br> pass = " << queries["pass"] << endl;
*/
//.........这里部分代码省略.........