本文整理汇总了C++中rapidjson::Value::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::GetString方法的具体用法?C++ Value::GetString怎么用?C++ Value::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::shared_ptr<VolumeIntegrator> VolumeIntegrator::Load(const rapidjson::Value& value) {
std::shared_ptr<VolumeIntegrator> integrator;
std::string type;
if (value.IsString()) {
type = value.GetString();
} else if (value.IsObject() && value.HasMember("type")) {
type = value["type"].GetString();
} else {
std::cerr << "VolumeIntegrator error: no type given" << std::endl;
return integrator;
}
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
if (type == "singlescattering") {
integrator = SingleScatteringIntegrator::Load(value);
} else {
std::cerr << "VolumeIntegrator error: unknown type \"" << type << "\"" << std::endl;
return integrator;
}
return integrator;
}
示例2: readFromValue
bool MultitypeVar::readFromValue(const rapidjson::Value& obj)
{
if (obj.IsNull())
{
mType = MultitypeNull;
}
else if (obj.IsBool())
{
mType = MultitypeBool;
mBool = obj.GetBool();
}
else if (obj.IsNumber())
{
mType = MultitypeNumber;
mNumber = obj.GetDouble();
}
else if (obj.IsString())
{
mType = MultitypeNumber;
mString = obj.GetString();
}
else
{
mType = MultitypeNull;
return false;
}
return true;
}
示例3: setProperty
bool UITextFieldLoader::setProperty(cocos2d::Node *p, const std::string & name, const rapidjson::Value & value, rapidjson::Value & properties)
{
uilib::TextField *text = dynamic_cast<uilib::TextField*>(p);
CCAssert(text, "UITextFieldLoader::setProperty");
if(name == "placeholderText")
{
if(value.IsString())
{
text->setPlaceholderText(value.GetString());
}
}
else if(name == "placeholderColor")
{
cocos2d::Color3B cr;
if(helper::parseValue(value, cr))
{
text->setPlaceholderColor(cr);
}
}
else
{
return base_class::setProperty(p, name, value, properties);
}
return true;
}
示例4: rewriteLocalScheme
void rewriteLocalScheme(rapidjson::Value &value, rapidjson::Document::AllocatorType &allocator) {
ASSERT_TRUE(value.IsString());
auto string = std::string { value.GetString(),value.GetStringLength() };
if (string.compare(0, 8, "local://") == 0) {
string.replace(0, 8, "http://127.0.0.1:2900/");
value.SetString(string.data(), string.size(), allocator);
}
}
示例5:
VertexIdx InputUtils::impl::VA::getVertexIdxFromValue(
const rapidjson::Value& vertexIdx) {
if (vertexIdx.IsString()) {
return (VertexIdx) std::atoll(vertexIdx.GetString());
} else {
return vertexIdx.GetDouble();
}
}
示例6: atoll
EdgeCost InputUtils::impl::VA::getEdgeCostFromValue(
const rapidjson::Value& edgeCost) {
if (edgeCost.IsString()) {
return std::atoll(edgeCost.GetString());
} else {
return edgeCost.GetDouble();
}
}
示例7: fromJson
bool fromJson(const rapidjson::Value &v, std::string &dst)
{
if (v.IsString()) {
dst = std::move(std::string(v.GetString()));
return true;
}
return false;
}
示例8: PrintValue
void PrintValue(rapidjson::Value &value)
{
rapidjson::Type type = value.GetType();
if (type == rapidjson::Type::kNumberType)
{
printf("%d", value.GetInt());
}
else if (type == rapidjson::Type::kStringType)
{
printf("%s", value.GetString());
}
else if (type == rapidjson::Type::kTrueType)
{
printf("가능");
}
else if (type == rapidjson::Type::kFalseType)
{
printf("불가능");
}
else if (type == rapidjson::Type::kArrayType)
{
for (int i = 0; i < value.Size(); i++)
{
PrintValue(value[i]);
if (i < value.Size() - 1)
printf(", ");
}
printf("\n");
}
else if (type == rapidjson::Type::kObjectType)
{
for (auto iter = value.MemberBegin(); iter != value.MemberEnd(); iter++)
{
rapidjson::Value &member = iter->value;
std::string name = iter->name.GetString();
if (member.GetType() == rapidjson::Type::kObjectType || member.GetType() == rapidjson::Type::kArrayType)
{
printf("\n- %s -\n", name.c_str());
PrintValue(member);
}
else
{
printf("%s : ", name.c_str());
PrintValue(member);
printf("\n");
}
}
}
else
{
printf("Null");
}
}
示例9: ToJSONValue
// Convert rapidjson value to JSON value.
static void ToJSONValue(JSONValue& jsonValue, const rapidjson::Value& rapidjsonValue)
{
switch (rapidjsonValue.GetType())
{
case kNullType:
// Reset to null type
jsonValue.SetType(JSON_NULL);
break;
case kFalseType:
jsonValue = false;
break;
case kTrueType:
jsonValue = true;
break;
case kNumberType:
if (rapidjsonValue.IsInt())
jsonValue = rapidjsonValue.GetInt();
else if (rapidjsonValue.IsUint())
jsonValue = rapidjsonValue.GetUint();
else
jsonValue = rapidjsonValue.GetDouble();
break;
case kStringType:
jsonValue = rapidjsonValue.GetString();
break;
case kArrayType:
{
jsonValue.Resize(rapidjsonValue.Size());
for (unsigned i = 0; i < rapidjsonValue.Size(); ++i)
{
ToJSONValue(jsonValue[i], rapidjsonValue[i]);
}
}
break;
case kObjectType:
{
jsonValue.SetType(JSON_OBJECT);
for (rapidjson::Value::ConstMemberIterator i = rapidjsonValue.MemberBegin(); i != rapidjsonValue.MemberEnd(); ++i)
{
JSONValue& value = jsonValue[String(i->name.GetString())];
ToJSONValue(value, i->value);
}
}
break;
default:
break;
}
}
示例10: read_print_for_array
void Json_Parser::read_print_for_array(rapidjson::Value &va,int i){
if (va.IsBool()) {
const bool flag=va.GetBool();
CCLOG("%d:%d",i,flag);
}
else if (va.IsDouble()) {
const double flag=va.GetDouble();
CCLOG("%d:%f",i,flag);
}
else if (va.IsInt()) {
const int flag=va.GetInt();
CCLOG("%d:%d",i,flag);
}
else if (va.IsString()) {
const std::string flag=va.GetString();
CCLOG("%d:%s",i,flag.c_str());
}
else if (va.IsNull()) {
CCLOG("%d:null",i);
}
else if(va.IsObject())
{
CCLOG("obj----------%d",i);
auto it=va.MemberBegin();
for (;it!=va.MemberEnd();it++) {
if (va.HasMember(it->name)) {
read_print(va,it->name.GetString());
}
}
}
else if(va.IsArray())
{
CCLOG("array-------%d",i);
for (int i=0; i<va.Size();i++) {
read_print_for_array(va[i],i);
}
}
}
示例11: setProperty
bool UIFrameViewLoader::setProperty(cocos2d::Node *p, const std::string & name, const rapidjson::Value & value, rapidjson::Value & properties)
{
uilib::FrameView *image = dynamic_cast<uilib::FrameView*>(p);
CCAssert(image, "UIFrameViewLoader::setProperty");
if (name == "image")
{
if(value.IsString())
{
image->setImage(value.GetString());
}
}
else if(name == "customSizeEnable")
{
if(value.IsBool())
{
image->setCustomSizeEnable(value.GetBool());
}
}
else if(name == "capInsets")
{
cocos2d::Rect rc;
if(helper::parseValue(value, rc))
{
image->setCapInsets(rc);
}
}
else if(name == "color")
{
cocos2d::Color3B cr;
if(helper::parseValue(value, cr))
{
image->setColor(cr);
}
}
else if(name == "opacity")
{
if(value.IsInt())
{
image->setOpacity(value.GetInt());
}
}
else
{
return base_class::setProperty(p, name, value, properties);
}
return true;
}
示例12: read_to_map_for_array
void Json_Parser::read_to_map_for_array(cocos2d::ValueVector &temp,rapidjson::Value &va,int i){
CCLOG("dex:%d",i);
if (va.IsBool()) {
const bool flag=va.GetBool();
temp.push_back(Value(flag));
}
else if (va.IsDouble()) {
const double flag=va.GetDouble();
temp.push_back(Value(flag));
}
else if (va.IsInt()) {
const int flag=va.GetInt();
temp.push_back(Value(flag));
}
else if (va.IsString()) {
const std::string flag=va.GetString();
temp.push_back(Value(flag));
// CCLOG("++:%d",temp.size());
}
else if (va.IsNull()) {
temp.push_back(Value(nullptr));
}
else if(va.IsObject())
{
cocos2d::ValueMap temp2;
auto it=va.MemberBegin();
for (;it!=va.MemberEnd();it++) {
if (va.HasMember(it->name)) {
read_to_map(temp2,va,it->name.GetString());
}
}
temp.push_back(Value(temp2));
// CCLOG("mapinvectro层:%lu",temp2.size());
}
else if(va.IsArray())
{
cocos2d::ValueVector temp2;
for (int i=0; i<va.Size();i++) {
read_to_map_for_array(temp2,va[i],i);
}
temp.push_back(Value(temp2));
// CCLOG("vectorinvectro层:%lu",temp.size());
}
}
示例13: readDatetime
time_t PlayFab::readDatetime(const rapidjson::Value& obj)
{
time_t time = (time_t)0;
std::string enumStr = obj.GetString();
tm timeStruct;
memset(&timeStruct, 0, sizeof(timeStruct));
unsigned int milliseconds = 0;
sscanf(enumStr.c_str(), "%u-%u-%uT%u:%u%u.%uZ", &timeStruct.tm_year, &timeStruct.tm_mon, &timeStruct.tm_mday,
&timeStruct.tm_hour, &timeStruct.tm_min, &timeStruct.tm_sec, &milliseconds);
timeStruct.tm_year -= 1900;
time = mktime(&timeStruct);
return time;
}
示例14: readDatetime
time_t PlayFab::readDatetime(const rapidjson::Value& obj)
{
time_t time = (time_t)0;
std::string enumStr = obj.GetString();
tm timeStruct = {};
unsigned int milliseconds = 0; // milliseconds are truncated in a standard time_t structure
sscanf(enumStr.c_str(), "%u-%u-%uT%u:%u%u.%uZ", &timeStruct.tm_year, &timeStruct.tm_mon, &timeStruct.tm_mday,
&timeStruct.tm_hour, &timeStruct.tm_min, &timeStruct.tm_sec, &milliseconds);
timeStruct.tm_year -= 1900;
timeStruct.tm_mon -= 1;
time = mktime(&timeStruct);
return time;
}
示例15: parseAccess
//-----------------------------------------------------------------------------------
ResourceAccess::ResourceAccess HlmsJsonCompute::parseAccess( const rapidjson::Value &json )
{
uint8 access = 0;
if( json.IsArray() )
{
for( rapidjson::SizeType i=0; i<json.Size(); ++i )
{
if( json[i].IsString() )
access |= parseAccess( json[i].GetString() );
}
}
else if( json.IsString() )
{
access = parseAccess( json.GetString() );
}
return static_cast<ResourceAccess::ResourceAccess>( access );
}