本文整理汇总了C++中rapidjson::Value::IsUint方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::IsUint方法的具体用法?C++ Value::IsUint怎么用?C++ Value::IsUint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rapidjson::Value
的用法示例。
在下文中一共展示了Value::IsUint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadBasedOnTextureOrUav
//-----------------------------------------------------------------------------------
void HlmsJsonCompute::loadBasedOnTextureOrUav( const rapidjson::Value &objValue,
const String &jobName, HlmsComputeJob *job,
int _threadGroupsBasedOn )
{
HlmsComputeJob::ThreadGroupsBasedOn threadGroupsBasedOn =
static_cast<HlmsComputeJob::ThreadGroupsBasedOn>( _threadGroupsBasedOn );
if( objValue.IsUint() )
{
job->setNumThreadGroupsBasedOn( threadGroupsBasedOn,
static_cast<uint8>( objValue.GetUint() ),
1u, 1u, 1u );
}
else if( objValue.IsObject() )
{
uint8 slot = 0;
uint8 divisors[3] = { 1u, 1u, 1u };
bool hasError = false;
const rapidjson::Value &subobj = objValue;
rapidjson::Value::ConstMemberIterator itor = subobj.FindMember( "slot" );
if( itor != subobj.MemberEnd() && itor->value.IsUint() )
slot = static_cast<uint8>( itor->value.GetUint() );
else
hasError = true;
itor = subobj.FindMember( "divisor" );
if( itor != subobj.MemberEnd() && itor->value.IsArray() )
{
const rapidjson::Value &divArray = itor->value;
const rapidjson::SizeType arraySize = std::min( 3u, divArray.Size() );
for( rapidjson::SizeType i=0; i<arraySize; ++i )
{
if( divArray[i].IsUint() )
{
divisors[i] = divArray[i].GetUint();
}
else
{
hasError = true;
LogManager::getSingleton().logMessage(
"Array with 3 integers expected in " + jobName + ". "
"Syntax is thread_groups_based_on_texture : { \"slot\" "
": 0, \"divisor\" : [1, 1, 1] } or the short form: "
"thread_groups_based_on_texture : 0 (with no divisors)" );
}
}
}
if( !hasError )
{
job->setNumThreadGroupsBasedOn( threadGroupsBasedOn,
slot, divisors[0], divisors[1], divisors[2] );
}
}
}
示例2: 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;
}
}
示例3: getJsonNumber
bool getJsonNumber(const rapidjson::Value &v, T &dst) {
if (v.IsDouble())
dst = T(v.GetDouble());
else if (v.IsInt())
dst = T(v.GetInt());
else if (v.IsUint())
dst = T(v.GetUint());
else if (v.IsInt64())
dst = T(v.GetInt64());
else if (v.IsUint64())
dst = T(v.GetUint64());
else
return false;
return true;
}
示例4: getType
int JsonValidator::getType(rapidjson::Value& jsonValue) {
if (jsonValue.IsNull()) {
return kJsonTypeNull;
} else if (jsonValue.IsBool()) {
return kJsonTypeBoolean;
} else if (jsonValue.IsObject()) {
return kJsonTypeObject;
} else if (jsonValue.IsArray()) {
return kJsonTypeArray;
} else if (jsonValue.IsString()) {
return kJsonTypeString;
} else if (jsonValue.IsInt() || jsonValue.IsInt64() ||
jsonValue.IsUint() || jsonValue.IsUint64()) {
return kJsonTypeInteger;
} else if (jsonValue.IsDouble()) {
return kJsonTypeDouble;
} else {
return kJsonTypeUnknown;
}
}
示例5: system_error
std::uint32_t get_value(const rapidjson::Value& root, const char* key)
{
if (key != nullptr)
{
if (root.HasMember(key) && root[key].IsUint())
{
return root[key].GetUint();
}
else
throw std::system_error(std::error_code(), "Parse error.");
}
else
{
if (root.IsUint())
{
return root.GetUint();
}
else
throw std::system_error(std::error_code(), "Parse error.");
}
}
示例6: ConvertToMsgPack
void ConvertToMsgPack(const rapidjson::Value& json, msgpack::object& object, msgpack::zone& zone)
{
switch (json.GetType())
{
case rapidjson::kFalseType:
object = false;
break;
case rapidjson::kTrueType:
object = true;
break;
case rapidjson::kNumberType:
{
if (json.IsInt())
{
object = json.GetInt();
}
else if (json.IsUint())
{
object = json.GetUint();
}
else if (json.IsInt64())
{
object = json.GetInt64();
}
else if (json.IsUint64())
{
object = json.GetUint64();
}
else if (json.IsDouble())
{
object = json.GetDouble();
}
break;
}
case rapidjson::kStringType:
// we allocate with 'zone', otherwise the std::string's raw pointer gets used, which won't work as it gets destructed later on
object = msgpack::object(std::string(json.GetString(), json.GetStringLength()), zone);
break;
case rapidjson::kObjectType:
{
std::map<std::string, msgpack::object> list;
for (auto it = json.MemberBegin(); it != json.MemberEnd(); it++)
{
msgpack::object newObject;
ConvertToMsgPack(it->value, newObject, zone);
list.insert({ it->name.GetString(), newObject });
}
object = msgpack::object(list, zone);
break;
}
case rapidjson::kArrayType:
{
std::vector<msgpack::object> list;
for (auto it = json.Begin(); it != json.End(); it++)
{
msgpack::object newObject;
ConvertToMsgPack(*it, newObject, zone);
list.push_back(newObject);
}
object = msgpack::object(list, zone);
break;
}
default:
object = msgpack::type::nil();
break;
}
}