mirror of
https://gitee.com/zyjblog/oatpp.git
synced 2024-12-22 22:16:37 +08:00
mapping::type. Rename ListMap --> PairList.
This commit is contained in:
parent
bd8330e06d
commit
eb116ef23b
@ -78,8 +78,8 @@ add_library(oatpp
|
||||
oatpp/core/data/mapping/type/Any.hpp
|
||||
oatpp/core/data/mapping/type/List.cpp
|
||||
oatpp/core/data/mapping/type/List.hpp
|
||||
oatpp/core/data/mapping/type/ListMap.cpp
|
||||
oatpp/core/data/mapping/type/ListMap.hpp
|
||||
oatpp/core/data/mapping/type/PairList.cpp
|
||||
oatpp/core/data/mapping/type/PairList.hpp
|
||||
oatpp/core/data/mapping/type/Object.cpp
|
||||
oatpp/core/data/mapping/type/Object.hpp
|
||||
oatpp/core/data/mapping/type/Primitive.cpp
|
||||
|
@ -129,15 +129,15 @@ namespace oatpp {
|
||||
typedef oatpp::data::mapping::type::AbstractList AbstractList;
|
||||
|
||||
/*
|
||||
* Mapping-Enables ListMap<String, Value>. &id:oatpp::data::mapping::type::ListMap;
|
||||
* Mapping-Enables PairList<String, Value>. &id:oatpp::data::mapping::type::PairList;
|
||||
*/
|
||||
template <class Value>
|
||||
using Fields = oatpp::data::mapping::type::ListMap<String, Value>;
|
||||
using Fields = oatpp::data::mapping::type::PairList<String, Value>;
|
||||
|
||||
/**
|
||||
* Abstract Fields
|
||||
*/
|
||||
typedef data::mapping::type::ListMapObjectWrapper<oatpp::String, oatpp::Void, data::mapping::type::__class::AbstractListMap> AbstractFields;
|
||||
typedef data::mapping::type::PairListObjectWrapper<oatpp::String, oatpp::Void, data::mapping::type::__class::AbstractPairList> AbstractFields;
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "./Type.hpp"
|
||||
|
||||
#include "./Primitive.hpp"
|
||||
#include "./ListMap.hpp"
|
||||
#include "./PairList.hpp"
|
||||
#include "./List.hpp"
|
||||
#include "./Vector.hpp"
|
||||
#include "./Any.hpp"
|
||||
@ -89,12 +89,16 @@ public:
|
||||
typedef oatpp::data::mapping::type::Float32 Float32;
|
||||
typedef oatpp::data::mapping::type::Float64 Float64;
|
||||
typedef oatpp::data::mapping::type::Boolean Boolean;
|
||||
|
||||
template <class T>
|
||||
using Vector = oatpp::data::mapping::type::Vector<T>;
|
||||
|
||||
template <class T>
|
||||
using List = oatpp::data::mapping::type::List<T>;
|
||||
|
||||
template <class Value>
|
||||
using Fields = oatpp::data::mapping::type::ListMap<String, Value>;
|
||||
using Fields = oatpp::data::mapping::type::PairList<String, Value>;
|
||||
|
||||
protected:
|
||||
|
||||
static Type::Properties* Z__CLASS_EXTEND(Type::Properties* properties, Type::Properties* extensionProperties) {
|
||||
|
@ -22,12 +22,12 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "ListMap.hpp"
|
||||
#include "PairList.hpp"
|
||||
|
||||
namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
||||
namespace __class {
|
||||
const ClassId AbstractListMap::CLASS_ID("ListMap");
|
||||
const ClassId AbstractPairList::CLASS_ID("PairList");
|
||||
}
|
||||
|
||||
}}}}
|
@ -22,8 +22,8 @@
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef oatpp_data_mapping_type_ListMap_hpp
|
||||
#define oatpp_data_mapping_type_ListMap_hpp
|
||||
#ifndef oatpp_data_mapping_type_PairList_hpp
|
||||
#define oatpp_data_mapping_type_PairList_hpp
|
||||
|
||||
#include "./Type.hpp"
|
||||
|
||||
@ -35,7 +35,7 @@ namespace oatpp { namespace data { namespace mapping { namespace type {
|
||||
|
||||
namespace __class {
|
||||
|
||||
class AbstractListMap {
|
||||
class AbstractPairList {
|
||||
public:
|
||||
static const ClassId CLASS_ID;
|
||||
public:
|
||||
@ -48,32 +48,32 @@ public:
|
||||
};
|
||||
|
||||
template<class Key, class Value>
|
||||
class ListMap;
|
||||
class PairList;
|
||||
|
||||
}
|
||||
|
||||
template<class Key, class Value, class C>
|
||||
class ListMapObjectWrapper : public type::ObjectWrapper<std::list<std::pair<Key, Value>>, C> {
|
||||
class PairListObjectWrapper : public type::ObjectWrapper<std::list<std::pair<Key, Value>>, C> {
|
||||
public:
|
||||
typedef std::list<std::pair<Key, Value>> TemplateObjectType;
|
||||
typedef C TemplateObjectClass;
|
||||
public:
|
||||
|
||||
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(ListMapObjectWrapper, TemplateObjectType, TemplateObjectClass)
|
||||
OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(PairListObjectWrapper, TemplateObjectType, TemplateObjectClass)
|
||||
|
||||
ListMapObjectWrapper(std::initializer_list<std::pair<Key, Value>> ilist)
|
||||
PairListObjectWrapper(std::initializer_list<std::pair<Key, Value>> ilist)
|
||||
: type::ObjectWrapper<TemplateObjectType, TemplateObjectClass>(std::make_shared<TemplateObjectType>(ilist))
|
||||
{}
|
||||
|
||||
static ListMapObjectWrapper createShared() {
|
||||
static PairListObjectWrapper createShared() {
|
||||
return std::make_shared<TemplateObjectType>();
|
||||
}
|
||||
|
||||
ListMapObjectWrapper& operator = (std::initializer_list<std::pair<Key, Value>> ilist) {
|
||||
PairListObjectWrapper& operator = (std::initializer_list<std::pair<Key, Value>> ilist) {
|
||||
this->m_ptr = std::make_shared<TemplateObjectType>(ilist);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Value& operator[] (const Key& key) const {
|
||||
auto& list = *(this->m_ptr.get());
|
||||
auto it = list.begin();
|
||||
@ -94,10 +94,10 @@ OATPP_DEFINE_OBJECT_WRAPPER_DEFAULTS(ListMapObjectWrapper, TemplateObjectType, T
|
||||
};
|
||||
|
||||
template<class Key, class Value>
|
||||
using ListMap = ListMapObjectWrapper<
|
||||
using PairList = PairListObjectWrapper<
|
||||
typename Key::__Wrapper,
|
||||
typename Value::__Wrapper,
|
||||
__class::ListMap<
|
||||
__class::PairList<
|
||||
typename Key::__Wrapper,
|
||||
typename Value::__Wrapper
|
||||
>
|
||||
@ -106,17 +106,17 @@ using ListMap = ListMapObjectWrapper<
|
||||
namespace __class {
|
||||
|
||||
template<class Key, class Value>
|
||||
class ListMap : public AbstractListMap {
|
||||
class PairList : public AbstractPairList {
|
||||
private:
|
||||
|
||||
class PolymorphicDispatcher : public AbstractPolymorphicDispatcher {
|
||||
public:
|
||||
|
||||
void addPolymorphicItem(const type::Void& object, const type::Void& key, const type::Void& value) const override {
|
||||
const auto& map = object.staticCast<type::ListMap<Key, Value>>();
|
||||
const auto& map = object.staticCast<type::PairList<Key, Value>>();
|
||||
const auto& k = key.staticCast<Key>();
|
||||
const auto& v = value.staticCast<Value>();
|
||||
map[k] = v;
|
||||
map->push_back({k, v});
|
||||
}
|
||||
|
||||
};
|
||||
@ -128,7 +128,7 @@ private:
|
||||
}
|
||||
|
||||
static Type createType() {
|
||||
Type type(__class::AbstractListMap::CLASS_ID, nullptr, &creator, nullptr, new PolymorphicDispatcher());
|
||||
Type type(__class::AbstractPairList::CLASS_ID, nullptr, &creator, nullptr, new PolymorphicDispatcher());
|
||||
type.params.push_back(Key::Class::getType());
|
||||
type.params.push_back(Value::Class::getType());
|
||||
return type;
|
||||
@ -147,4 +147,4 @@ public:
|
||||
|
||||
}}}}
|
||||
|
||||
#endif // oatpp_data_mapping_type_ListMap_hpp
|
||||
#endif // oatpp_data_mapping_type_PairList_hpp
|
@ -55,7 +55,7 @@ Deserializer::Deserializer(const std::shared_ptr<Config>& config)
|
||||
setDeserializerMethod(oatpp::data::mapping::type::__class::Boolean::CLASS_ID, &Deserializer::deserializeBoolean);
|
||||
|
||||
setDeserializerMethod(oatpp::data::mapping::type::__class::AbstractList::CLASS_ID, &Deserializer::deserializeList);
|
||||
setDeserializerMethod(oatpp::data::mapping::type::__class::AbstractListMap::CLASS_ID, &Deserializer::deserializeFieldsMap);
|
||||
setDeserializerMethod(oatpp::data::mapping::type::__class::AbstractPairList::CLASS_ID, &Deserializer::deserializeFieldsMap);
|
||||
setDeserializerMethod(oatpp::data::mapping::type::__class::AbstractObject::CLASS_ID, &Deserializer::deserializeObject);
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ public:
|
||||
typedef oatpp::data::mapping::type::Object Object;
|
||||
typedef oatpp::String String;
|
||||
|
||||
typedef oatpp::data::mapping::type::ListMap<String, oatpp::Void> AbstractFieldsMap;
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ Serializer::Serializer(const std::shared_ptr<Config>& config)
|
||||
|
||||
setSerializerMethod(oatpp::data::mapping::type::__class::AbstractObject::CLASS_ID, &Serializer::serializeObject);
|
||||
setSerializerMethod(oatpp::data::mapping::type::__class::AbstractList::CLASS_ID, &Serializer::serializeList);
|
||||
setSerializerMethod(oatpp::data::mapping::type::__class::AbstractListMap::CLASS_ID, &Serializer::serializeFieldsMap);
|
||||
setSerializerMethod(oatpp::data::mapping::type::__class::AbstractPairList::CLASS_ID, &Serializer::serializeFieldsMap);
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include "oatpp/parser/json/Beautifier.hpp"
|
||||
|
||||
#include "oatpp/core/data/mapping/type/ListMap.hpp"
|
||||
#include "oatpp/core/data/mapping/type/PairList.hpp"
|
||||
#include "oatpp/core/data/mapping/type/List.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Object.hpp"
|
||||
#include "oatpp/core/data/mapping/type/Primitive.hpp"
|
||||
@ -52,9 +52,6 @@ public:
|
||||
|
||||
typedef oatpp::data::mapping::type::Object Object;
|
||||
typedef oatpp::String String;
|
||||
|
||||
typedef oatpp::data::mapping::type::ListMap<String, oatpp::Void> AbstractFieldsMap;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Serializer config.
|
||||
|
@ -126,62 +126,62 @@ public:
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::String;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::String String;
|
||||
typedef oatpp::String String;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Int8;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Int8 Int8;
|
||||
typedef oatpp::Int8 Int8;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::UInt8;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::UInt8 UInt8;
|
||||
typedef oatpp::UInt8 UInt8;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Int16;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Int16 Int16;
|
||||
typedef oatpp::Int16 Int16;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::UInt16;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::UInt16 UInt16;
|
||||
typedef oatpp::UInt16 UInt16;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Int32;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Int32 Int32;
|
||||
typedef oatpp::Int32 Int32;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::UInt32;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::UInt32 UInt32;
|
||||
typedef oatpp::UInt32 UInt32;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Int64;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Int64 Int64;
|
||||
typedef oatpp::Int64 Int64;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::UInt64;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::UInt64 UInt64;
|
||||
typedef oatpp::UInt64 UInt64;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Float32;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Float32 Float32;
|
||||
typedef oatpp::Float32 Float32;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:atpp::data::mapping::type::Float64;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Float64 Float64;
|
||||
typedef oatpp::Float64 Float64;
|
||||
|
||||
/**
|
||||
* Convenience typedef for &id:oatpp::data::mapping::type::Boolean;.
|
||||
*/
|
||||
typedef oatpp::data::mapping::type::Boolean Boolean;
|
||||
typedef oatpp::Boolean Boolean;
|
||||
|
||||
/*
|
||||
* Convenience typedef for std::function<std::shared_ptr<Endpoint::Info>()>.
|
||||
@ -189,9 +189,10 @@ public:
|
||||
typedef std::function<std::shared_ptr<Endpoint::Info>()> EndpointInfoBuilder;
|
||||
|
||||
template <class T>
|
||||
using List = oatpp::data::mapping::type::List<T>;
|
||||
using List = oatpp::List<T>;
|
||||
|
||||
template <class Value>
|
||||
using Fields = oatpp::data::mapping::type::ListMap<String, Value>;
|
||||
using Fields = oatpp::Fields<Value>;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -112,7 +112,7 @@ void TypeTest::onRun() {
|
||||
OATPP_ASSERT(obj->field_list_boolean.valueType->classId.id == oatpp::data::mapping::type::__class::AbstractList::CLASS_ID.id);
|
||||
|
||||
OATPP_LOGV(TAG, "type: '%s'", obj->field_map_string_string.valueType->classId.name);
|
||||
OATPP_ASSERT(obj->field_map_string_string.valueType->classId.id == oatpp::data::mapping::type::__class::AbstractListMap::CLASS_ID.id);
|
||||
OATPP_ASSERT(obj->field_map_string_string.valueType->classId.id == oatpp::data::mapping::type::__class::AbstractPairList::CLASS_ID.id);
|
||||
|
||||
OATPP_LOGV(TAG, "type: '%s'", obj->obj1.valueType->classId.name);
|
||||
OATPP_ASSERT(obj->obj1.valueType->classId.id == oatpp::data::mapping::type::__class::AbstractObject::CLASS_ID.id);
|
||||
|
Loading…
Reference in New Issue
Block a user