2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "dali-scene-loader/internal/json-reader.h"
24 int StrCmp(const json_string_s& js, const char* s)
26 auto sSize = strlen(s);
27 auto shorter = std::min(js.string_size, sSize);
28 auto base = strncmp(js.string, s, shorter);
29 return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ?
30 -s[shorter] : js.string[shorter]);
33 int StrCmp(const json_string_s& js, const std::string& s)
35 auto sSize = s.size();
36 auto shorter = std::min(js.string_size, sSize);
37 auto base = strncmp(js.string, s.c_str(), shorter);
38 return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ?
39 -s[shorter] : js.string[shorter]);
42 void Validate(const json_value_s & jv, json_type_e type)
46 throw std::runtime_error("Invalid type; expected: " + std::to_string(type) + ", got: " + std::to_string(jv.type));
50 json_value_s* FindObjectChild(const std::string& key, json_object_s& obj)
55 if (0 == StrCmp(*i->name, key))