Identifiable.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "Identifiable.hpp"
00030
00031 #include <algorithm>
00032 #include <typeinfo>
00033
00034 #include <boost/serialization/extended_type_info.hpp>
00035 #include <boost/serialization/extended_type_info_typeid.hpp>
00036 #include <boost/serialization/extended_type_info_no_rtti.hpp>
00037 #include <boost/serialization/type_info_implementation.hpp>
00038
00039 std::string Identifiable::TidyTemplatedExportIdentifier(std::string identifier) const
00040 {
00041
00042 std::string::iterator end_pos = std::remove(identifier.begin(), identifier.end(), ' ');
00043 identifier.erase(end_pos, identifier.end());
00044
00045
00046 const std::string s_pack = "pack<void(";
00047 std::string::size_type i = identifier.find(s_pack);
00048 if (i != identifier.npos)
00049 {
00050 identifier.erase(i, s_pack.length());
00051 }
00052
00053
00054 const std::string s_open = "<";
00055 const std::string s_dash = "-";
00056 i = identifier.find(s_open);
00057 if (i != identifier.npos)
00058 {
00059 identifier.replace(i, s_open.length(), s_dash);
00060 }
00061
00062
00063 const std::string s_comma = ",";
00064 i = identifier.find(s_comma);
00065 assert( i == identifier.npos );
00066
00074
00075 const std::string s_end = ">)>::type";
00076 i = identifier.find(s_end);
00077 if (i != identifier.npos)
00078 {
00079 identifier.erase(i, s_end.length());
00080 }
00081
00082 return identifier;
00083 }
00084
00085 Identifiable::~Identifiable()
00086 {
00087 }
00088
00089 std::string Identifiable::GetIdentifier() const
00090 {
00091 std::string id;
00092 #if BOOST_VERSION >= 103700
00093 id = boost::serialization::type_info_implementation<Identifiable>::type::get_const_instance().get_derived_extended_type_info(*this)->get_key();
00094 #else
00095 id = boost::serialization::type_info_implementation<Identifiable>::type::get_derived_extended_type_info(*this)->get_key();
00096 #endif
00097 return TidyTemplatedExportIdentifier(id);
00098 }