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
00030
00031
00032
00033
00034
00035
00036 #include "Identifiable.hpp"
00037
00038 #include <algorithm>
00039 #include <typeinfo>
00040
00041 #include <boost/serialization/extended_type_info.hpp>
00042 #include <boost/serialization/extended_type_info_typeid.hpp>
00043 #include <boost/serialization/extended_type_info_no_rtti.hpp>
00044 #include <boost/serialization/type_info_implementation.hpp>
00045
00046 std::string Identifiable::TidyTemplatedExportIdentifier(std::string identifier) const
00047 {
00048
00049 std::string::iterator end_pos = std::remove(identifier.begin(), identifier.end(), ' ');
00050 identifier.erase(end_pos, identifier.end());
00051
00052
00053 const std::string s_pack = "pack<void(";
00054 std::string::size_type i = identifier.find(s_pack);
00055 if (i != identifier.npos)
00056 {
00057 identifier.erase(i, s_pack.length());
00058 }
00059
00060
00061 const std::string s_open = "<";
00062 const std::string s_dash = "-";
00063 i = identifier.find(s_open);
00064 if (i != identifier.npos)
00065 {
00066 identifier.replace(i, s_open.length(), s_dash);
00067 }
00068
00069
00070 const std::string s_comma = ",";
00071 i = identifier.find(s_comma);
00072 while (i != identifier.npos)
00073 {
00074 identifier.replace(i, s_comma.length(), s_dash);
00075 i = identifier.find(s_comma, i);
00076 }
00077
00078
00079 const std::string s_end = ">)>::type";
00080 i = identifier.find(s_end);
00081 if (i != identifier.npos)
00082 {
00083 identifier.erase(i, s_end.length());
00084 }
00085
00086 return identifier;
00087 }
00088
00089 Identifiable::~Identifiable()
00090 {
00091 }
00092
00093 std::string Identifiable::GetIdentifier() const
00094 {
00095 std::string id;
00096 #if BOOST_VERSION >= 103700
00097 id = boost::serialization::type_info_implementation<Identifiable>::type::get_const_instance().get_derived_extended_type_info(*this)->get_key();
00098 #else
00099 id = boost::serialization::type_info_implementation<Identifiable>::type::get_derived_extended_type_info(*this)->get_key();
00100 #endif
00101 return TidyTemplatedExportIdentifier(id);
00102 }