]> git.mxchange.org Git - simgear.git/blob - simgear/misc/strutils.hxx
Replace SG_USE_STD() by using std::
[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 <string>
33
34 #include <vector>
35 using std::vector;
36
37 #include <cstdlib>
38
39 using std::string;
40
41 namespace simgear {
42     namespace strutils {
43
44 //      /** 
45 //       * atof() wrapper for "string" type
46 //       */
47 //      inline double
48 //      atof( const string& str )
49 //      {
50 //          return ::atof( str.c_str() );
51 //      }
52
53 //      /**
54 //       * atoi() wrapper for "string" type
55 //       */
56 //      inline int
57 //      atoi( const string& str )
58 //      {
59 //          return ::atoi( str.c_str() );
60 //      }
61
62         /**
63          * Strip leading and/or trailing whitespace from s.
64          * @param s String to strip.
65          * @return The stripped string.
66          */
67         string lstrip( const string& s );
68         string rstrip( const string& s );
69         string strip( const string& s );
70
71         /**
72          * Split a string into a words using 'sep' as the delimiter string.
73          * Produces a result similar to the perl and python functions of the
74          * same name.
75          * 
76          * @param s The string to split into words,
77          * @param sep Word delimiters.  If not specified then any whitespace is a separator,
78          * @param maxsplit If given, splits at no more than maxsplit places,
79          * resulting in at most maxsplit+1 words.
80          * @return Array of words.
81          */
82         vector<string>
83         split( const string& s,
84                const char* sep = 0,
85                int maxsplit = 0 );
86
87     } // end namespace strutils
88 } // end namespace simgear
89
90 #endif // STRUTILS_H
91