regex is not working until gcc 4.9.0, then this is an alternative
authorEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Tue, 4 Apr 2017 00:08:41 +0000 (02:08 +0200)
committerEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Tue, 4 Apr 2017 00:08:41 +0000 (02:08 +0200)
example/diameter/launcher/Launcher.cpp

index dec3008..5ae6f87 100644 (file)
@@ -12,7 +12,8 @@
 #include <math.h> // ceil
 #include <climits>
 #include <unistd.h> // chdir
-#include <regex>
+//#include <regex> TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler
+#include <stdio.h>
 
 // Project
 #include <anna/timex/Engine.hpp>
@@ -2283,6 +2284,9 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
 
         // optional 'full':
         if(param4 != "strict") {
+
+          // TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler
+/*
           std::string s_from = "hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\"";
           std::string s_to = s_from;
 
@@ -2292,6 +2296,28 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
           catch (const std::regex_error& e) {
             throw anna::RuntimeException(e.what(), ANNA_FILE_LOCATION);
           }
+*/
+          std::string::size_type pos = 0u;
+          std::string::size_type pos_hbh_1, pos_hbh_2;
+          std::string::size_type pos_ete_1, pos_ete_2;
+
+          pos = regexp.find("hop-by-hop-id=", pos);
+          pos = regexp.find("\"", pos);
+          pos_hbh_1 = pos;
+          pos = regexp.find("\"", pos+1);
+          pos_hbh_2 = pos;
+
+          pos = regexp.find("end-to-end-id=", pos);
+          pos = regexp.find("\"", pos);
+          pos_ete_1 = pos;
+          pos = regexp.find("\"", pos+1);
+          pos_ete_2 = pos;
+
+          std::string hbh = regexp.substr(pos_hbh_1 + 1, pos_hbh_2 - pos_hbh_1 - 1);
+          std::string ete = regexp.substr(pos_ete_1 + 1, pos_ete_2 - pos_ete_1 - 1);
+
+          regexp.replace(pos_hbh_1 + 1, pos_hbh_2 - pos_hbh_1 - 1, "[0-9]+");
+          regexp.replace(pos_ete_1 + 1, pos_ete_2 - pos_ete_1 - 1, "[0-9]+");
 
           //regexp.insert(0, "^");
           //regexp += "$";