当前位置: 首页>>代码示例>>C++>>正文


C++ JSONNode::set_name方法代码示例

本文整理汇总了C++中JSONNode::set_name方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONNode::set_name方法的具体用法?C++ JSONNode::set_name怎么用?C++ JSONNode::set_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSONNode的用法示例。


在下文中一共展示了JSONNode::set_name方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toJSON

JSONNode Programmer::toJSON() {
  JSONNode root;
  root.set_name("programmer");

  JSONNode devices;
  devices.set_name("devices");

  for (const auto& kvp : m_devices) {
    devices.push_back(kvp.second->toJSON());
  }

  root.push_back(devices);

  root.push_back(captured.toJSON("captured"));

  return root;
}
开发者ID:ebshimizu,项目名称:Lumiverse,代码行数:17,代码来源:Programmer.cpp

示例2: toJSON

JSONNode Event::toJSON() {
  // this is equivalent to saying "something happened here but I have no idea what it is"
  JSONNode e;
  e.set_name(_id);
  e.push_back(JSONNode("type", getType()));

  return e;
}
开发者ID:ebshimizu,项目名称:Lumiverse,代码行数:8,代码来源:Keyframe.cpp

示例3: main

int main(){
JSONNode n = read_formatted("input.json");
JSONNode n1 = read_formatted("input1.json");
test *tst = new test();
int status;
//n.set_name(abi::__cxa_demangle(typeid(*tst).name(), 0,0,&status ));
n.push_back(JSONNode("FF::Node_Subclass", abi::__cxa_demangle(typeid(*tst).name(), 0,0,&status )));
if(n1.type()==JSON_NULL){
   std::cout<<"null"<<std::endl; 
}
JSONNode n2 (JSON_NODE);
n2.set_name("Child1");
n2.push_back(JSONNode("id",1));
n.set_name("Parrent");
n.push_back(n2);
JSONNode::iterator it =n.find_nocase("String Node");
if(it->as_string()=="-1"){std::cout<<it->as_int()<<std::endl;}
it->as_int()!=-1 ? (std::cout<< "it is"<<std::endl) : (std::cout<<"Mapper Warning: processor id is -1"<<std::endl);
if (n.at("String Node")==""){
std::cout<<"ha ha ha"<<std::endl;
}
std::cout<< "This is the name: "<<n.name()<<std::endl;
n.at("String Node")="";
bool x =true;
n.push_back(JSONNode("MyBOOLNODE", x));
n["String Node"]=x;
//n.erase(n.find_nocase("String Node"));
write_formatted(n1, "out1.json");
write_formatted(n, "out.json");
JSONNode::const_iterator i =n.find_nocase("ArrayOfNumbers");
std::string strLowerCase= "ARRAYOfNUMbers"; 
std::string myTest= "ff::ff_farm<adaptive_loadbalancer, ff::ff_gatherer>";
std::transform(myTest.begin(), myTest.end(), myTest.begin(), ::tolower);
std::size_t found = myTest.find("adaptive_loadbalancer");
if (found!=std::string::npos)
  std::cout << "first 'needle' found at: " << found << '\n';

std::cout<< "here it is: " << myTest<< std::endl;
JSONNode n_ar = n.at("ArrayOfNumbers");
std::cout<<"here :"<<n_ar[0].as_int()<< std::endl;
// if (0 == strcasecmp("hello", "HELLO"))

if(strcasecmp((i->name()).c_str(), strLowerCase.c_str()) == 0)
//if(!(n2.empty()))
  std::cout<<"haha"<<i->size()<<std::endl;
std::cout<<i->name()<<std::endl;
std::cout<<((i->as_array()).begin()+1)->as_int()<<std::endl;
std::cout<<((i->as_array()).at(1)).as_int()<<std::endl;
std::cout<<((i->as_array())[1]).as_int()<<std::endl;
//std::cout<<i->as_string()<<std::endl;
//JSONNode c(JSON_ARRAY);
//c=i->as_array();
//JSONNode nk= c.at(0);
//JSONNode::const_iterator it = c.begin();
//std::cout <<nk.as_int()<<std::endl;
return 0;
}
开发者ID:mehdi-goli,项目名称:MC-FastFlow-PEI,代码行数:57,代码来源:test_parser.cpp

示例4: stringType

 JSONNode JSONNode::stringType(const json_string & str){
     JSONNode res;
     res.set_name(json_global(EMPTY_JSON_STRING));
     #ifdef JSON_LESS_MEMORY
         res = JSONWorker::FixString(str, res.internal, false);
     #else
         res = JSONWorker::FixString(str, res.internal -> _string_encoded);
     #endif
     return res;
 }
开发者ID:CISMM,项目名称:ITKPlugins,代码行数:10,代码来源:JSONNode.cpp

示例5: AppendDBEvent

MEVENT CSkypeProto::AppendDBEvent(MCONTACT hContact, MEVENT hEvent, const char *szContent, const char *szUid, time_t edit_time)
{
	mir_cslock lck(m_AppendMessageLock);
	DBEVENTINFO dbei = { sizeof(dbei) };
	dbei.cbBlob = db_event_getBlobSize(hEvent);
	dbei.pBlob = mir_ptr<BYTE>((PBYTE)mir_alloc(dbei.cbBlob));
	db_event_get(hEvent, &dbei);

	JSONNode jMsg = JSONNode::parse((char*)dbei.pBlob);
	if (jMsg)
	{
		JSONNode &jEdits = jMsg["edits"];
		if (jEdits)
		{
			for (auto it = jEdits.begin(); it != jEdits.end(); ++it)
			{
				const JSONNode &jEdit = *it;

				if (jEdit["time"].as_int() == edit_time)
					return hEvent;
			}
			JSONNode jEdit;
			jEdit 
				<< JSONNode("time", (long)edit_time)
				<< JSONNode("text", szContent);

			jEdits << jEdit;
		}
	}
	else
	{
		jMsg = JSONNode();
		JSONNode jOriginalMsg; jOriginalMsg.set_name("original_message");
		JSONNode jEdits(JSON_ARRAY); jEdits.set_name("edits");
		JSONNode jEdit;

		jOriginalMsg
			<< JSONNode("time", (long)dbei.timestamp)
			<< JSONNode("text", (char*)dbei.pBlob);

		jMsg << jOriginalMsg;

		jEdit 
			<< JSONNode("time", (long)edit_time)
			<< JSONNode("text", szContent);

		jEdits << jEdit;	
		jMsg   << jEdits;


	}
	db_event_delete(hContact, hEvent);	
	return AddDbEvent(SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE, hContact, dbei.timestamp, DBEF_UTF, jMsg.write().c_str(), szUid);
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:54,代码来源:skype_db.cpp

示例6: toJSON

JSONNode LumiverseFloat::toJSON(string name) {
  JSONNode node;
  node.set_name(name);

  node.push_back(JSONNode("type", getTypeName()));
  node.push_back(JSONNode("val", m_val));
  node.push_back(JSONNode("default", m_default));
  node.push_back(JSONNode("max", m_max));
  node.push_back(JSONNode("min", m_min));

  return node;
}
开发者ID:Chelsea21,项目名称:Lumiverse,代码行数:12,代码来源:LumiverseFloat.cpp

示例7: onClientAttach

void StreamingDevice::onClientAttach(ClientConn* client){
	Device::onClientAttach(client);
	
	JSONNode n(JSON_NODE);
	n.push_back(JSONNode("_action", "deviceConfig"));

	JSONNode jstate = stateToJSON();
	jstate.set_name("device");
	n.push_back(jstate);
	
	client->sendJSON(n);
}
开发者ID:nonolith,项目名称:connect,代码行数:12,代码来源:ws_api.cpp

示例8: json__newindex

static int json__newindex(lua_State *L)
{
	JSONNode &node = *((JSON*)luaL_checkudata(L, 1, MT_JSON))->node;
	const char *key = lua_tostring(L, 2);

	JSONNode child = node[key];
	if (child.isnull())
	{
		child.set_name(key);
		node << child;
	}
	lua2json(L, child);
	node[key] = child;

	return 0;
}
开发者ID:ybznek,项目名称:miranda-ng,代码行数:16,代码来源:metatable.cpp

示例9: columns

JSONNode *Database::CreateTable(const string &name, const vector<string> &columnNames)
{
	if (this->FindTable(name))
		return NULL;
	JSONNode table;
	table.set_name(name);
	JSONNode columns(JSON_ARRAY);
	columns.set_name("columns");
	for (auto i = columnNames.begin(); i != columnNames.end(); i++)
		columns.push_back(JSONNode("", *i));
	table.push_back(columns);
	JSONNode rows(JSON_ARRAY);
	rows.set_name("rows");
	table.push_back(rows);
	auto tables = data.find("tables");
	tables->push_back(table);
	//cout << tables->write_formatted() << endl;
	//cout << data.write_formatted() << endl;
	auto t = tables->find(name);
	return t == tables->end() ? NULL : &*t;
}
开发者ID:HackerDom,项目名称:ructf-2013-final,代码行数:21,代码来源:Database.cpp

示例10: lua2json

void lua2json(lua_State *L, JSONNode &node)
{
	const char *name = lua_tostring(L, -2);

	switch (lua_type(L, -1))
	{
	case LUA_TNIL:
		node.nullify();
		break;
	case LUA_TSTRING:
		node = lua_tostring(L, -1);
		break;
	case LUA_TBOOLEAN:
		node = lua_toboolean(L, -1) != 0;
		break;
	case LUA_TNUMBER:
		node = lua_tonumber(L, -1);
		break;
	case LUA_TTABLE:
	{
		node.cast(JSON_NODE);
		if (name)
			node.set_name(name);

		lua_pushnil(L);
		while (lua_next(L, -2) != 0)
		{
			JSONNode child;
			lua2json(L, child);
			node << child;

			lua_pop(L, 1);
		}
	}
	}
}
开发者ID:ybznek,项目名称:miranda-ng,代码行数:36,代码来源:metatable.cpp

示例11: setData

void JSONResult::setData(JSONNode & data){
  data.set_name("data");
  this->push_back(data);
}
开发者ID:psychobob666,项目名称:MediaEncodingCluster,代码行数:4,代码来源:JSONResult.cpp

示例12: LOGDEBUG

      PresetReaderJson::PresetReaderJson(std::string data) {
        LOGDEBUG("Preset Data:" << data);
        JSONNode node = libjson::parse(data);
        if(node.contains("profile-uuid")){
          db::HiveDb db=DatabaseService::getDatabase();//"sqlite3", org::esb::config::Config::get("db.url"));
          litesql::DataSource<db::Preset>s = litesql::select<db::Preset > (db, db::Preset::Uuid == node["profile-uuid"].as_string());
          if(s.count()==1){
            data=s.one().data;
          }else{
            throw org::esb::lang::Exception(__FILE__,__LINE__,"profile defined by profile-uuid not found");
          }
          node = libjson::parse(data);
        }
        if (node.contains("format") && node["format"].contains("id")) {
          _preset["id"] = node["format"]["id"].as_string();
          if(node.contains("name")){
            _preset["name"]=node["name"].as_string();
          }
        }else{
          throw org::esb::lang::Exception(__FILE__,__LINE__,"no format attribute found");
        }
        std::string type;
        type = "video";
        if (node.contains(type)) {
          int c = node[type].size();
          for (int a = 0; a < c; a++) {
            JSONNode n = node[type].at(a);
            std::string name = n.name();
            std::string value = n.as_string();
            /*filter out some unwanted attributes*/
            if (name == "frame_size"){
              int width;
              int height;
              int result=sscanf(value.c_str(),"%dx%d", &width, &height);
              LOGDEBUG("width="<<width);
              LOGDEBUG("width="<<height);
              _codecs[type]["width"]=StringUtil::toString(width);
              _codecs[type]["height"]=StringUtil::toString(height);
              continue;
            }
            //LOGDEBUG("json type : "<<n.type());
            if (name == "id") {
              name = "codec_id";
            }
            if (name == "b" || name == "maxrate" || name == "bt" || name == "bufsize" || name == "minrate")
              value += "000";
            LOGDEBUG("Name=" << name << " val=" << value);

            _codecs[type][name] = value; //.insert(std::pair<std::string, std::string>(name,value));
          }
        }else{
          throw org::esb::lang::Exception(__FILE__,__LINE__,"no video attribute found");
        }
        type = "audio";
        if (node.contains(type)) {
          int c = node[type].size();
          for (int a = 0; a < c; a++) {
            JSONNode n = node[type].at(a);
            LOGDEBUG("Name=" << n.name() << " val=" << n.as_string());
            if (n.name() == "id") {
              n.set_name("codec_id");
              //AVCodec * codec=avcodec_find_encoder_by_name(n.as_string().c_str());
              //n=JSONNode("codec_id",codec->id);
            }
            _codecs[type][n.name()] = n.as_string(); //.insert(std::pair<std::string, std::string>(n.name(),n.as_string()));
          }
        }else{
          throw org::esb::lang::Exception(__FILE__,__LINE__,"no audio attribute found");
        }
      }
开发者ID:psychobob666,项目名称:MediaEncodingCluster,代码行数:70,代码来源:PresetReaderJson.cpp


注:本文中的JSONNode::set_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。