#ifndef BOOST_UNITS_UTILITY_HPP #define BOOST_UNITS_UTILITY_HPP #include #include #include #include #include #include #include #ifdef MCS_USE_BOOST_REGEX_DEMANGLING #include #define MCS_USE_DEMANGLING #endif // MCS_USE_BOOST_REGEX_DEMANGLING #ifdef MCS_USE_DEMANGLING #ifdef __GNUC__ #include #endif // __GNUC__ namespace std { inline std::string demangle(const char* name) { #ifdef __GNUC__ // need to demangle C++ symbols char* realname; std::size_t len; int stat; realname = abi::__cxa_demangle(name,NULL,&len,&stat); if (realname != NULL) { const std::string out(realname); free(realname); return out; } return std::string("demangle :: error - unable to demangle specified symbol"); #else return name; #endif } } // namespace std namespace boost { namespace units { template std::string simplify_mpl_typename(const L& source) { const std::string demangled = std::demangle(typeid(source).name()); #ifdef MCS_USE_BOOST_REGEX_DEMANGLING boost::regex ns_regex("boost::|units::|mpl::|, mpl_::na|mpl_::"), l_end_regex(", l_end"), case_regex("[0-9]l"); const std::string tmp1(boost::regex_replace(demangled,ns_regex,"")), tmp2(boost::regex_replace(tmp1,l_end_regex," ")); return boost::regex_replace(tmp2,case_regex,"\\U$&\\E"); #else // MCS_USE_BOOST_REGEX_DEMANGLING return demangled; #endif // MCS_USE_BOOST_REGEX_DEMANGLING } } // namespace units } // namespace boost #else // MCS_USE_DEMANGLING namespace std { inline std::string demangle(const char* name) { return name; } } // namespace std namespace boost { namespace units { template std::string simplify_mpl_typename(const L& source) { return std::string(typeid(source).name()); } } // namespace units } // namespace boost #endif // MCS_USE_DEMANGLING #endif // BOOST_UNITS_UTILITY_HPP