本文整理汇总了C++中JsonArray::CountItem方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::CountItem方法的具体用法?C++ JsonArray::CountItem怎么用?C++ JsonArray::CountItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::CountItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveMarks
void RecordingsResponder::saveMarks(ostream& out, cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
QueryHandler q("/recordings/marks", request);
int recording = q.getParamAsInt(0);
JsonArray* jsonArray = q.getBodyAsArray("marks");
if (jsonArray == NULL) {
reply.httpReturn(503, "Marks in HTTP-Body are missing.");
}
if (recording < 0 && recording >= Recordings.Count()) {
reply.httpReturn(504, "Recording number missing or invalid.");
}
vector< string > marks;
for(int i=0;i<jsonArray->CountItem();i++) {
JsonBase* jsonBase = jsonArray->GetItem(i);
if (jsonBase->IsBasicValue()) {
JsonBasicValue* jsonBasicValue = (JsonBasicValue*)jsonBase;
if (jsonBasicValue->IsString()) {
marks.push_back(jsonBasicValue->ValueAsString());
}
}
}
VdrMarks::get()->saveMarks(Recordings.Get(recording), marks);
}
示例2: hitKey
bool KeyPairList::hitKey(cxxtools::http::Request& request, cxxtools::http::Reply& reply)
{
if ( (int)request.url().find("/remote/kbd") != -1) {
QueryHandler q("/remote/kbd", request);
cxxtools::String kbd = StringExtension::UTF8Decode(q.getBodyAsString("kbd"));
if ( kbd == StringExtension::UTF8Decode("") ) {
reply.httpReturn(400, "Key is empty.");
}
std::size_t n = 0;
while (kbd[n]) {
cRemote::Put(KBDKEY(kbd[n]));
++n;
}
return true;
} else if ( (int)request.url().find("/remote/seq") != -1) {
QueryHandler q("/remote/seq", request);
JsonArray* seq = q.getBodyAsArray("seq");
if ( seq == NULL ) {
reply.httpReturn(400, "Sequence is empty.");
return false;
}
for (int i = 0; i < seq->CountItem(); i++) {
JsonBase* jsonBase = seq->GetItem(i);
if (jsonBase->IsBasicValue()) {
JsonBasicValue* jsonBasicValue = (JsonBasicValue*)jsonBase;
if (jsonBasicValue->IsString()) {
string key = jsonBasicValue->ValueAsString();
for (int n=0;n<(int)key.length();n++ ) {
key[n] = tolower(key[n]);
}
for (int x=0;x<(int)keys.size();x++) {
if (string(keys[x].str) == key) {
cRemote::Put(keys[x].key);
}
}
}
}
}
return true;
} else {
QueryHandler q("/remote", request);
string key = q.getParamAsString(0);
if (key.length() == 0) {
reply.httpReturn(404, "Please add a key to the parameter list, see API-file for more details.");
return false;
}
for (int i=0;i<(int)key.length();i++) {
key[i] = tolower(key[i]);
}
for (int i=0;i<(int)keys.size();i++)
{
if (string(keys[i].str) == key) {
cRemote::Put(keys[i].key);
return true;
}
}
}
return false;
}