MCPcopy Create free account
hub / github.com/crownengine/crown / parse

Function parse

src/resource/render_config_resource.cpp:43–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41namespace render_settings
42{
43 s32 parse(HashMap<StringId32, Value> &rs, const char *settings_json)
44 {
45 TempAllocator1024 ta;
46 JsonObject obj(ta);
47 RETURN_IF_ERROR(sjson::parse(obj, settings_json));
48
49 auto cur = json_object::begin(obj);
50 auto end = json_object::end(obj);
51 for (; cur != end; ++cur) {
52 JSON_OBJECT_SKIP_HOLE(obj, cur);
53
54 if (cur->first == "sun_shadow_map_size") {
55 Value v; v.type = Value::VECTOR2; v.value.v2 = RETURN_IF_ERROR(sjson::parse_vector2(cur->second));
56 hash_map::set(rs, cur->first.to_string_id(), v);
57 } else if (cur->first == "sun_shadows") {
58 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
59 hash_map::set(rs, cur->first.to_string_id(), v);
60 } else if (cur->first == "local_lights_shadow_map_size") {
61 Value v; v.type = Value::VECTOR2; v.value.v2 = RETURN_IF_ERROR(sjson::parse_vector2(cur->second));
62 hash_map::set(rs, cur->first.to_string_id(), v);
63 } else if (cur->first == "local_lights") {
64 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
65 hash_map::set(rs, cur->first.to_string_id(), v);
66 } else if (cur->first == "local_lights_shadows") {
67 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
68 hash_map::set(rs, cur->first.to_string_id(), v);
69 } else if (cur->first == "local_lights_distance_culling") {
70 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
71 hash_map::set(rs, cur->first.to_string_id(), v);
72 } else if (cur->first == "bloom") {
73 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
74 hash_map::set(rs, cur->first.to_string_id(), v);
75 } else if (cur->first == "msaa") {
76 Value v; v.type = Value::BOOL; v.value.b = RETURN_IF_ERROR(sjson::parse_bool(cur->second));
77 hash_map::set(rs, cur->first.to_string_id(), v);
78 } else if (cur->first == "msaa_quality") {
79 StringId32 quality = RETURN_IF_ERROR(sjson::parse_string_id(cur->second));
80 Value v; v.type = Value::UINT32; v.value.u = msaa_quality_samples(quality);
81 hash_map::set(rs, cur->first.to_string_id(), v);
82 } else if (cur->first == "local_lights_distance_culling_fade") {
83 Value v; v.type = Value::FLOAT; v.value.f = RETURN_IF_ERROR(sjson::parse_float(cur->second));
84 hash_map::set(rs, cur->first.to_string_id(), v);
85 } else if (cur->first == "local_lights_distance_culling_cutoff") {
86 Value v; v.type = Value::FLOAT; v.value.f = RETURN_IF_ERROR(sjson::parse_float(cur->second));
87 hash_map::set(rs, cur->first.to_string_id(), v);
88 } else if (cur->first == "lod_fade_duration") {
89 Value v; v.type = Value::FLOAT; v.value.f = RETURN_IF_ERROR(sjson::parse_float(cur->second));
90 hash_map::set(rs, cur->first.to_string_id(), v);
91 } else {
92 logw(RENDER_CONFIG_RESOURCE
93 , "Unknown render_settings property '%.*s'"
94 , cur->first.length()
95 , cur->first.data()
96 );
97 }
98 }
99
100 return 0;

Callers 1

compileFunction · 0.70

Calls 10

parse_vector2Function · 0.85
setClass · 0.85
parse_string_idFunction · 0.85
msaa_quality_samplesFunction · 0.85
beginFunction · 0.50
endFunction · 0.50
parse_boolFunction · 0.50
parse_floatFunction · 0.50
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected