4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Traits public header */
31 #include <boost/intrusive_ptr.hpp>
32 #include "../Utils/intrusive_refcount.hh"
37 //#include "Traits.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
43 /** \brief Customize return value formating
45 ReturnValueTraits provides return value formatting. The default implementation provided here
46 will just write the value to the output stream.
48 To customize this behavior for some type, specialize this class for the type.
50 The output should \e not end in a newline since one is added automatically.
53 struct ReturnValueTraits
57 static void format(Type const & value, std::ostream & os);
58 ///< Write \a value to \a os
62 void senf_console_format_value(Type const & value, std::ostream & os);
64 /** \brief Customize argument parsing
66 ArgumentTraits provides argument parsing, Additionally, this class provides a way to get a
67 string-description of a type and to convert a value back into it's string representation
68 used to display default values.
70 The default implementation provided here will use \c boost::lexical_cast and thereby \c
71 iostreams to convert an argument consisting of a single input token into the required
72 type. Types are named by returning the last component of the fully scoped name (e.g. \c
73 "string" for \c std::string). Values are formatted again using \c boost::lexical_cast.
75 To customize this behavior for some type, specialize this class for the type.
82 static void parse(ParseCommandInfo::TokensRange const & tokens, Type & out);
83 ///< Parse token range into value
84 /**< This function needs to parse \a tokens and write the
85 parsed value into \a out. This function needs to parse
86 the \e complete list of tokens, additional tokens must
87 be considered as syntax error.
88 \throws SyntaxErrorException
89 \param[in] tokens tokens to parse
90 \param[out] out parsed value */
92 static std::string description(); ///< String description of type
93 /**< Returns the string description of \a Type. Used to
94 generate online help. */
95 static std::string str(Type const & value); ///< Stringify value
96 /**< To show default values in the online help, this
97 function converts a value back into a one-line string
98 representation. The default implementation uses the
99 ReturnValueTraits for this conversion. */
102 template <class Type>
103 void senf_console_parse_argument(ParseCommandInfo::TokensRange const & tokens, Type & out);
105 # define SENF_CONSOLE_REGISTER_ENUM(Type, Values) SENF_CONSOLE_REGISTER_ENUM_(Type, Values)
109 ///////////////////////////////hh.e////////////////////////////////////////
110 //#include "Traits.cci"
111 //#include "Traits.ct"
112 #include "Traits.cti"
119 // comment-column: 40
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"