typedisplay.hh
Go to the documentation of this file.
00001 #ifndef TYPELIB_DISPLAYVISITOR_HH
00002 #define TYPELIB_DISPLAYVISITOR_HH
00003 
00004 #include "typevisitor.hh"
00005 #include <iosfwd>
00006 
00007 namespace Typelib
00008 {
00013     class TypeDisplayVisitor : public TypeVisitor
00014     {
00015         template<typename T>
00016         void display_compound(T const& type, char const* compound_name);
00017 
00018         std::ostream& m_stream;
00019         std::string   m_indent;
00020 
00021     protected:
00022         bool visit_(NullType const& type);
00023         bool visit_(OpaqueType const& type);
00024         bool visit_(Compound const& type);
00025         bool visit_(Compound const& type, Field const& field);
00026         
00027         bool visit_(Numeric const& type);
00028         bool visit_(Enum const& type);
00029        
00030         bool visit_(Pointer const& type);
00031         bool visit_(Array const& type);
00032 
00033     public:
00034         TypeDisplayVisitor(std::ostream& stream, std::string const& base_indent);
00035     };
00036 
00037     namespace details
00038     {
00039         struct do_type_display
00040         {
00041             Type const& type;
00042             std::string indent;
00043             do_type_display(Type const& type_, std::string const& indent_ = "")
00044                 : type(type_), indent(indent_) {}
00045         };
00046         inline std::ostream& operator << (std::ostream& stream, do_type_display display)
00047         {
00048             TypeDisplayVisitor visitor(stream, display.indent);
00049             visitor.apply(display.type);
00050             return stream;
00051         }
00052     }
00053 
00062     inline details::do_type_display type_display(Type const& type, std::string const& indent = "")
00063     { return details::do_type_display(type, indent); }
00064 
00069     inline std::ostream& operator << (std::ostream& stream, Type const& type)
00070     { return stream << type_display(type); }
00071 }
00072 
00073 #endif
00074 


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Sat Jun 8 2019 18:49:22