]> git.mxchange.org Git - simgear.git/blob - simgear/misc/strutils.hxx
- new FSF addresses
[simgear.git] / simgear / misc / strutils.hxx
1 /**
2  * \file strutils.hxx
3  * String utilities.
4  */
5
6 // Written by Bernie Bright, started 1998
7 //
8 // Copyright (C) 1998  Bernie Bright - bbright@bigpond.net.au
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Library General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 // Library General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23 //
24 // $Id$
25
26
27 #ifndef STRUTILS_H
28 #define STRUTILS_H
29
30 #include <simgear/compiler.h>
31
32 #include STL_STRING
33
34 #include <vector>
35 SG_USING_STD(vector);
36
37 #ifdef SG_HAVE_STD_INCLUDES
38 #  include <cstdlib>
39 #else
40 #  include <stdlib.h>
41 #endif
42
43 SG_USING_STD(string);
44
45 namespace simgear {
46     namespace strutils {
47
48 //      /** 
49 //       * atof() wrapper for "string" type
50 //       */
51 //      inline double
52 //      atof( const string& str )
53 //      {
54 //          return ::atof( str.c_str() );
55 //      }
56
57 //      /**
58 //       * atoi() wrapper for "string" type
59 //       */
60 //      inline int
61 //      atoi( const string& str )
62 //      {
63 //          return ::atoi( str.c_str() );
64 //      }
65
66         /**
67          * Strip leading and/or trailing whitespace from s.
68          * @param s String to strip.
69          * @return The stripped string.
70          */
71         string lstrip( const string& s );
72         string rstrip( const string& s );
73         string strip( const string& s );
74
75         /**
76          * Split a string into a words using 'sep' as the delimiter string.
77          * Produces a result similar to the perl and python functions of the
78          * same name.
79          * 
80          * @param s The string to split into words,
81          * @param sep Word delimiters.  If not specified then any whitespace is a separator,
82          * @param maxsplit If given, splits at no more than maxsplit places,
83          * resulting in at most maxsplit+1 words.
84          * @return Array of words.
85          */
86         vector<string>
87         split( const string& s,
88                const char* sep = 0,
89                int maxsplit = 0 );
90
91     } // end namespace strutils
92 } // end namespace simgear
93
94 #endif // STRUTILS_H
95