Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
string_util.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_string_util_h 00003 #define INCLUDED_string_util_h 00004 00005 #include "attributes.h" 00006 #include <string> 00007 #include <vector> 00008 00009 //! some common string processing functions, for std::string 00010 namespace string_util { 00011 //! uses the standard library's "locale" to convert case of a single character 00012 char localeToUpper(char c); 00013 00014 //! uses the standard library's "locale" to convert case of a single character 00015 char localeToLower(char c); 00016 00017 //! returns lower case version of @a s 00018 std::string makeLower(const std::string& s) ATTR_must_check; 00019 00020 //! returns upper case version of @a s 00021 std::string makeUpper(const std::string& s) ATTR_must_check; 00022 00023 //! returns @a str with @a pre removed - if @a pre is not fully matched, @a str is returned unchanged 00024 std::string removePrefix(const std::string& str, const std::string& pre) ATTR_must_check; 00025 00026 //! removes whitespace (as defined by isspace()) from the beginning and end of @a str, and returns the result 00027 std::string trim(const std::string& str) ATTR_must_check; 00028 00029 //! parses the input string into an arg list, with corresponding offsets of each arg in the original input 00030 bool parseArgs(const std::string& input, std::vector<std::string>& args, std::vector<unsigned int>& offsets); 00031 00032 //! replaces ~USER prefix with specified user's home directory, or ~ prefix with current HOME environment setting; returns str if no valid expansion is found 00033 std::string tildeExpansion(const std::string& str) ATTR_must_check; 00034 00035 //! returns true if @a str matches @a re (assumes 'extended' regular expression, not 'basic'), false otherwise and throws std::string message on error 00036 /*! @param str The string to match 00037 * @param regex The (extended) regular expression which should be parsed and executed 00038 * 00039 * This compiles the @a regex and then executes it... for repeated usage of the same 00040 * regular expression, you could be better off compiling it yourself and using the regex library directly. */ 00041 bool reMatch(const std::string& str, const std::string& regex); 00042 00043 //! returns true if @a str matches @a re (with optional @a flags to control interpretation), false otherwise and throws std::string message on error 00044 /*! @param str The string to match 00045 * @param regex The regular expression which should be parsed and executed 00046 * @param flags pass flags for regex (e.g. REG_EXTENDED) 00047 * 00048 * This compiles the @a regex and then executes it... for repeated usage of the same 00049 * regular expression, you could be better off compiling it yourself and using the regex library directly. */ 00050 bool reMatch(const std::string& str, const std::string& regex, int flags); 00051 00052 }; 00053 00054 /*! @file 00055 * @brief Describes some useful functions for string manipulation in the string_util namespace 00056 * @author ejt (Creator) 00057 * 00058 * $Author: ejt $ 00059 * $Name: tekkotsu-4_0 $ 00060 * $Revision: 1.10 $ 00061 * $State: Exp $ 00062 * $Date: 2007/11/09 19:01:14 $ 00063 */ 00064 00065 #endif |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:54:56 2007 by Doxygen 1.5.4 |