本文整理汇总了C++中json::value::Members::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Members::size方法的具体用法?C++ Members::size怎么用?C++ Members::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::value::Members
的用法示例。
在下文中一共展示了Members::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_card_right_json
int CCardFieldDlg::load_card_right_json()
{
int i,idx;
Json::Value root;
Json::Reader reader;
std::ifstream input;
//input.open("e:\\works\\cardlib\\ykt.v3_1.dev\\bin\\lcsmanager\\cardright.json");
input.open((LPCTSTR)m_jsonfile);
if(input.is_open()==false)
{
AfxMessageBox("´ò¿ªÅäÖÃÎļþ´íÎó");
return -1;
}
if(reader.parse(input,root)==false)
{
std::string msg = "¶ÁÈ¡ÅäÖÃÎļþ´íÎó : " + reader.getFormatedErrorMessages();
AfxMessageBox(msg.c_str());
return -1;
}
std::string encoding = root.get("encoding","GBK").asString();
Json::Value fields = root["cardfield"];
Json::Value::Members fldid = fields.getMemberNames();
m_cardfield.clear();
for(i = 0;i < fldid.size();++i)
{
idx = atoi(fldid[i].c_str());
std::string v = fields.get(fldid[i],"Unknown").asString();
m_cardfield.insert(CARD_FILED_MAP::value_type(idx,v));
}
if(fldid.size() > m_string_len)
m_string_len = fldid.size();
// std::sort(m_cardfield.begin(),m_cardfield.end());
init_check_box();
return 0;
}
示例2: init
//virtual
bool AnimationLogic::init( const JsonValueRef json )
{
m_states.clear();
if( !json.isMember("states") || !json.isMember("events") ) return false;
for( int i=0; i< json["events"].size(); i++)
{
m_events.push_back( json["events"][i].asString() );
}
m_defaultState = json.get("default", "idle").asString();
Json::Value::Members states = json["states"].getMemberNames();
for(int i=0; i< states.size(); i++)
{
JsonValueRef stateObj = json["states"][states[i]];
Json::Value::Members events = stateObj.getMemberNames();
AnimState animState;
animState.name = states[i];
CCLOG(" animState: %s", animState.name.c_str() );
for( int j=0; j< events.size(); j++)
{
std::string newState = stateObj[ events[j] ].asString();
animState.transitionTable[ events[j] ] = newState;
CCLOG(" %s => %s", events[j].c_str(), newState.c_str() );
}
m_states[ states[i] ] = animState;
}
return true;
}
示例3: load
//Load skin
bool Skin::load(const std::string& filename) {
std::ifstream ifs(filename);
std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
Json::Value root;
Json::Reader reader;
m_classes.clear();
if (!reader.parse(str, root)) {
return false;
}
Json::Value::Members classes = root.getMemberNames();
for (uint32 i = 0; i < classes.size(); i++) {
std::string name = classes[i];
Json::Value v = root[name];
Skin::SkinClass sc;
bool addP = false;
//We need to figure out if we're dealing with sub classes.
Json::Value::Members subs = v.getMemberNames();
for (uint32 j = 0; j < subs.size(); j++) {
if (subs[j] != "normal" && subs[j] != "hover" && subs[j] != "active" && subs[j] != "focus") {
//Yup, this is a sub class.
Skin::SkinClass sub;
jsonToStates(v[subs[j]], sub);
sc.m_subs.insert(ClassMapPair(subs[j], sub));
} else {
addP = true;
}
}
//There's a valid state in the root
if (addP) {
jsonToStates(v, sc);
}
sc.reset();
m_classes.insert(ClassMapPair(name, sc));
}
m_loaded = filename;
return true;
}
示例4: SetupRegisteredUsers
void Configuration::SetupRegisteredUsers(MongooseServer& httpServer)
{
boost::mutex::scoped_lock lock(globalMutex_);
httpServer.ClearUsers();
if (!configuration_.isMember("RegisteredUsers"))
{
return;
}
const Json::Value& users = configuration_["RegisteredUsers"];
if (users.type() != Json::objectValue)
{
LOG(ERROR) << "Badly formatted list of users";
throw OrthancException(ErrorCode_BadFileFormat);
}
Json::Value::Members usernames = users.getMemberNames();
for (size_t i = 0; i < usernames.size(); i++)
{
const std::string& username = usernames[i];
std::string password = users[username].asString();
httpServer.RegisterUser(username.c_str(), password.c_str());
}
}
示例5: RegisterUserContentType
static void RegisterUserContentType()
{
if (configuration_.isMember("UserContentType"))
{
const Json::Value& parameter = configuration_["UserContentType"];
Json::Value::Members members = parameter.getMemberNames();
for (size_t i = 0; i < members.size(); i++)
{
std::string info = "\"" + members[i] + "\" = " + parameter[members[i]].toStyledString();
LOG(INFO) << "Registering user-defined attachment type: " << info;
if (!parameter[members[i]].asBool())
{
LOG(ERROR) << "Not a number in this user-defined attachment type: " << info;
throw OrthancException(ErrorCode_BadParameterType);
}
int contentType = parameter[members[i]].asInt();
try
{
RegisterUserContentType(contentType, members[i]);
}
catch (OrthancException&)
{
LOG(ERROR) << "Cannot register this user-defined attachment type: " << info;
throw;
}
}
}
}
示例6: buildTasks
void QueryParser::buildTasks(
const Json::Value &query,
std::vector<std::shared_ptr<Task> > &tasks,
task_map_t &task_map) const {
Json::Value::Members members = query["operators"].getMemberNames();
std::string papiEventName = getPapiEventName(query);
for (unsigned i = 0; i < members.size(); ++i) {
Json::Value planOperationSpec = query["operators"][members[i]];
std::string typeName = planOperationSpec["type"].asString();
std::shared_ptr<PlanOperation> planOperation = QueryParser::instance().parse(
typeName, planOperationSpec);
planOperation->setEvent(papiEventName);
setInputs(planOperation, planOperationSpec);
if (auto para = std::dynamic_pointer_cast<ParallelizablePlanOperation>(planOperation)) {
para->setPart(planOperationSpec["part"].asUInt());
para->setCount(planOperationSpec["count"].asUInt());
} else {
if (planOperationSpec.isMember("part") || planOperationSpec.isMember("count")) {
throw std::runtime_error("Trying to parallelize " + typeName + ", which is not a subclass of Parallelizable");
}
}
planOperation->setOperatorId(members[i]);
if (planOperationSpec.isMember("core"))
planOperation->setPreferredCore(planOperationSpec["core"].asInt());
// check for materialization strategy
if (planOperationSpec.isMember("positions"))
planOperation->setProducesPositions(!planOperationSpec["positions"].asBool());
tasks.push_back(planOperation);
task_map[members[i]] = planOperation;
}
}
示例7: readJson
void readJson() {
using namespace std;
std::string strValue = "{\"name\":\"json\",\"array\":[{\"cpp\":\"jsoncpp\",\"cpp1\":\"jxx\"},{\"java\":\"jsoninjava\"},{\"php\":\"support\"}]}";
Json::Reader reader;
Json::Value value;
if (reader.parse(strValue, value))
{
std::string out = value["name"].asString();
//std::cout << out << std::endl;
const Json::Value arrayObj = value["array"];
for (int i=0; i<arrayObj.size(); i++) {
const Json::Value::Members memberNames = arrayObj[i].getMemberNames();
for(int j=0; j<memberNames.size(); j++) {
std::cout << memberNames[j] << std::endl;
}
}
//for (unsigned int i = 0; i < arrayObj.size(); i++)
//{
//if (!arrayObj[i].isMember("cpp"))
// continue;
//out = arrayObj[i].asString();
//std::cout << out;
//if (i != (arrayObj.size() - 1))
// std::cout << std::endl;
//std::cout << "1111" << std::endl;
//}
}
}
示例8: parseJsonData
bool KsCardMsg::parseJsonData(const std::string& rootname,Json::Value &root)
{
size_t i;
Json::Value::Members mbs = root.getMemberNames();
++parseLevel_;
if(parseLevel_>2)
return false;
for(i = 0;i < mbs.size(); ++i)
{
Json::Value& clt = root[mbs[i]];
std::string fullname = rootname;
if(rootname.length() > 0)
fullname += ".";
fullname += mbs[i];
if(clt.isArray() || clt.isObject())
{
if(!parseJsonData(fullname,clt))
return false;
}
else
{
msg_field_.insert(PARA_MAP_TYPE::value_type(fullname,root.get(mbs[i],"").asString()));
}
}
return true;
}
示例9: jsonParse
int jsonParse(string _s)
{
// Let's parse it
Json::Value root;
Json::Reader reader;
bool parsedSuccess = reader.parse(_s,
root,
false);
if (not parsedSuccess) {
// Report failures and their locations
// in the document.
cout << "Failed to parse JSON" << endl
<< reader.getFormatedErrorMessages()
<< endl;
return 1;
}
Json::Value::Members mem = root.getMemberNames();
Json::Value child = root[mem[0]];
cout << "name: " << mem[0] << ", child: " << child.asString() << endl;
for (int i = 1; i < mem.size(); ++i)
{
child = root[mem[i]];
cout << "name: " << mem[i] << endl;
Json::Value::Members childMem = child.getMemberNames();
cout << "\t" << "type: " << child[childMem[0]].asString() << endl;
cout << "\t" << "value: " << child[childMem[1]].asString() << endl;
cout << "\t" << "typeGen: " << child[childMem[2]].asString() << endl;
}
return 1;
}
示例10: SimplifyTags
void SimplifyTags(Json::Value& target,
const Json::Value& source,
DicomToJsonFormat format)
{
assert(source.isObject());
target = Json::objectValue;
Json::Value::Members members = source.getMemberNames();
for (size_t i = 0; i < members.size(); i++)
{
const Json::Value& v = source[members[i]];
const std::string& type = v["Type"].asString();
std::string name;
switch (format)
{
case DicomToJsonFormat_Human:
name = v["Name"].asString();
break;
case DicomToJsonFormat_Short:
name = members[i];
break;
default:
throw OrthancException(ErrorCode_ParameterOutOfRange);
}
if (type == "String")
{
target[name] = v["Value"].asString();
}
else if (type == "TooLong" ||
type == "Null")
{
target[name] = Json::nullValue;
}
else if (type == "Sequence")
{
const Json::Value& array = v["Value"];
assert(array.isArray());
Json::Value children = Json::arrayValue;
for (Json::Value::ArrayIndex i = 0; i < array.size(); i++)
{
Json::Value c;
SimplifyTags(c, array[i], format);
children.append(c);
}
target[name] = children;
}
else
{
assert(0);
}
}
}
示例11: parseEntity
void LevelsParser::parseEntity(const Json::Value& json, Entity* entity) {
using namespace Json;
Json::Value::Members members = json.getMemberNames();
for (int i = 0; i < members.size(); ++i) {
String member = members[i];
shared_ptr<EntityParser> parser = EntityParser::parser(member);
Json::Value data = json[parser->type().c_str()];
parser->parse(entity, data);
}
}
示例12: readJsonDict
void readJsonDict() {
std::string strValue = "{\"a\":\"1\",\"b\":\"2\",\"c\":\"3\"}";
Json::Reader reader;
Json::Value value;
reader.parse(strValue, value);
std::cout << "value.isObject=" << value.isObject() << std::endl;
const Json::Value::Members memberNames = value.getMemberNames();
for(int i=0; i<memberNames.size(); i++) {
std::cout << memberNames[i] << ":" << value[memberNames[i]] << std::endl;
}
}
示例13: initFromFile
void JsonManager::initFromFile( const std::string& fileName )
{
Json::Value json = ReadFileToJson(fileName);
if( json.isObject() ) {
Json::Value::Members domains = json.getMemberNames();
for(int i=0; i< domains.size(); i++){
m_domains[ domains[i] ] = json[domains[i]];
CCLog("loaded json domain %s", domains[i].c_str() );
}
}
}
示例14: DbgPrintValue
void DbgPrintValue( const Json::Value& value )
{
const Json::Value::Members valueMembers = value.getMemberNames();
const UINT numMembers = valueMembers.size();
for( UINT i = 0; i < numMembers; i++ )
{
const Json::Value& member = valueMembers[i];
const std::string s = member.toStyledString();
DBGOUT( "\t%s\n", s.c_str() );
//DBGOUT( "\t%s\n", member.c_str() );
}
}
示例15: applyParallelizationTo
Json::Value& QueryTransformationEngine::transform(Json::Value& query) {
Json::Value::Members operatorIds = query["operators"].getMemberNames();
Json::Value operatorConfiguration;
for (size_t i = 0; i < operatorIds.size(); ++i) {
operatorConfiguration = query["operators"][operatorIds[i]];
// check whether operator should be transformed; postpone transformation if dynamic transformation is required
if (operatorConfiguration["dynamic"].asBool() == false &&
_factory.count(operatorConfiguration["type"].asString()) > 0)
_factory[operatorConfiguration["type"].asString()]->transform(operatorConfiguration, operatorIds[i], query);
// check whether operator needs to be parallelized
if (requestsParallelization(operatorConfiguration))
applyParallelizationTo(operatorConfiguration, operatorIds[i], query);
}
// std::cout << query.toStyledString()<< std::endl;
return query;
}