22 #ifndef TypeHelper20110405H
23 #define TypeHelper20110405H
27 #include <boost/shared_ptr.hpp>
28 #include <boost/version.hpp>
30 #include "protobuf_cpp_type_helpers.h"
34 class FieldCodecManager;
43 static boost::shared_ptr<FromProtoTypeBase> find(google::protobuf::FieldDescriptor::Type type);
44 static boost::shared_ptr<FromProtoCppTypeBase> find(
const google::protobuf::FieldDescriptor* field)
46 if(field->cpp_type() == google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE)
47 return find(field->message_type());
49 return find(field->cpp_type());
52 static boost::shared_ptr<FromProtoCppTypeBase> find(
const google::protobuf::Descriptor* desc)
54 return find(google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE,
58 static boost::shared_ptr<FromProtoCppTypeBase> find(google::protobuf::FieldDescriptor::CppType cpptype,
const std::string& type_name =
"");
61 friend class ::dccl::FieldCodecManager;
62 template<
typename ProtobufMessage>
65 custom_message_map_.insert(std::make_pair(ProtobufMessage::descriptor()->full_name(),
68 template<
typename ProtobufMessage>
71 custom_message_map_.erase(ProtobufMessage::descriptor()->full_name());
84 custom_message_map_.clear();
92 #if BOOST_VERSION >= 107000
94 friend void boost::checked_delete(T*) BOOST_NOEXCEPT;
97 friend void boost::checked_delete(T*);
99 static boost::shared_ptr<TypeHelper> inst_;
101 typedef std::map<google::protobuf::FieldDescriptor::Type,
102 boost::shared_ptr<FromProtoTypeBase> > TypeMap;
103 static TypeMap type_map_;
105 typedef std::map<google::protobuf::FieldDescriptor::CppType,
106 boost::shared_ptr<FromProtoCppTypeBase> > CppTypeMap;
107 static CppTypeMap cpptype_map_;
109 typedef std::map<std::string,
110 boost::shared_ptr<FromProtoCppTypeBase> > CustomMessageMap;
111 static CustomMessageMap custom_message_map_;