Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

string_util.h

Go 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   //! returns lower case version of @a s
00012   std::string makeLower(const std::string& s) ATTR_must_check;
00013 
00014   //! returns upper case version of @a s
00015   std::string makeUpper(const std::string& s) ATTR_must_check;
00016 
00017   //! returns @a str with @a pre removed - if @a pre is not fully matched, @a str is returned unchanged
00018   std::string removePrefix(const std::string& str, const std::string& pre) ATTR_must_check;
00019   
00020   //! removes whitespace (as defined by isspace()) from the beginning and end of @a str, and returns the result
00021   std::string trim(const std::string& str) ATTR_must_check;
00022   
00023   //! parses the input string into an arg list, with corresponding offsets of each arg in the original input
00024   bool parseArgs(const std::string& input, std::vector<std::string>& args, std::vector<unsigned int>& offsets); 
00025 
00026   //! replaces ~USER prefix with specified user's home directory, or ~ prefix with current HOME environment setting; returns str if no valid expansion is found
00027   std::string tildeExpansion(const std::string& str) ATTR_must_check;
00028 };
00029 
00030 /*! @file
00031  * @brief Describes some useful functions for string manipulation in the string_util namespace
00032  * @author ejt (Creator)
00033  *
00034  * $Author: ejt $
00035  * $Name: tekkotsu-3_0 $
00036  * $Revision: 1.7 $
00037  * $State: Exp $
00038  * $Date: 2006/03/16 22:24:30 $
00039  */
00040 
00041 #endif

Tekkotsu v3.0
Generated Wed Oct 4 00:03:46 2006 by Doxygen 1.4.7