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


C++ Value::asCString方法代码示例

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


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

示例1: LoadSceneSettings

//-----------------------------------------------------------------------------------
void EngineConfig::LoadSceneSettings(Json::Value root, Json::Reader reader)
{
	Json::Value settings = root["scenes"];
	int componentCount = settings.size();

	for( int i=0; i< componentCount; ++i )
	{
		Json::Value componentVal = settings[i];
		Json::Value::Members members = componentVal.getMemberNames();

		map<std::string, std::string> mapValues;
		for( Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it)
		{
			std::string memberName = *it;
			std::string value = componentVal[memberName].asString();
			
			mapValues[memberName] = value;

		}

		std::string sceneName = mapValues["name"];
		std::string fileName = mapValues["file"];

		SceneData *sceneData = new SceneData( sceneName, fileName );

		scenes[sceneName] = sceneData;
	}

	settings = root["startscene"];
	startScene = scenes[settings.asCString()];
}
开发者ID:bfogerty,项目名称:xdpixelengine,代码行数:32,代码来源:EngineConfig.cpp

示例2: GetVal

void GetVal(Json::Value &config, char** setting)
{
	if (config.isNull())
		return;

	*setting = strdup(config.asCString());
}
开发者ID:oSleepY,项目名称:AimTux,代码行数:7,代码来源:settings.cpp

示例3: addAllPackageCrossRefs

//////////////////////////////////////////////////////////////////////////
// addAllPackageCrossRefs
void CsPackageImporter::addAllPackageCrossRefs( Json::Value& Root )
{
	std::lock_guard< std::recursive_mutex > Lock( BuildingLock_ );
	BcAssert( BuildingBeginCount_ > 0 );

	// If it's a string value, attempt to match it.
	if( Root.type() == Json::stringValue )
	{
		std::cmatch Match;
		std::regex_match( Root.asCString(), Match, GRegex_ResourceReference );
		
		// Try the weak match.
		// TODO: Merge into  regex.
		if( Match.size() == 0 )
		{
			std::regex_match( Root.asCString(), Match, GRegex_WeakResourceReference );
		}

		if( Match.size() == 4 )
		{
			BcU32 RefIndex = addPackageCrossRef( Root.asCString() );

			// If we find it, replace string reference with a cross ref index.
			if( RefIndex != BcErrorCode )
			{
				PSY_LOG("Adding crossref %u: %s\n", RefIndex, Root.asCString() );
				Root = Json::Value( RefIndex );
			}
		}
	}
	else if( Root.type() == Json::arrayValue )
	{
		for( BcU32 Idx = 0; Idx < Root.size(); ++Idx )
		{
			addAllPackageCrossRefs( Root[ Idx ] );
		}
	}
	else if( Root.type() == Json::objectValue )
	{
		Json::Value::Members MemberValues = Root.getMemberNames();

		for( BcU32 Idx = 0; Idx < MemberValues.size(); ++Idx )
		{
			addAllPackageCrossRefs( Root[ MemberValues[ Idx ] ] );
		}
	}
}
开发者ID:Psybrus,项目名称:Psybrus,代码行数:49,代码来源:CsPackageImporter.cpp

示例4: parseFromJsonToDictionary

/// 从 Json 解析数据到 dictNode 中
static void parseFromJsonToDictionary(const Json::Value & jsonNode, CCDictionary * dictNode)
{
	Json::Value::Members members = jsonNode.getMemberNames();
	for (Json::Value::Members::iterator beg = members.begin(); beg != members.end(); ++beg)
	{
        std::string name = *beg;
		Json::Value child = jsonNode[name];
		
		if (child.isArray())
		{
			CCArray * arr = CCArray::create();
			parseFromJsonToArray(child, arr);
			dictNode->setObject(arr, name);
		}
		else if (child.isObject())
		{
			CCDictionary * dict = CCDictionary::create();
			parseFromJsonToDictionary(child, dict);
			dictNode->setObject(dict, name);
		}
		else if (child.isString())
		{
			CCString * str = CCString::createWithFormat("%s", child.asCString());
			dictNode->setObject(str, name);
		}
		else if (child.isInt())
		{
			CCString * str = CCString::createWithFormat("%d", child.asInt());
			dictNode->setObject(str, name);
		}
		else if (child.isUInt())
		{
			CCString * str = CCString::createWithFormat("%u", child.asUInt());
			dictNode->setObject(str, name);
		}
		else if (child.isInt64())
		{
			CCString * str = CCString::createWithFormat("%lld", child.asInt64());
			dictNode->setObject(str, name);
			
		}
		else if (child.isUInt64())
		{
			CCString * str = CCString::createWithFormat("%llu", child.asUInt64());
			dictNode->setObject(str, name);
		}
		else if (child.isDouble())
		{
			CCString * str = CCString::createWithFormat("%f", child.asDouble());
			dictNode->setObject(str, name);
		}
		else if (child.isBool())
		{
			CCString * str = CCString::createWithFormat("%d", child.asInt());
			dictNode->setObject(str, name);
		}
	}
}
开发者ID:JackKa325,项目名称:cocos2d-x-tools,代码行数:59,代码来源:YHJsonHelper.cpp

示例5: LCDCore

// Constructor
DrvSDL::DrvSDL(std::string name, LCDControl *v,
    Json::Value *config, int layers) :
    LCDCore(v, name, config, LCD_GRAPHIC, (LCDGraphic *)this),
    LCDGraphic((LCDCore *)this), drvFB(0) {

    GraphicRealBlit = DrvSDLBlit;

    Json::Value *val = CFG_Fetch(config, name + ".cols", new Json::Value(SCREEN_W));
    cols_ = val->asInt();
    delete val;

    val = CFG_Fetch(config, name + ".rows", new Json::Value(SCREEN_H));
    rows_ = val->asInt();
    delete val;

    val = CFG_Fetch(config, name + ".update", new Json::Value(150));
    update_ = val->asInt();
    delete val;

    val = CFG_Fetch(config, name + ".fill", new Json::Value(0));
    fill_ = val->asInt();
    delete val;

    val = CFG_Fetch_Raw(config, name + ".pixels", new Json::Value("1x1"));
    sscanf(val->asCString(), "%dx%d", &pixels.x, &pixels.y);
    delete val;

    GraphicInit(rows_, cols_, 8, 7, layers);

    if(!(drvFB = (RGBA *)malloc(rows_ * pixels.y * cols_ * pixels.x * sizeof(RGBA))))
	LCDError("Could not allocate frame buffer for DrvSDL");

    wrapper_ = new SDLWrapper((SDLInterface *)this);

    update_thread_ = new SDLUpdateThread(this);

    //gif_thread_ = new SDLGifThread(this);

    if(SDL_Init(SDL_INIT_VIDEO) != 0) {
        LCDError("DrvSDL: Unable to init SDL: %s", SDL_GetError());
    }

    surface_ = SDL_SetVideoMode(cols_ * pixels.x, rows_ * pixels.y, 32, 
        SDL_RESIZABLE);

    SDL_WM_SetCaption("LCDControl", "LCDControl");

    if( surface_ == NULL) {
        LCDError("DrvSDL: Unable to set %dx%d video: %s", cols_, rows_, SDL_GetError());
    }

/*
    sdl_timer_.setInterval(update_);
    QObject::connect(&sdl_timer_, SIGNAL(timeout()),
        wrapper_, SLOT(DrvUpdateSDL()));
*/
}
开发者ID:Chelovecheggg,项目名称:libvisual,代码行数:58,代码来源:DrvSDL.cpp

示例6: Deserialize_Enum

	void Deserialize_Enum(
		const Json::Value& srcValue,
		const mxEnumType& enumInfo,
		void *rawMem	
		)
	{
		const UINT newValue = enumInfo.GetItemIndexByString( srcValue.asCString() );

		enumInfo.m_accessor.Set_Value( rawMem, newValue );
	}
开发者ID:S-V,项目名称:Lollipop,代码行数:10,代码来源:JsonSerializationCommon.cpp

示例7: GetJsonInt

int GetJsonInt(const Json::Value& _jsValue)
{
	if ( _jsValue.type() == Json::intValue)
		return _jsValue.asInt();
	else if (_jsValue.type() == Json::stringValue)
		return atoi(_jsValue.asCString());
	else if (_jsValue.isBool())
		return (int)_jsValue.asBool();
	return 0;
}
开发者ID:zjjfhqpl,项目名称:SDLib,代码行数:10,代码来源:CJsonParse.cpp

示例8: ReadTags

void MusicConfigLoader::ReadTags(Json::Value& node, std::set<CString>& setTags)
{
   ATLASSERT(node.isArray());

   // enumerate array member
   for (Json::Value::UInt index = 0, max = node.size(); index < max; index++)
   {
      Json::Value valItem = node[index];
      setTags.insert(CString(valItem.asCString()));
   }
}
开发者ID:vividos,项目名称:MultiplayerOnlineGame,代码行数:11,代码来源:MusicConfigLoader.cpp

示例9: testGetString

void EepromMapPrivateTestCase::testGetString(void)
{
  EepromMapPrivate* eepromMap = this->createEepromMap();
  Json::Value nameValues = eepromMap->getEepromMap()["eeprom_map"]["MACHINE_NAME"]["value"];
  Json::Value expectedValue = nameValues[0];
  QString expectedName = QString(expectedValue.asCString()); 
  QString path = QString("MACHINE_NAME");
  std::vector<QString> * gotValues = eepromMap->getString(path);
  QString gotName = (*gotValues)[0];
  CPPUNIT_ASSERT(expectedName == gotName);
}
开发者ID:Jnesselr,项目名称:conveyor,代码行数:11,代码来源:EepromMapPrivateTestCase.cpp

示例10: parseShopBuyInfoFromServer

bool ShopItemInfoFromServer::parseShopBuyInfoFromServer()
{
    m_mapBuyShopInfo.clear();
    const char* pMessage = m_strShopBuyList.c_str();

    CCLOG("download step m_strShopBuyList %s",pMessage);
    if (pMessage == NULL || pMessage == "" || pMessage == "error")
    {
        return false;
    }

    Json::Value jsonValue;
    if (!parseJsonStr(pMessage, jsonValue)) 
    {
        CCLOGERROR("UpdateInfoFromServer Error: %s",pMessage);
        return false;
    }

    bool isArray = jsonValue.isArray();
    if (isArray)
    {
        unsigned int arraySize = jsonValue.size();
        for (int i = 0; i < arraySize; i++)
        {
            const Json::Value jProduct_id = jsonValue[i]["id"];
            const Json::Value jAmount = jsonValue[i]["count"];

            if (false == jProduct_id.isNull() &&
                false == jAmount.isNull())
            {
                int id = atoi(jProduct_id.asCString());
                int amount = atoi(jAmount.asCString());

                m_mapBuyShopInfo.insert(std::make_pair(id, amount));
            }
        }
    }

    return true;
}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:40,代码来源:ShopItemInfoFromServer.cpp

示例11: push_json_value_helper

// Recursive function to convert JSON --> Lua table
static bool push_json_value_helper(lua_State *L, const Json::Value &value,
		int nullindex)
{
	switch(value.type()) {
		case Json::nullValue:
		default:
			lua_pushvalue(L, nullindex);
			break;
		case Json::intValue:
			lua_pushinteger(L, value.asInt());
			break;
		case Json::uintValue:
			lua_pushinteger(L, value.asUInt());
			break;
		case Json::realValue:
			lua_pushnumber(L, value.asDouble());
			break;
		case Json::stringValue:
			{
				const char *str = value.asCString();
				lua_pushstring(L, str ? str : "");
			}
			break;
		case Json::booleanValue:
			lua_pushboolean(L, value.asInt());
			break;
		case Json::arrayValue:
			lua_newtable(L);
			for (Json::Value::const_iterator it = value.begin();
					it != value.end(); ++it) {
				push_json_value_helper(L, *it, nullindex);
				lua_rawseti(L, -2, it.index() + 1);
			}
			break;
		case Json::objectValue:
			lua_newtable(L);
			for (Json::Value::const_iterator it = value.begin();
					it != value.end(); ++it) {
#ifndef JSONCPP_STRING
				const char *str = it.memberName();
				lua_pushstring(L, str ? str : "");
#else
				std::string str = it.name();
				lua_pushstring(L, str.c_str());
#endif
				push_json_value_helper(L, *it, nullindex);
				lua_rawset(L, -3);
			}
			break;
	}
	return true;
}
开发者ID:kaeza,项目名称:minetest,代码行数:53,代码来源:c_content.cpp

示例12: UnpackValue

// helpers
CString UnpackValue(Json::Value& v)
{
	// we expect we are in UNICODE mode
	const char* c = v.asCString();
	if (!c) return CString();
	int s = strlen(c);
	int l = MultiByteToWideChar(CP_UTF8, 0, c, s, 0, 0);
	wchar_t* buf = new wchar_t[l+1];
	CAPtrGuard guard(buf);
	MultiByteToWideChar(CP_UTF8, 0, c, s, buf, l);
	buf[l] = 0;
	return CString(buf);
}
开发者ID:chzh,项目名称:xrefresh,代码行数:14,代码来源:ConnectionManager.cpp

示例13: to_uint

/***************以下函数用于读取json静态数据***************/
unsigned int to_uint(const Json::Value& val)
{
    if ( val.isIntegral() )
        return val.asUInt();

    if ( val.isDouble() )
        return (unsigned int)val.asDouble();

    if ( val.isString() )
        return strtoul(val.asCString(), NULL, 0 );

    return 0;
}
开发者ID:quinsmpang,项目名称:phone-code,代码行数:14,代码来源:jsonconfig.cpp

示例14: Widget

WidgetScript::WidgetScript(LCDCore *v, std::string n, Json::Value *section) :
    Widget(v, n, section, 0, 0, 0, WIDGET_TYPE_KEYPAD) {

    Json::Value *scriptFile = v->CFG_Fetch_Raw(section, "file", NULL);
    if(scriptFile) {
        FILE *file = fopen( scriptFile->asCString(), "rb");
        if( !file ) {
            LCDError("WidgetScript: Unable to open file <%s>", scriptFile->asCString());
            return;
        }
        fseek(file, 0, SEEK_END);
        long size = ftell(file);
        fseek(file, 0, SEEK_SET);
        char *buffer = new char[size+1];
        buffer[size] = 0x0;
        if( fread( buffer, 1, size, file) != (unsigned long) size)
            return;
        std::string script = buffer;
        delete []buffer;
        fclose(file);
        v->Eval(script);
    }
}
开发者ID:Chelovecheggg,项目名称:libvisual,代码行数:23,代码来源:WidgetScript.cpp

示例15: WidgetColor

int Widget::WidgetColor(Json::Value *section, std::string key, RGBA *C) {

    C->R = 0;
    C->G = 0;
    C->B = 0;
    C->A = 0;

    Json::Value *val = NULL;
    
    val = visitor_->CFG_Fetch_Raw(section, key);

    if (val == NULL)
        return 0;

    if (color2RGBA(val->asCString(), C) < 0) {
        LCDError("widget '%s': ignoring illegal %s color '%s'", 
            name_.c_str(), key.c_str(), val->asCString());
        return 0;
    }

    delete val;
    return 1;
}
开发者ID:Chelovecheggg,项目名称:libvisual,代码行数:23,代码来源:Widget.cpp


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