X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene-loader%2Finternal%2Fjson-reader.cpp;h=035381716b1f6e4bf13d4e00fb315a0fe7d3d70f;hb=cef6d2324d9ecca71abf3c9e63db8e371a636b8a;hp=6b12d1d55d001b5c9f5358b308883a9c2912f710;hpb=7a315fe9869206bf6ad3195931f27d88fe9c128e;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene-loader/internal/json-reader.cpp b/dali-scene-loader/internal/json-reader.cpp index 6b12d1d..0353817 100644 --- a/dali-scene-loader/internal/json-reader.cpp +++ b/dali-scene-loader/internal/json-reader.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,28 +20,25 @@ namespace json { - int StrCmp(const json_string_s& js, const char* s) { - auto sSize = strlen(s); + auto sSize = strlen(s); auto shorter = std::min(js.string_size, sSize); - auto base = strncmp(js.string, s, shorter); - return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ? - -s[shorter] : js.string[shorter]); + auto base = strncmp(js.string, s, shorter); + return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ? -s[shorter] : js.string[shorter]); } int StrCmp(const json_string_s& js, const std::string& s) { - auto sSize = s.size(); + auto sSize = s.size(); auto shorter = std::min(js.string_size, sSize); - auto base = strncmp(js.string, s.c_str(), shorter); - return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ? - -s[shorter] : js.string[shorter]); + auto base = strncmp(js.string, s.c_str(), shorter); + return ((base != 0) || (sSize == js.string_size)) ? base : ((js.string_size < sSize) ? -s[shorter] : js.string[shorter]); } -void Validate(const json_value_s & jv, json_type_e type) +void Validate(const json_value_s& jv, json_type_e type) { - if (jv.type != type) + if(jv.type != type) { throw std::runtime_error("Invalid type; expected: " + std::to_string(type) + ", got: " + std::to_string(jv.type)); } @@ -50,9 +47,9 @@ void Validate(const json_value_s & jv, json_type_e type) json_value_s* FindObjectChild(const std::string& key, json_object_s& obj) { auto i = obj.start; - while (i) + while(i) { - if (0 == StrCmp(*i->name, key)) + if(0 == StrCmp(*i->name, key)) { return i->value; } @@ -61,4 +58,4 @@ json_value_s* FindObjectChild(const std::string& key, json_object_s& obj) return nullptr; } -} +} // namespace json