]> git.mxchange.org Git - simgear.git/blob - simgear/misc/strutils.hxx
Updates to build system to better support automake-1.5
[simgear.git] / simgear / misc / strutils.hxx
1 /**
2  * \file strutils.hxx
3  * String utilities.
4  */
5
6 // Written by Bernie Bright, 1998
7 //
8 // Copyright (C) 1998  Bernie Bright - bbright@c031.aone.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 Library General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA  02111-1307, USA.
24 //
25 // $Id$
26
27
28 #ifndef STRUTILS_H
29 #define STRUTILS_H
30
31 #include <simgear/compiler.h>
32
33 #include STL_STRING
34
35 #ifdef SG_HAVE_STD_INCLUDES
36 #  include <cstdlib>
37 #else
38 #  include <stdlib.h>
39 #endif
40
41 SG_USING_STD(string);
42
43
44 /** Default characters to remove. */
45 extern const string whitespace;
46
47 /** Returns a string with trailing characters removed. */
48 string trimleft( const string& s, const string& trimmings = whitespace );
49
50 /** Returns a string with leading characters removed. */
51 string trimright( const string& s, const string& trimmings = whitespace );
52
53 /** Returns a string with leading and trailing characters removed. */
54 string trim( const string& s, const string& trimmings = whitespace );
55
56 /** atof() wrapper for "string" type */
57 inline double
58 atof( const string& str )
59 {
60     return ::atof( str.c_str() );
61 }
62
63 /** atoi() wrapper for "string" type */
64 inline int
65 atoi( const string& str )
66 {
67     return ::atoi( str.c_str() );
68 }
69
70 #endif // STRUTILS_H
71