Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

StringUtil.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00019 /*
00020  * $Log: StringUtil.h,v $
00021  * Revision 1.9  2007/04/23 04:58:53  n-ando
00022  * FUnction "stringTo()" was added.
00023  *
00024  * Revision 1.8  2007/04/13 15:57:13  n-ando
00025  * toArgv() was added to create command line arguments.
00026  * Some bug fixes.
00027  *
00028  * Revision 1.7  2006/11/27 10:00:15  n-ando
00029  * otos() function that converts object to string was added.
00030  * flatten() function that flattens string vector was added.
00031  *
00032  * Revision 1.6  2006/10/24 06:24:45  n-ando
00033  * Now StringUtil was devided into definition and implementation.
00034  *
00035  * Revision 1.5  2006/10/23 07:41:20  n-ando
00036  * Kanji-code was changed from JIS to EUC.
00037  *
00038  * Revision 1.4  2006/10/23 07:37:42  n-ando
00039  * Bug fix for split(). The problems that split() does not return empty
00040  * string as list of results string.
00041  * Reference manuals for functions were described.
00042  *
00043  * Revision 1.3  2006/10/17 10:11:09  n-ando
00044  * Some escape/unescape related bugs are fixed.
00045  * The following some functions were added.
00046  * - eraseHeadBlank(), eraseTailBlank(), replaceString()
00047  *
00048  * Revision 1.2  2006/10/13 03:51:37  n-ando
00049  * The "escape" and "unescape" functions were added.
00050  *
00051  * Revision 1.1  2006/09/20 08:49:08  n-ando
00052  * The first commit.
00053  *
00054  *
00055  */
00056 
00057 #ifndef StringUtil_h
00058 #define StringUtil_h
00059 
00060 #include <string>
00061 #include <vector>
00062 #include <sstream>
00063 
00086 bool isEscaped(const std::string& str, std::string::size_type pos);
00087 
00088 
00113 std::string escape(const std::string str);
00114 
00115 
00142 std::string unescape(const std::string str);
00143 
00144 
00152 void eraseHeadBlank(std::string& str);
00153 
00154 
00162 void eraseTailBlank(std::string& str);
00163 
00164 
00172 void replaceString(std::string& str, const std::string from,
00173                    const std::string to);
00174 
00175 
00183 std::vector<std::string> split(const std::string& input,
00184                                const std::string& delimiter);
00185 
00186 
00194 bool toBool(std::string str, std::string yes, std::string no, 
00195             bool default_value = true);
00196 
00197 
00205 bool isAbsolutePath(const std::string& str);
00206 
00207 
00215 bool isURL(const std::string& str);
00216 
00217 
00225 template <class Printable>
00226 std::string otos(Printable n)
00227 {
00228   std::stringstream str_stream;
00229   str_stream << n;
00230   return str_stream.str();
00231 };
00232 
00233 template <typename To>
00234 bool stringTo(To& val, const char* str)
00235 {
00236   std::stringstream s;
00237   return (s << str && s >> val);
00238 }
00239 
00240 
00241 std::vector<std::string> unique_sv(std::vector<std::string> sv);
00242 
00243 std::string flatten(std::vector<std::string> sv);
00244 
00245 
00246 char** toArgv(const std::vector<std::string>& args); 
00247 
00248 
00249 #endif // StringUtil_h

Generated on Fri Oct 5 05:16:00 2007 for OpenRTM by  doxygen 1.4.1