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
00040 std::string Identifiable::TidyTemplatedExportIdentifier(std::string identifier) const
00041 {
00042
00043 std::string::iterator end_pos = std::remove(identifier.begin(), identifier.end(), ' ');
00044 identifier.erase(end_pos, identifier.end());
00045
00046
00047 const std::string s_pack = "pack<void(";
00048 std::string::size_type i = identifier.find(s_pack);
00049 if (i != identifier.npos)
00050 {
00051 identifier.erase(i, s_pack.length());
00052 }
00053
00054
00055 const std::string s_open = "<";
00056 const std::string s_dash = "-";
00057 i = identifier.find(s_open);
00058 if (i != identifier.npos)
00059 {
00060 identifier.replace(i, s_open.length(), s_dash);
00061 }
00062
00063
00064 const std::string s_comma = ",";
00065 i = identifier.find(s_comma);
00066 assert( i == identifier.npos );
00067
00075
00076 const std::string s_end = ">)>::type";
00077 i = identifier.find(s_end);
00078 if (i != identifier.npos)
00079 {
00080 identifier.erase(i, s_end.length());
00081 }
00082
00083 return identifier;
00084 }
00085
00086 Identifiable::~Identifiable()
00087 {
00088 }
00089
00090 std::string Identifiable::GetIdentifier() const
00091 {
00092 std::string id;
00093 #if BOOST_VERSION >= 103700
00094 id = boost::serialization::type_info_implementation<Identifiable>::type::get_const_instance().get_derived_extended_type_info(*this)->get_key();
00095 #else
00096 id = boost::serialization::type_info_implementation<Identifiable>::type::get_derived_extended_type_info(*this)->get_key();
00097 #endif
00098 return TidyTemplatedExportIdentifier(id);
00099 }