diff --git a/generator/jsonserializationcodegenerator.cpp b/generator/jsonserializationcodegenerator.cpp index 4604902..8ed1f18 100644 --- a/generator/jsonserializationcodegenerator.cpp +++ b/generator/jsonserializationcodegenerator.cpp @@ -47,9 +47,9 @@ void JsonSerializationCodeGenerator::generate(ostream &os) const return; } - // put everything into namespace ReflectiveRapidJSON::Reflector + // put everything into namespace ReflectiveRapidJSON::JsonReflector os << "namespace ReflectiveRapidJSON {\n" - "namespace Reflector {\n\n"; + "namespace JsonReflector {\n\n"; // add push and pull functions for each class, for an example of the resulting // output, see ../lib/tests/jsonserializable.cpp (code under comment "pretend serialization code...") @@ -101,8 +101,8 @@ void JsonSerializationCodeGenerator::generate(ostream &os) const os << "}\n\n"; } - // close namespace ReflectiveRapidJSON::Reflector - os << "} // namespace Reflector\n" + // close namespace ReflectiveRapidJSON::JsonReflector + os << "} // namespace JsonReflector\n" "} // namespace ReflectiveRapidJSON\n"; } diff --git a/generator/testfiles/some_structs_json_serialization.h b/generator/testfiles/some_structs_json_serialization.h index 97ec12d..c3f4770 100644 --- a/generator/testfiles/some_structs_json_serialization.h +++ b/generator/testfiles/some_structs_json_serialization.h @@ -1,5 +1,5 @@ namespace ReflectiveRapidJSON { -namespace Reflector { +namespace JsonReflector { // define code for (de)serializing TestNamespace1::Person objects template <> inline void push<::TestNamespace1::Person>(const ::TestNamespace1::Person &reflectable, ::RAPIDJSON_NAMESPACE::Value::Object &value, ::RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) @@ -27,5 +27,5 @@ template <> inline void pull<::TestNamespace1::Person>(::TestNamespace1::Person } } -} // namespace Reflector +} // namespace JsonReflector } // namespace ReflectiveRapidJSON diff --git a/lib/json/reflector-boosthana.h b/lib/json/reflector-boosthana.h index 320ce47..38b85ab 100644 --- a/lib/json/reflector-boosthana.h +++ b/lib/json/reflector-boosthana.h @@ -18,7 +18,7 @@ #include namespace ReflectiveRapidJSON { -namespace Reflector { +namespace JsonReflector { // define functions to "push" values to a RapidJSON array or object @@ -59,7 +59,7 @@ void pull(Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue struct TuplePushHelper { static void push(const Tuple &tuple, RAPIDJSON_NAMESPACE::Value::Array &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { TuplePushHelper::push(tuple, value, allocator); - Reflector::push(std::get(tuple), value, allocator); + JsonReflector::push(std::get(tuple), value, allocator); } }; template struct TuplePushHelper { static void push(const Tuple &tuple, RAPIDJSON_NAMESPACE::Value::Array &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { - Reflector::push(std::get<0>(tuple), value, allocator); + JsonReflector::push(std::get<0>(tuple), value, allocator); } }; } // namespace Detail @@ -517,14 +517,14 @@ template struct TuplePullHelper { static void pull(Tuple &tuple, const RAPIDJSON_NAMESPACE::Value::Array &value, JsonDeserializationErrors *errors) { TuplePullHelper::pull(tuple, value, errors); - Reflector::pull(std::get(tuple), value[N - 1], errors); + JsonReflector::pull(std::get(tuple), value[N - 1], errors); } }; template struct TuplePullHelper { static void pull(Tuple &tuple, const RAPIDJSON_NAMESPACE::Value::Array &value, JsonDeserializationErrors *errors) { - Reflector::pull(std::get<0>(tuple), value[0], errors); + JsonReflector::pull(std::get<0>(tuple), value[0], errors); } }; } // namespace Detail @@ -716,7 +716,7 @@ template Type fromJson(const std::string &json) return fromJson(json.data(), json.size()); } -} // namespace Reflector +} // namespace JsonReflector } // namespace ReflectiveRapidJSON #endif // REFLECTIVE_RAPIDJSON_JSON_REFLECTOR_H diff --git a/lib/json/serializable.h b/lib/json/serializable.h index eb946d6..4b16b23 100644 --- a/lib/json/serializable.h +++ b/lib/json/serializable.h @@ -37,7 +37,7 @@ template struct JsonSerializable { */ template void JsonSerializable::push(RAPIDJSON_NAMESPACE::Value &container) { - return Reflector::push(*this, container); + return JsonReflector::push(*this, container); } /*! @@ -45,7 +45,7 @@ template void JsonSerializable::push(RAPIDJSON_NAMESPACE:: */ template void JsonSerializable::push(RAPIDJSON_NAMESPACE::Value &container, const char *name) { - return Reflector::push(*this, name, container); + return JsonReflector::push(*this, name, container); } /*! @@ -54,7 +54,7 @@ template void JsonSerializable::push(RAPIDJSON_NAMESPACE:: */ template RAPIDJSON_NAMESPACE::StringBuffer JsonSerializable::toJson() const { - return Reflector::toJson(static_cast(*this)); + return JsonReflector::toJson(static_cast(*this)); } /*! @@ -62,7 +62,7 @@ template RAPIDJSON_NAMESPACE::StringBuffer JsonSerializable Type JsonSerializable::fromJson(const char *json, std::size_t jsonSize, JsonDeserializationErrors *errors) { - return Reflector::fromJson(json, jsonSize, errors); + return JsonReflector::fromJson(json, jsonSize, errors); } /*! @@ -70,7 +70,7 @@ template Type JsonSerializable::fromJson(const char *json, */ template Type JsonSerializable::fromJson(const char *json, JsonDeserializationErrors *errors) { - return Reflector::fromJson(json, std::strlen(json), errors); + return JsonReflector::fromJson(json, std::strlen(json), errors); } /*! @@ -78,7 +78,7 @@ template Type JsonSerializable::fromJson(const char *json, */ template Type JsonSerializable::fromJson(const std::string &json, JsonDeserializationErrors *errors) { - return Reflector::fromJson(json.data(), json.size(), errors); + return JsonReflector::fromJson(json.data(), json.size(), errors); } /*! diff --git a/lib/tests/jsonreflector.cpp b/lib/tests/jsonreflector.cpp index 3440776..fe513a4 100644 --- a/lib/tests/jsonreflector.cpp +++ b/lib/tests/jsonreflector.cpp @@ -63,7 +63,7 @@ enum class SomeEnumClass { // pretend serialization code for structs has been generated namespace ReflectiveRapidJSON { -namespace Reflector { +namespace JsonReflector { template <> inline void push(const TestObject &reflectable, Value::Object &value, Document::AllocatorType &allocator) { @@ -134,9 +134,9 @@ inline void pull(NestingArray &reflectable, const GenericValue(foo, array, alloc); - Reflector::push("bar", array, alloc); + JsonReflector::push(foo, array, alloc); + JsonReflector::push("bar", array, alloc); // number - Reflector::push(25, array, alloc); - Reflector::push(12.5, array, alloc); + JsonReflector::push(25, array, alloc); + JsonReflector::push(12.5, array, alloc); // enum - Reflector::push(SomeEnumItem2, array, alloc); - Reflector::push(SomeEnumClass::Item2, array, alloc); - Reflector::push(SomeEnumClass::Item3, array, alloc); + JsonReflector::push(SomeEnumItem2, array, alloc); + JsonReflector::push(SomeEnumClass::Item2, array, alloc); + JsonReflector::push(SomeEnumClass::Item3, array, alloc); // array - Reflector::push>({ "foo1", "bar1" }, array, alloc); - Reflector::push>({ "foo2", "bar2" }, array, alloc); - Reflector::push>({ "foo3", "bar3" }, array, alloc); - Reflector::push>(make_tuple(2, 413.0), array, alloc); + JsonReflector::push>({ "foo1", "bar1" }, array, alloc); + JsonReflector::push>({ "foo2", "bar2" }, array, alloc); + JsonReflector::push>({ "foo3", "bar3" }, array, alloc); + JsonReflector::push>(make_tuple(2, 413.0), array, alloc); // boolean - Reflector::push(true, array, alloc); - Reflector::push(false, array, alloc); + JsonReflector::push(true, array, alloc); + JsonReflector::push(false, array, alloc); StringBuffer strbuf; Writer jsonWriter(strbuf); @@ -278,13 +278,13 @@ void JsonReflectorTests::testDeserializePrimitives() float float1 = 0.0; double double1 = 0.0; JsonDeserializationErrors errors; - Reflector::pull(str1, array, &errors); - Reflector::pull(int1, array, &errors); - Reflector::pull(float1, array, &errors); - Reflector::pull(str2, array, &errors); - Reflector::pull(bool1, array, &errors); - Reflector::pull(double1, array, &errors); - Reflector::pull(bool2, array, &errors); + JsonReflector::pull(str1, array, &errors); + JsonReflector::pull(int1, array, &errors); + JsonReflector::pull(float1, array, &errors); + JsonReflector::pull(str2, array, &errors); + JsonReflector::pull(bool1, array, &errors); + JsonReflector::pull(double1, array, &errors); + JsonReflector::pull(bool2, array, &errors); CPPUNIT_ASSERT_EQUAL(0_st, errors.size()); CPPUNIT_ASSERT_EQUAL("a"s, str1); @@ -297,7 +297,7 @@ void JsonReflectorTests::testDeserializePrimitives() // deserialize primitives as tuple tuple arrayAsTuple; - Reflector::pull(arrayAsTuple, doc, &errors); + JsonReflector::pull(arrayAsTuple, doc, &errors); CPPUNIT_ASSERT_EQUAL(0_st, errors.size()); CPPUNIT_ASSERT_EQUAL("a"s, get<0>(arrayAsTuple)); CPPUNIT_ASSERT_EQUAL(5, get<1>(arrayAsTuple)); @@ -307,7 +307,7 @@ void JsonReflectorTests::testDeserializePrimitives() CPPUNIT_ASSERT_EQUAL(4.125, get<5>(arrayAsTuple)); CPPUNIT_ASSERT_EQUAL(false, get<6>(arrayAsTuple)); tuple anotherTuple; - Reflector::pull(anotherTuple, doc, &errors); + JsonReflector::pull(anotherTuple, doc, &errors); CPPUNIT_ASSERT_EQUAL(1_st, errors.size()); CPPUNIT_ASSERT_EQUAL(JsonDeserializationErrorKind::ArraySizeMismatch, errors.front().kind); }