From e342a9d243d9cdea030ce08ad3770713f76de4e2 Mon Sep 17 00:00:00 2001 From: Korobeinikov Evgeny Date: Wed, 5 Feb 2025 12:08:04 +0300 Subject: [PATCH] Delete std namespace --- interop/src/cpp/DeserializerBase.h | 62 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/interop/src/cpp/DeserializerBase.h b/interop/src/cpp/DeserializerBase.h index 7f62a8768..2e4292713 100644 --- a/interop/src/cpp/DeserializerBase.h +++ b/interop/src/cpp/DeserializerBase.h @@ -31,8 +31,6 @@ void releaseManagedCallbackResource(InteropInt32); #define KOALA_NO_UNALIGNED_ACCESS 1 #endif -using namespace std; - inline const char *tagName(InteropTag tag) { switch (tag) @@ -145,10 +143,10 @@ inline void convertor(T value) = delete; // TODO: restore full printing! template -inline void WriteToString(string *result, T value) = delete; +inline void WriteToString(std::string *result, T value) = delete; template <> -inline void WriteToString(string *result, const InteropEmpty &value) +inline void WriteToString(std::string *result, const InteropEmpty &value) { result->append("{"); result->append(".dummy=" + std::to_string(value.dummy)); @@ -162,26 +160,26 @@ struct Error }; template <> -inline void WriteToString(string *result, InteropTag value) +inline void WriteToString(std::string *result, InteropTag value) { result->append(".tag="); result->append(tagName(value)); } template <> -inline void WriteToString(string *result, InteropNativePointer value) +inline void WriteToString(std::string *result, InteropNativePointer value) { result->append("0x" + std::to_string((uint64_t)value)); } template <> -inline void WriteToString(string *result, InteropNodeHandle value) +inline void WriteToString(std::string *result, InteropNodeHandle value) { result->append("0x" + std::to_string((uint64_t)value)); } template <> -inline void WriteToString(string *result, InteropFunction value) +inline void WriteToString(std::string *result, InteropFunction value) { result->append("{"); result->append(".id=" + std::to_string(value.id)); @@ -189,7 +187,7 @@ inline void WriteToString(string *result, InteropFunction value) } template <> -inline void WriteToString(string *result, const InteropFunction* value) +inline void WriteToString(std::string *result, const InteropFunction* value) { result->append("{"); result->append(".id=" + std::to_string(value->id)); @@ -197,7 +195,7 @@ inline void WriteToString(string *result, const InteropFunction* value) } template <> -inline void WriteToString(string *result, const InteropMaterialized *value) +inline void WriteToString(std::string *result, const InteropMaterialized *value) { char hex[20]; std::snprintf(hex, sizeof(hex), "0x%llx", (long long)value->ptr); @@ -209,7 +207,7 @@ inline void WriteToString(string *result, const InteropMaterialized *value) // TODO: generate! template<> -inline void WriteToString(string *result, const InteropCallbackResource *value) +inline void WriteToString(std::string *result, const InteropCallbackResource *value) { result->append("{"); result->append(".resourceId=" + std::to_string(value->resourceId)); @@ -221,27 +219,27 @@ inline void WriteToString(string *result, const InteropCallbackResource *value) class DeserializerBase; template <> -inline void WriteToString(string *result, InteropUndefined value) +inline void WriteToString(std::string *result, InteropUndefined value) { result->append("{}"); } template <> -inline void WriteToString(string *result, const InteropUndefined *value) +inline void WriteToString(std::string *result, const InteropUndefined *value) { result->append("{}"); } template <> -inline void WriteToString(string *result, InteropVoid value) +inline void WriteToString(std::string *result, InteropVoid value) { result->append("{}"); } template <> -inline void WriteToString(string *result, const InteropVoid *value) +inline void WriteToString(std::string *result, const InteropVoid *value) { result->append("{}"); } template <> -inline void WriteToString(string *result, const InteropCustomObject *value) +inline void WriteToString(std::string *result, const InteropCustomObject *value) { if (strcmp(value->kind, "NativeErrorFunction") == 0) { @@ -257,8 +255,8 @@ inline void WriteToString(string *result, const InteropCustomObject *value) struct CustomDeserializer { virtual ~CustomDeserializer() {} - virtual bool supports(const string &kind) { return false; } - virtual InteropCustomObject deserialize(DeserializerBase *deserializer, const string &kind) + virtual bool supports(const std::string &kind) { return false; } + virtual InteropCustomObject deserialize(DeserializerBase *deserializer, const std::string &kind) { InteropCustomObject result; strcpy(result.kind, "error"); @@ -349,7 +347,7 @@ public: } } - InteropCustomObject readCustomObject(string kind) + InteropCustomObject readCustomObject(std::string kind) { auto *current = DeserializerBase::customDeserializers; while (current) @@ -538,32 +536,32 @@ public: } }; template <> -inline void WriteToString(string *result, InteropBoolean value) +inline void WriteToString(std::string *result, InteropBoolean value) { result->append(value ? "true" : "false"); } template <> -inline void WriteToString(string *result, InteropInt32 value) +inline void WriteToString(std::string *result, InteropInt32 value) { result->append(std::to_string(value)); } template <> -inline void WriteToString(string *result, const InteropInt32* value) +inline void WriteToString(std::string *result, const InteropInt32* value) { result->append(std::to_string(*value)); } template <> -inline void WriteToString(string *result, InteropInt64 value) +inline void WriteToString(std::string *result, InteropInt64 value) { result->append(std::to_string(value)); } template <> -inline void WriteToString(string *result, InteropUInt32 value) +inline void WriteToString(std::string *result, InteropUInt32 value) { result->append(std::to_string(value)); } template <> -inline void WriteToString(string *result, InteropFloat32 value) +inline void WriteToString(std::string *result, InteropFloat32 value) { std::string storage; storage.resize(20); @@ -573,19 +571,19 @@ inline void WriteToString(string *result, InteropFloat32 value) result->append(storage); } template <> -inline void WriteToString(string* result, const InteropBuffer* value) { +inline void WriteToString(std::string* result, const InteropBuffer* value) { result->append("{.data=nullptr, .length="); - result->append(to_string(value->length)); + result->append(std::to_string(value->length)); result->append("}"); } template <> -inline void WriteToString(string* result, InteropBuffer value) { +inline void WriteToString(std::string* result, InteropBuffer value) { result->append("{.data=nullptr, .length="); - result->append(to_string(value.length)); + result->append(std::to_string(value.length)); result->append("}"); } template <> -inline void WriteToString(string *result, const InteropString *value) +inline void WriteToString(std::string *result, const InteropString *value) { result->append("{"); if (value->chars) { @@ -601,7 +599,7 @@ inline void WriteToString(string *result, const InteropString *value) } template <> -inline void WriteToString(string *result, const InteropNumber *value) +inline void WriteToString(std::string *result, const InteropNumber *value) { result->append("{.tag=" + std::to_string(value->tag) + ", "); @@ -618,7 +616,7 @@ inline void WriteToString(string *result, const InteropNumber *value) } template <> -inline void WriteToString(string *result, const InteropLength *value) +inline void WriteToString(std::string *result, const InteropLength *value) { result->append("{"); result->append(".type=" + std::to_string(value->type)); -- Gitee