* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/sysdep.h"
+#include "xbt/dict.h"
#include "xbt/log.h"
#include "xbt/str.h"
-#include "xbt/dict.h"
+
#include "src/surf/trace_mgr.hpp"
#include "src/surf/surf_interface.hpp"
#include "surf_private.h"
#include "xbt/RngStream.h"
+#include <boost/algorithm/string.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/split.hpp>
#include <math.h>
#include <unordered_map>
-#include <boost/algorithm/string/join.hpp>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_trace, surf, "Surf trace management");
{
int linecount = 0;
tmgr_event_t last_event = nullptr;
- unsigned int cpt;
- char *val;
xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name);
xbt_assert(periodicity >= 0, "Invalid periodicity %g (must be positive)", periodicity);
tmgr_trace_t trace = new simgrid::trace_mgr::trace();
- xbt_dynar_t list = xbt_str_split(input, "\n\r");
- xbt_dynar_foreach(list, cpt, val) {
+ std::vector<std::string> list;
+ boost::split(list, input, boost::is_any_of("\n\r"));
+ for (auto val : list) {
s_tmgr_event_t event;
linecount++;
- xbt_str_trim(val, " \t\n\r\x0B");
+ boost::trim(val);
if (val[0] == '#' || val[0] == '\0' || val[0] == '%') // pass comments
continue;
-
- if (sscanf(val, "PERIODICITY " "%lg" "\n", &periodicity) == 1)
+ if (sscanf(val.c_str(), "PERIODICITY " "%lg" "\n", &periodicity) == 1)
continue;
- xbt_assert(sscanf(val, "%lg" " " "%lg" "\n", &event.delta, &event.value) == 2,
+ xbt_assert(sscanf(val.c_str(), "%lg" " " "%lg" "\n", &event.delta, &event.value) == 2,
"%s:%d: Syntax error in trace\n%s", name, linecount, input);
if (last_event) {
trace_list.insert({xbt_strdup(name), trace});
- xbt_dynar_free(&list);
return trace;
}