Browse code

core: move str2bool() to AmUtils

Raphael Coeffic authored on 23/12/2013 08:49:46
Showing 3 changed files
... ...
@@ -670,21 +670,6 @@ string SBCCallProfile::print() const {
670 670
   return res;
671 671
 }
672 672
 
673
-/* translates string value into bool, returns false on error */
674
-static bool str2bool(const string &s, bool &dst)
675
-{
676
-  // TODO: optimize
677
-  if ((s == "yes") || (s == "true") || (s == "1")) {
678
-    dst = true;
679
-    return true;
680
-  }
681
-  if ((s == "no") || (s == "false") || (s == "0")) {
682
-    dst = false;
683
-    return true;
684
-  }
685
-  return false;
686
-}
687
-
688 673
 static bool isTranscoderNeeded(const AmSipRequest& req, vector<PayloadDesc> &caps,
689 674
 			       bool default_value)
690 675
 {
... ...
@@ -367,6 +367,20 @@ bool str2long(char*& str, long& result, char sep)
367 367
   return false;
368 368
 }
369 369
 
370
+bool str2bool(const string &s, bool &dst)
371
+{
372
+  // TODO: optimize
373
+  if ((s == "yes") || (s == "true") || (s == "1")) {
374
+    dst = true;
375
+    return true;
376
+  }
377
+  if ((s == "no") || (s == "false") || (s == "0")) {
378
+    dst = false;
379
+    return true;
380
+  }
381
+  return false;
382
+}
383
+
370 384
 int parse_return_code(const char* lbuf, unsigned int& res_code, string& res_msg )
371 385
 {
372 386
   char res_code_str[4] = {'\0'};
... ...
@@ -158,6 +158,9 @@ bool str2long(const string& str, long& result);
158 158
  */
159 159
 bool str2long(char*& str, long& result, char sep = ' ');
160 160
 
161
+/* translates string value into bool, returns false on error */
162
+bool str2bool(const string &s, bool &dst);
163
+
161 164
 /**
162 165
  * Parse code/reason line.
163 166
  * Syntax: "code reason"