diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-05-11 12:12:06 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.ru> | 2022-05-11 12:12:06 +0300 |
commit | 62f93da087b2fec0f89979fd11ac4d754ca36253 (patch) | |
tree | 67bf8ceb55e2d079f3575f9a7373584ad407d2a5 /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils | |
parent | 8d55620139d4309265409767f873ba83fe046418 (diff) | |
download | ydb-62f93da087b2fec0f89979fd11ac4d754ca36253.tar.gz |
Update aws-c-common and aws-c-io
* Update `contrib/restricted/aws/aws-c-io` to 0.11.0
* Backport cJSON symbol renaming logic from aws-sdk-cpp upstream
ref:396829235a01ed34888651ee38ebd76c95510d6b
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils')
-rw-r--r-- | contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp index 9b785d1995..9358d00c0a 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/utils/json/JsonSerializer.cpp @@ -19,7 +19,7 @@ JsonValue::JsonValue() : m_wasParseSuccessful(true) } JsonValue::JsonValue(cJSON* value) : - m_value(cJSON_Duplicate(value, true /* recurse */)), + m_value(cJSON_AS4CPP_Duplicate(value, true /* recurse */)), m_wasParseSuccessful(true) { } @@ -27,9 +27,9 @@ JsonValue::JsonValue(cJSON* value) : JsonValue::JsonValue(const Aws::String& value) : m_wasParseSuccessful(true) { const char* return_parse_end; - m_value = cJSON_ParseWithOpts(value.c_str(), &return_parse_end, 1/*require_null_terminated*/); + m_value = cJSON_AS4CPP_ParseWithOpts(value.c_str(), &return_parse_end, 1/*require_null_terminated*/); - if (!m_value || cJSON_IsInvalid(m_value)) + if (!m_value || cJSON_AS4CPP_IsInvalid(m_value)) { m_wasParseSuccessful = false; m_errorMessage = "Failed to parse JSON at: "; @@ -43,9 +43,9 @@ JsonValue::JsonValue(Aws::IStream& istream) : m_wasParseSuccessful(true) std::copy(std::istreambuf_iterator<char>(istream), std::istreambuf_iterator<char>(), std::ostreambuf_iterator<char>(memoryStream)); const char* return_parse_end; const auto input = memoryStream.str(); - m_value = cJSON_ParseWithOpts(input.c_str(), &return_parse_end, 1/*require_null_terminated*/); + m_value = cJSON_AS4CPP_ParseWithOpts(input.c_str(), &return_parse_end, 1/*require_null_terminated*/); - if (!m_value || cJSON_IsInvalid(m_value)) + if (!m_value || cJSON_AS4CPP_IsInvalid(m_value)) { m_wasParseSuccessful = false; m_errorMessage = "Failed to parse JSON. Invalid input at: "; @@ -54,7 +54,7 @@ JsonValue::JsonValue(Aws::IStream& istream) : m_wasParseSuccessful(true) } JsonValue::JsonValue(const JsonValue& value) : - m_value(cJSON_Duplicate(value.m_value, true/*recurse*/)), + m_value(cJSON_AS4CPP_Duplicate(value.m_value, true/*recurse*/)), m_wasParseSuccessful(value.m_wasParseSuccessful), m_errorMessage(value.m_errorMessage) { @@ -70,7 +70,7 @@ JsonValue::JsonValue(JsonValue&& value) : void JsonValue::Destroy() { - cJSON_Delete(m_value); + cJSON_AS4CPP_Delete(m_value); } JsonValue::~JsonValue() @@ -86,7 +86,7 @@ JsonValue& JsonValue::operator=(const JsonValue& other) } Destroy(); - m_value = cJSON_Duplicate(other.m_value, true /*recurse*/); + m_value = cJSON_AS4CPP_Duplicate(other.m_value, true /*recurse*/); m_wasParseSuccessful = other.m_wasParseSuccessful; m_errorMessage = other.m_errorMessage; return *this; @@ -108,14 +108,14 @@ JsonValue& JsonValue::operator=(JsonValue&& other) static void AddOrReplace(cJSON* root, const char* key, cJSON* value) { - const auto existing = cJSON_GetObjectItemCaseSensitive(root, key); + const auto existing = cJSON_AS4CPP_GetObjectItemCaseSensitive(root, key); if (existing) { - cJSON_ReplaceItemInObjectCaseSensitive(root, key, value); + cJSON_AS4CPP_ReplaceItemInObjectCaseSensitive(root, key, value); } else { - cJSON_AddItemToObject(root, key, value); + cJSON_AS4CPP_AddItemToObject(root, key, value); } } @@ -123,10 +123,10 @@ JsonValue& JsonValue::WithString(const char* key, const Aws::String& value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - const auto val = cJSON_CreateString(value.c_str()); + const auto val = cJSON_AS4CPP_CreateString(value.c_str()); AddOrReplace(m_value, key, val); return *this; } @@ -139,7 +139,7 @@ JsonValue& JsonValue::WithString(const Aws::String& key, const Aws::String& valu JsonValue& JsonValue::AsString(const Aws::String& value) { Destroy(); - m_value = cJSON_CreateString(value.c_str()); + m_value = cJSON_AS4CPP_CreateString(value.c_str()); return *this; } @@ -147,10 +147,10 @@ JsonValue& JsonValue::WithBool(const char* key, bool value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - const auto val = cJSON_CreateBool(value); + const auto val = cJSON_AS4CPP_CreateBool(value); AddOrReplace(m_value, key, val); return *this; } @@ -163,7 +163,7 @@ JsonValue& JsonValue::WithBool(const Aws::String& key, bool value) JsonValue& JsonValue::AsBool(bool value) { Destroy(); - m_value = cJSON_CreateBool(value); + m_value = cJSON_AS4CPP_CreateBool(value); return *this; } @@ -180,7 +180,7 @@ JsonValue& JsonValue::WithInteger(const Aws::String& key, int value) JsonValue& JsonValue::AsInteger(int value) { Destroy(); - m_value = cJSON_CreateNumber(static_cast<double>(value)); + m_value = cJSON_AS4CPP_CreateNumber(static_cast<double>(value)); return *this; } @@ -188,10 +188,10 @@ JsonValue& JsonValue::WithInt64(const char* key, long long value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - const auto val = cJSON_CreateInt64(value); + const auto val = cJSON_AS4CPP_CreateInt64(value); AddOrReplace(m_value, key, val); return *this; } @@ -204,7 +204,7 @@ JsonValue& JsonValue::WithInt64(const Aws::String& key, long long value) JsonValue& JsonValue::AsInt64(long long value) { Destroy(); - m_value = cJSON_CreateInt64(value); + m_value = cJSON_AS4CPP_CreateInt64(value); return *this; } @@ -212,10 +212,10 @@ JsonValue& JsonValue::WithDouble(const char* key, double value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - const auto val = cJSON_CreateNumber(value); + const auto val = cJSON_AS4CPP_CreateNumber(value); AddOrReplace(m_value, key, val); return *this; } @@ -228,7 +228,7 @@ JsonValue& JsonValue::WithDouble(const Aws::String& key, double value) JsonValue& JsonValue::AsDouble(double value) { Destroy(); - m_value = cJSON_CreateNumber(value); + m_value = cJSON_AS4CPP_CreateNumber(value); return *this; } @@ -236,13 +236,13 @@ JsonValue& JsonValue::WithArray(const char* key, const Array<Aws::String>& array { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - auto arrayValue = cJSON_CreateArray(); + auto arrayValue = cJSON_AS4CPP_CreateArray(); for (unsigned i = 0; i < array.GetLength(); ++i) { - cJSON_AddItemToArray(arrayValue, cJSON_CreateString(array[i].c_str())); + cJSON_AS4CPP_AddItemToArray(arrayValue, cJSON_AS4CPP_CreateString(array[i].c_str())); } AddOrReplace(m_value, key, arrayValue); @@ -258,13 +258,13 @@ JsonValue& JsonValue::WithArray(const Aws::String& key, const Array<JsonValue>& { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - auto arrayValue = cJSON_CreateArray(); + auto arrayValue = cJSON_AS4CPP_CreateArray(); for (unsigned i = 0; i < array.GetLength(); ++i) { - cJSON_AddItemToArray(arrayValue, cJSON_Duplicate(array[i].m_value, true /*recurse*/)); + cJSON_AS4CPP_AddItemToArray(arrayValue, cJSON_AS4CPP_Duplicate(array[i].m_value, true /*recurse*/)); } AddOrReplace(m_value, key.c_str(), arrayValue); @@ -275,13 +275,13 @@ JsonValue& JsonValue::WithArray(const Aws::String& key, Array<JsonValue>&& array { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - auto arrayValue = cJSON_CreateArray(); + auto arrayValue = cJSON_AS4CPP_CreateArray(); for (unsigned i = 0; i < array.GetLength(); ++i) { - cJSON_AddItemToArray(arrayValue, array[i].m_value); + cJSON_AS4CPP_AddItemToArray(arrayValue, array[i].m_value); array[i].m_value = nullptr; } @@ -291,10 +291,10 @@ JsonValue& JsonValue::WithArray(const Aws::String& key, Array<JsonValue>&& array JsonValue& JsonValue::AsArray(const Array<JsonValue>& array) { - auto arrayValue = cJSON_CreateArray(); + auto arrayValue = cJSON_AS4CPP_CreateArray(); for (unsigned i = 0; i < array.GetLength(); ++i) { - cJSON_AddItemToArray(arrayValue, cJSON_Duplicate(array[i].m_value, true /*recurse*/)); + cJSON_AS4CPP_AddItemToArray(arrayValue, cJSON_AS4CPP_Duplicate(array[i].m_value, true /*recurse*/)); } Destroy(); @@ -304,10 +304,10 @@ JsonValue& JsonValue::AsArray(const Array<JsonValue>& array) JsonValue& JsonValue::AsArray(Array<JsonValue>&& array) { - auto arrayValue = cJSON_CreateArray(); + auto arrayValue = cJSON_AS4CPP_CreateArray(); for (unsigned i = 0; i < array.GetLength(); ++i) { - cJSON_AddItemToArray(arrayValue, array[i].m_value); + cJSON_AS4CPP_AddItemToArray(arrayValue, array[i].m_value); array[i].m_value = nullptr; } @@ -320,10 +320,10 @@ JsonValue& JsonValue::WithObject(const char* key, const JsonValue& value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - const auto copy = value.m_value == nullptr ? cJSON_CreateObject() : cJSON_Duplicate(value.m_value, true /*recurse*/); + const auto copy = value.m_value == nullptr ? cJSON_AS4CPP_CreateObject() : cJSON_AS4CPP_Duplicate(value.m_value, true /*recurse*/); AddOrReplace(m_value, key, copy); return *this; } @@ -337,10 +337,10 @@ JsonValue& JsonValue::WithObject(const char* key, JsonValue&& value) { if (!m_value) { - m_value = cJSON_CreateObject(); + m_value = cJSON_AS4CPP_CreateObject(); } - AddOrReplace(m_value, key, value.m_value == nullptr ? cJSON_CreateObject() : value.m_value); + AddOrReplace(m_value, key, value.m_value == nullptr ? cJSON_AS4CPP_CreateObject() : value.m_value); value.m_value = nullptr; return *this; } @@ -364,7 +364,7 @@ JsonValue& JsonValue::AsObject(JsonValue && value) bool JsonValue::operator==(const JsonValue& other) const { - return cJSON_Compare(m_value, other.m_value, true /*case-sensitive*/) != 0; + return cJSON_AS4CPP_Compare(m_value, other.m_value, true /*case-sensitive*/) != 0; } bool JsonValue::operator!=(const JsonValue& other) const @@ -404,14 +404,14 @@ JsonView& JsonView::operator=(cJSON* val) Aws::String JsonView::GetString(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); - auto str = cJSON_GetStringValue(item); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto str = cJSON_AS4CPP_GetStringValue(item); return str ? str : ""; } Aws::String JsonView::AsString() const { - const char* str = cJSON_GetStringValue(m_value); + const char* str = cJSON_AS4CPP_GetStringValue(m_value); if (str == nullptr) { return {}; @@ -422,35 +422,35 @@ Aws::String JsonView::AsString() const bool JsonView::GetBool(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); assert(item); return item->valueint != 0; } bool JsonView::AsBool() const { - assert(cJSON_IsBool(m_value)); - return cJSON_IsTrue(m_value) != 0; + assert(cJSON_AS4CPP_IsBool(m_value)); + return cJSON_AS4CPP_IsTrue(m_value) != 0; } int JsonView::GetInteger(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); assert(item); return item->valueint; } int JsonView::AsInteger() const { - assert(cJSON_IsNumber(m_value)); // can be double or value larger than int_max, but at least not UB + assert(cJSON_AS4CPP_IsNumber(m_value)); // can be double or value larger than int_max, but at least not UB return m_value->valueint; } int64_t JsonView::GetInt64(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); assert(item); if (item->valuestring) { @@ -464,7 +464,7 @@ int64_t JsonView::GetInt64(const Aws::String& key) const int64_t JsonView::AsInt64() const { - assert(cJSON_IsNumber(m_value)); + assert(cJSON_AS4CPP_IsNumber(m_value)); if (m_value->valuestring) { return Aws::Utils::StringUtils::ConvertToInt64(m_value->valuestring); @@ -478,36 +478,36 @@ int64_t JsonView::AsInt64() const double JsonView::GetDouble(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); assert(item); return item->valuedouble; } double JsonView::AsDouble() const { - assert(cJSON_IsNumber(m_value)); + assert(cJSON_AS4CPP_IsNumber(m_value)); return m_value->valuedouble; } JsonView JsonView::GetObject(const Aws::String& key) const { assert(m_value); - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); return item; } JsonView JsonView::AsObject() const { - assert(cJSON_IsObject(m_value) || cJSON_IsNull(m_value)); + assert(cJSON_AS4CPP_IsObject(m_value) || cJSON_AS4CPP_IsNull(m_value)); return m_value; } Array<JsonView> JsonView::GetArray(const Aws::String& key) const { assert(m_value); - auto array = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); - assert(cJSON_IsArray(array)); - Array<JsonView> returnArray(cJSON_GetArraySize(array)); + auto array = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); + assert(cJSON_AS4CPP_IsArray(array)); + Array<JsonView> returnArray(cJSON_AS4CPP_GetArraySize(array)); auto element = array->child; for (unsigned i = 0; element && i < returnArray.GetLength(); ++i, element = element->next) @@ -520,8 +520,8 @@ Array<JsonView> JsonView::GetArray(const Aws::String& key) const Array<JsonView> JsonView::AsArray() const { - assert(cJSON_IsArray(m_value)); - Array<JsonView> returnArray(cJSON_GetArraySize(m_value)); + assert(cJSON_AS4CPP_IsArray(m_value)); + Array<JsonView> returnArray(cJSON_AS4CPP_GetArraySize(m_value)); auto element = m_value->child; @@ -551,43 +551,43 @@ Aws::Map<Aws::String, JsonView> JsonView::GetAllObjects() const bool JsonView::ValueExists(const Aws::String& key) const { - if (!cJSON_IsObject(m_value)) + if (!cJSON_AS4CPP_IsObject(m_value)) { return false; } - auto item = cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()); - return !(item == nullptr || cJSON_IsNull(item)); + auto item = cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()); + return !(item == nullptr || cJSON_AS4CPP_IsNull(item)); } bool JsonView::KeyExists(const Aws::String& key) const { - if (!cJSON_IsObject(m_value)) + if (!cJSON_AS4CPP_IsObject(m_value)) { return false; } - return cJSON_GetObjectItemCaseSensitive(m_value, key.c_str()) != nullptr;; + return cJSON_AS4CPP_GetObjectItemCaseSensitive(m_value, key.c_str()) != nullptr;; } bool JsonView::IsObject() const { - return cJSON_IsObject(m_value) != 0; + return cJSON_AS4CPP_IsObject(m_value) != 0; } bool JsonView::IsBool() const { - return cJSON_IsBool(m_value) != 0; + return cJSON_AS4CPP_IsBool(m_value) != 0; } bool JsonView::IsString() const { - return cJSON_IsString(m_value) != 0; + return cJSON_AS4CPP_IsString(m_value) != 0; } bool JsonView::IsIntegerType() const { - if (!cJSON_IsNumber(m_value)) + if (!cJSON_AS4CPP_IsNumber(m_value)) { return false; } @@ -602,7 +602,7 @@ bool JsonView::IsIntegerType() const bool JsonView::IsFloatingPointType() const { - if (!cJSON_IsNumber(m_value)) + if (!cJSON_AS4CPP_IsNumber(m_value)) { return false; } @@ -617,12 +617,12 @@ bool JsonView::IsFloatingPointType() const bool JsonView::IsListType() const { - return cJSON_IsArray(m_value) != 0; + return cJSON_AS4CPP_IsArray(m_value) != 0; } bool JsonView::IsNull() const { - return cJSON_IsNull(m_value) != 0; + return cJSON_AS4CPP_IsNull(m_value) != 0; } Aws::String JsonView::WriteCompact(bool treatAsObject) const @@ -636,9 +636,9 @@ Aws::String JsonView::WriteCompact(bool treatAsObject) const return {}; } - auto temp = cJSON_PrintUnformatted(m_value); + auto temp = cJSON_AS4CPP_PrintUnformatted(m_value); Aws::String out(temp); - cJSON_free(temp); + cJSON_AS4CPP_free(temp); return out; } @@ -653,9 +653,9 @@ Aws::String JsonView::WriteReadable(bool treatAsObject) const return {}; } - auto temp = cJSON_Print(m_value); + auto temp = cJSON_AS4CPP_Print(m_value); Aws::String out(temp); - cJSON_free(temp); + cJSON_AS4CPP_free(temp); return out; } |