// file : cli/context.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2009 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file #ifndef CLI_CONTEXT_HXX #define CLI_CONTEXT_HXX #include #include #include #include #include // std::size_t #include #include "options.hxx" #include "semantics.hxx" #include "traversal.hxx" using std::endl; class context { public: typedef std::size_t size_t; typedef std::string string; typedef ::options options_type; private: struct data; cutl::shared_ptr data_; public: std::ostream& os; semantics::cli_unit& unit; options_type const& options; string const& inl; string const& opt_prefix; string const& opt_sep; typedef std::map reserved_name_map_type; reserved_name_map_type const& reserved_name_map; typedef std::set keyword_set_type; keyword_set_type const& keyword_set; private: struct data { string inl_; keyword_set_type keyword_set_; }; public: // Escape C++ keywords, reserved names, and illegal characters. // string escape (string const&) const; public: static string const& ename (semantics::nameable& n) { return n.context ().get ("name"); } static string const& emember (semantics::nameable& n) { return n.context ().get ("member"); } public: context (std::ostream&, semantics::cli_unit&, options_type const&); context (context&); private: context& operator= (context const&); }; // Standard namespace traverser. // struct namespace_: traversal::namespace_, context { namespace_ (context& c) : context (c) {} virtual void pre (type&); virtual void post (type&); }; #endif // CLI_CONTEXT_HXX