|
2 | 2 |
|
3 | 3 | #include "event_msg.h"
|
4 | 4 |
|
| 5 | +#define FIELDS_IN_EVENT 5 |
| 6 | + |
5 | 7 | namespace utm {
|
6 | 8 |
|
7 | 9 | 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)
|
81 | 83 | return;
|
82 | 84 |
|
83 | 85 | std::vector<std::string> fields;
|
84 |
| - |
| 86 | + |
85 | 87 | stringtools::split(fields, keyvalue, '|');
|
86 |
| - if (fields.size() != 5) |
| 88 | + if (fields.size() < FIELDS_IN_EVENT) |
87 | 89 | return;
|
88 | 90 |
|
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 | + } |
94 | 110 |
|
95 | 111 | if (stringtools::localize != NULL)
|
96 | 112 | {
|
|
0 commit comments