|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67125 - sandbox/configurator/boost/configurator/detail
From: for.dshevchenko_at_[hidden]
Date: 2010-12-08 23:57:50
Author: dshevchenko
Date: 2010-12-08 23:57:49 EST (Wed, 08 Dec 2010)
New Revision: 67125
URL: http://svn.boost.org/trac/boost/changeset/67125
Log:
Type name adding
Added:
sandbox/configurator/boost/configurator/detail/type_name.hpp (contents, props changed)
Added: sandbox/configurator/boost/configurator/detail/type_name.hpp
==============================================================================
--- (empty file)
+++ sandbox/configurator/boost/configurator/detail/type_name.hpp 2010-12-08 23:57:49 EST (Wed, 08 Dec 2010)
@@ -0,0 +1,72 @@
+// detail/type_name.hpp
+// ~~~~~~~~~~~~~~~~~~~~
+//
+// Copyright (C) 2010 Denis Shevchenko (for @ dshevchenko.biz)
+//
+// Distributed under the Boost Software License, version 1.0
+// (see http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_CONFIGURATOR_TYPE_NAME_HPP
+#define BOOST_CONFIGURATOR_TYPE_NAME_HPP
+
+#include <map>
+#include <string>
+
+namespace boost {
+
+/// \namespace cf
+/// \brief Main namespace of library.
+namespace cf {
+
+/// \namespace cf::detail
+/// \brief Details of realization.
+namespace detail {
+
+class type_name {
+private:
+ typedef std::map
+ <
+ const std::string // typeid.name()
+ , const std::string // type name
+ >
+ type_names;
+public:
+ type_name() {
+ using namespace boost::assign;
+ insert( names )( typeid( bool ).name(), "bool" )
+ ( typeid( char ).name(), "char" )
+ ( typeid( signed char ).name(), "signed char" )
+ ( typeid( unsigned char ).name(), "unsigned char" )
+ ( typeid( int ).name(), "int" )
+ ( typeid( signed int ).name(), "signed int" )
+ ( typeid( unsigned int ).name(), "unsigned int" )
+ ( typeid( short int ).name(), "short int" )
+ ( typeid( long int ).name(), "long int" )
+ ( typeid( unsigned short int ).name(), "unsigned short int" )
+ ( typeid( unsigned long int ).name(), "unsigned long int" )
+ ( typeid( signed short int ).name(), "signed short int" )
+ ( typeid( signed long int ).name(), "signed long int" )
+ ( typeid( float ).name(), "float" )
+ ( typeid( double ).name(), "double" )
+ ( typeid( long double ).name(), "long double" )
+ ( typeid( std::string ).name(), "std::string" )
+ ;
+ }
+private:
+ type_names names;
+public:
+ template< typename Type >
+ std::string name_of() {
+ std::string type_name = "<unknown>";
+ try {
+ type_name = "<" + names.at( typeid( Type ).name() ) + ">";
+ } catch ( const std::exception& /* exc */ ) {}
+ return type_name;
+ }
+};
+
+} // namespace detail
+} // namespace cf
+} // namespace boost
+
+#endif // BOOST_CONFIGURATOR_TYPE_NAME_HPP
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk