Browse code

moved trim() to AmUtils

Stefan Sayer authored on 04/03/2011 15:16:13
Showing 3 changed files
... ...
@@ -44,14 +44,6 @@ SCStrArgAction::SCStrArgAction(const string& m_arg) {
44 44
     arg = trim(arg, "'");
45 45
 }
46 46
 
47
-string trim(string const& str,char const* sepSet)
48
-{
49
-  string::size_type const first = str.find_first_not_of(sepSet);
50
-  return ( first==string::npos )
51
-    ? std::string()  : 
52
-    str.substr(first, str.find_last_not_of(sepSet)-first+1);
53
-}
54
-
55 47
 bool isNumber(const std::string& s) {
56 48
   if (s.empty())
57 49
     return false;
... ...
@@ -81,9 +81,6 @@ typedef void* (*SCFactoryCreate)();
81 81
 #define SC_EXPORT(class_name)			\
82 82
   EXPORT_SC_FACTORY(SC_FACTORY_EXPORT,class_name)
83 83
 
84
-
85
-string trim(string const& str,char const* sepSet);
86
-
87 84
 class SCStrArgAction   
88 85
 : public DSMAction {
89 86
  protected:
... ...
@@ -242,6 +242,14 @@ unsigned int get_random();
242 242
 /** Explode string by a separator to a vector */
243 243
 std::vector<string> explode(const string& s, const string& delim, const bool keep_empty = false);
244 244
 
245
+/** remove chars in sepSet from beginning and end of str */
246
+inline std::string trim(std::string const& str,char const* sepSet)
247
+{
248
+  std::string::size_type const first = str.find_first_not_of(sepSet);
249
+  return ( first==std::string::npos ) ?
250
+    std::string() : str.substr(first, str.find_last_not_of(sepSet)-first+1);
251
+}
252
+
245 253
 /** add a directory to an environement variable */
246 254
 void add_env_path(const char* name, const string& path);
247 255