Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4 from get-a-clue/fixing_event_serialization_issue
Fixing event serialization issue
  • Loading branch information
get-a-clue committed Mar 4, 2018
2 parents ab9e781 + aa2f444 commit d1d2e24
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions src/utm/event_msg.cpp
Expand Up @@ -2,6 +2,8 @@

#include "event_msg.h"

#define FIELDS_IN_EVENT 5

namespace utm {

const char event_msg::this_class_name[] = "event_msg";
Expand Down Expand Up @@ -81,16 +83,30 @@ void event_msg::xml_catch_value(const char *keyname, const char *keyvalue)
return;

std::vector<std::string> fields;

stringtools::split(fields, keyvalue, '|');
if (fields.size() != 5)
if (fields.size() < FIELDS_IN_EVENT)
return;

id = boost::lexical_cast<std::uint64_t>(fields[0]);
pane = boost::lexical_cast<int>(fields[1]);
type = boost::lexical_cast<int>(fields[2]);
time.from_string(fields[3].c_str(), utime::format_iso);
message.assign_fromutf8(fields[4].c_str());
size_t k = 0;
id = boost::lexical_cast<std::uint64_t>(fields[k++]);
pane = boost::lexical_cast<int>(fields[k++]);
type = boost::lexical_cast<int>(fields[k++]);
time.from_string(fields[k++].c_str(), utime::format_iso);

// Message may include the character '|' (one is actually separator).
// Therefore, parser should correctly handle this case.
message.clear();
while (k < fields.size())
{
if (k >= FIELDS_IN_EVENT)
{
message.append("|");
}
utm::gstring str;
str.assign_fromutf8(fields[k++].c_str());
message.append(str);
}

if (stringtools::localize != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/utm/utm.h
Expand Up @@ -6,7 +6,7 @@
#endif

#ifndef UTM_VERSION
#define UTM_VERSION "15.0.104"
#define UTM_VERSION "15.0.106"
#endif

#ifdef UTM_WIN
Expand Down

0 comments on commit d1d2e24

Please sign in to comment.