00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef COMMON_UTILS_H
00015 #define COMMON_UTILS_H
00016
00017 #include <sstream>
00018
00019 #include <string>
00020 #include <vector>
00021 using std::vector;
00022 using std::string;
00023
00034 #if defined (WIN32)
00035
00036 #include <Windows.h>
00037
00038 #define ASSA_DIR_SEPARATOR '\\'
00039 #define ASSA_DIR_SEPARATOR_S "\\"
00040 #define ASSA_IS_DIR_SEPARATOR(c) ((c) == ASSA_DIR_SEPARATOR || (c) == '/')
00041 #define ASSA_SEARCHPATH_SEPARATOR ';'
00042 #define ASSA_SEARCHPATH_SEPARATOR_S ";"
00043
00044 #else
00045
00046 #define ASSA_DIR_SEPARATOR '/'
00047 #define ASSA_DIR_SEPARATOR_S "/"
00048 #define ASSA_IS_DIR_SEPARATOR(c) ((c) == ASSA_DIR_SEPARATOR)
00049 #define ASSA_SEARCHPATH_SEPARATOR ':'
00050 #define ASSA_SEARCHPATH_SEPARATOR_S ":"
00051
00052 #endif
00053
00054 namespace ASSA {
00055 namespace Utils {
00056
00065 void split (const char* text_, std::vector<std::string>& vec_);
00066
00077 int split_pair (const string& text_, char sep_, string& lhs_, string& rhs_);
00078
00087 int ltrim (std::string& text_, const std::string& delim_);
00088
00098 int rtrim (std::string& text_, const std::string& delim_);
00099
00106 void trim_sides (std::string& text_);
00107
00116 void find_and_replace_char (std::string& text_, char src_, char dest_);
00117
00126 std::string strenv (const char* in_);
00127
00134 std::string get_cwd_name ();
00135
00141 inline void sleep_for_seconds (long secs_to_sleep_)
00142 {
00143 #if defined (WIN32)
00144 SleepEx (secs_to_sleep_ * 1000, FALSE);
00145 #else
00146 ::sleep (secs_to_sleep_);
00147 #endif
00148 }
00149
00150
00151 }
00152 }
00153
00154 #endif