switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / String.hh
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief String public header */
30
31 #ifndef HH_SENF_Utils_String_
32 #define HH_SENF_Utils_String_ 1
33
34 // Custom includes
35 #include <string>
36
37 //#include "String.mpp"
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39
40 namespace senf {
41
42     /** \brief Join string range with separator into single string
43
44         This utility will build string by joining all elements of \a range into a single string
45         using \a sep as separator. The \a range may contain values of any streamable type.
46      */
47     template <class ForwardReadableRange>
48     std::string stringJoin(ForwardReadableRange const & range, std::string sep);
49
50     /** \brief Get string representation
51
52         Returns the result of streaming the argument into a standard library string-based
53         stream and then out as a std::string object. The conversion is done with
54         <tt>boost::lexical_cast</tt>. The call is equivalent to
55         <pre>
56             boost::lexical_cast<std::string>(t);
57         </pre>
58         \pre
59             <tt>t</tt> must be <i>OutputStreamable</i>,
60                 meaning that an <tt>operator\<\<</tt> is defined\n
61             <tt>t</tt> must be <i>CopyConstructible</i>
62
63         \see <a href="http://www.boost.org/doc/libs/release/libs/conversion/lexical_cast.htm">
64             boost::lexical_cast</a>
65      */
66     template <class T>
67     std::string str(T const & t);
68
69     template <class Target, class Source>
70     Target lexical_cast(Source const & arg);
71
72     namespace detail { template <class Target> class lexical_caster; }
73
74     template <class Target>
75     detail::lexical_caster<Target> lexical_cast();
76 }
77
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 //#include "String.cci"
80 #include "String.ct"
81 #include "String.cti"
82 #endif
83
84 \f
85 // Local Variables:
86 // mode: c++
87 // fill-column: 100
88 // comment-column: 40
89 // c-file-style: "senf"
90 // indent-tabs-mode: nil
91 // ispell-local-dictionary: "american"
92 // compile-command: "scons -u test"
93 // End: