Skip to content

Commit d1d2e24

Browse files
authored
Merge pull request #4 from get-a-clue/fixing_event_serialization_issue
Fixing event serialization issue
2 parents ab9e781 + aa2f444 commit d1d2e24

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/utm/event_msg.cpp

+23-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "event_msg.h"
44

5+
#define FIELDS_IN_EVENT 5
6+
57
namespace utm {
68

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

8385
std::vector<std::string> fields;
84-
86+
8587
stringtools::split(fields, keyvalue, '|');
86-
if (fields.size() != 5)
88+
if (fields.size() < FIELDS_IN_EVENT)
8789
return;
8890

89-
id = boost::lexical_cast<std::uint64_t>(fields[0]);
90-
pane = boost::lexical_cast<int>(fields[1]);
91-
type = boost::lexical_cast<int>(fields[2]);
92-
time.from_string(fields[3].c_str(), utime::format_iso);
93-
message.assign_fromutf8(fields[4].c_str());
91+
size_t k = 0;
92+
id = boost::lexical_cast<std::uint64_t>(fields[k++]);
93+
pane = boost::lexical_cast<int>(fields[k++]);
94+
type = boost::lexical_cast<int>(fields[k++]);
95+
time.from_string(fields[k++].c_str(), utime::format_iso);
96+
97+
// Message may include the character '|' (one is actually separator).
98+
// Therefore, parser should correctly handle this case.
99+
message.clear();
100+
while (k < fields.size())
101+
{
102+
if (k >= FIELDS_IN_EVENT)
103+
{
104+
message.append("|");
105+
}
106+
utm::gstring str;
107+
str.assign_fromutf8(fields[k++].c_str());
108+
message.append(str);
109+
}
94110

95111
if (stringtools::localize != NULL)
96112
{

src/utm/utm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#endif
77

88
#ifndef UTM_VERSION
9-
#define UTM_VERSION "15.0.104"
9+
#define UTM_VERSION "15.0.106"
1010
#endif
1111

1212
#ifdef UTM_WIN

0 commit comments

Comments
 (0)