From: Eduardo Ramos Testillano Date: Sun, 2 Apr 2017 18:29:06 +0000 (+0200) Subject: Improved wait for regexp operations X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=commitdiff_plain;h=9fa68da11c56250017da9735e4a5dd3fd3b2021b Improved wait for regexp operations --- diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index b141865..0fcfd52 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -12,6 +12,7 @@ #include // ceil #include #include // chdir +#include // Project #include @@ -792,8 +793,7 @@ throw(anna::RuntimeException) { a_communicator->accept(); } - -bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw() { +bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBlock &db) const throw(anna::RuntimeException) { // Get hex string static char buffer[8192]; std::ifstream infile(pathfile.c_str(), std::ifstream::in); @@ -808,7 +808,8 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl msg += hexString; anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); - anna::functions::fromHexString(hexString, db); + + anna::functions::fromHexString(hexString, db); // could launch exception // Close file infile.close(); return true; @@ -817,6 +818,21 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl return false; } +bool Launcher::getContentFromFile(const std::string &pathfile, std::string &content) const throw(anna::RuntimeException) { + + std::ifstream inFile(pathfile.c_str(), std::ifstream::in); + if(!inFile.good()) { + throw RuntimeException(anna::functions::asString("Unable to open file '%s'", pathfile.c_str()), ANNA_FILE_LOCATION); + } + + std::stringstream strStream; + strStream << inFile.rdbuf(); //read the file + content = strStream.str(); // holds the content of the file + inFile.close(); + + return true; +} + void Launcher::resetStatistics() throw() { if (a_workingNode) { a_workingNode->getCommEngine()->resetStatistics(); @@ -1222,16 +1238,6 @@ std::string Launcher::help() const throw() { result += "\n delay| Blocking step until the time lapse expires. Useful to give "; result += "\n some cadence control and time schedule for a specific case."; result += "\n A value of 0 could be used as a dummy step."; - result += "\n wait| Blocking step until condition is fulfilled. The message could"; - result += "\n received from entity (waitfe) or from client (waitfc)."; - result += "\n"; - result += "\n wait-regexp|"; - result += "\n Wait condition, from entity (waitfe-regexp) or client (waitfc-regexp)"; - result += "\n to match the serialized xml content for received messages. CPU cost"; - result += "\n is bigger than the former ones because the whole message must be"; - result += "\n decoded and converted to xml instead of doing a direct hexadecimal"; - result += "\n buffer search. The main advantage is the great flexibility to identify"; - result += "\n any content with a regular expression."; result += "\n"; result += "\n sh-command|