Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/putil/string_utils.h

Go to the documentation of this file.
00001 // Filename: string_utils.h
00002 // Created by:  drose (18Jan99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef STRING_UTILS_H
00020 #define STRING_UTILS_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include <string>
00025 #include <vector_string.h>
00026 
00027 // Case-insensitive string comparison, from Stroustrup's C++ third edition.
00028 // Works like strcmp().
00029 EXPCL_PANDA int cmp_nocase(const string &s, const string &s2);
00030 
00031 // Similar, except it also accepts hyphen and underscore as equivalent.
00032 EXPCL_PANDA int cmp_nocase_uh(const string &s, const string &s2);
00033 
00034 // Returns the string converted to lowercase.
00035 EXPCL_PANDA string downcase(const string &s);
00036 
00037 // Returns the string converted to uppercase.
00038 EXPCL_PANDA string upcase(const string &s);
00039 
00040 // Separates the string into words according to whitespace.
00041 EXPCL_PANDA int extract_words(const string &str, vector_string &words);
00042 
00043 // Separates the string into words according to the indicated delimiters.
00044 EXPCL_PANDA void tokenize(const string &str, vector_string &words,
00045                           const string &delimiters);
00046 
00047 // Trims leading and/or trailing whitespace from the string.
00048 EXPCL_PANDA string trim_left(const string &str);
00049 EXPCL_PANDA string trim_right(const string &str);
00050 
00051 // Functions to parse numeric values out of a string.
00052 EXPCL_PANDA int string_to_int(const string &str, string &tail);
00053 EXPCL_PANDA bool string_to_int(const string &str, int &result);
00054 EXPCL_PANDA double string_to_double(const string &str, string &tail);
00055 EXPCL_PANDA bool string_to_double(const string &str, double &result);
00056 EXPCL_PANDA bool string_to_float(const string &str, float &result);
00057 
00058 // Convenience function to make a string from anything that has an
00059 // ostream operator.
00060 template<class Thing>
00061 INLINE string format_string(const Thing &thing);
00062 
00063 #include "string_utils.I"
00064 
00065 #endif
00066 

Generated on Fri May 2 00:43:42 2003 for Panda by doxygen1.3