Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "incident_helper" |
| 18 | |
| 19 | #include "ih_util.h" |
| 20 | |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 21 | #include <algorithm> |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 22 | #include <sstream> |
| 23 | #include <unistd.h> |
| 24 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 25 | bool isValidChar(char c) { |
| 26 | uint8_t v = (uint8_t)c; |
| 27 | return (v >= (uint8_t)'a' && v <= (uint8_t)'z') |
| 28 | || (v >= (uint8_t)'A' && v <= (uint8_t)'Z') |
| 29 | || (v >= (uint8_t)'0' && v <= (uint8_t)'9') |
| 30 | || (v == (uint8_t)'_'); |
| 31 | } |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 32 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 33 | std::string trim(const std::string& s, const std::string& charset) { |
| 34 | const auto head = s.find_first_not_of(charset); |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 35 | if (head == std::string::npos) return ""; |
| 36 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 37 | const auto tail = s.find_last_not_of(charset); |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 38 | return s.substr(head, tail - head + 1); |
| 39 | } |
| 40 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 41 | static inline std::string toLowerStr(const std::string& s) { |
| 42 | std::string res(s); |
| 43 | std::transform(res.begin(), res.end(), res.begin(), ::tolower); |
| 44 | return res; |
| 45 | } |
| 46 | |
| 47 | static inline std::string trimDefault(const std::string& s) { |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 48 | return trim(s, DEFAULT_WHITESPACE); |
| 49 | } |
| 50 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 51 | static inline std::string trimHeader(const std::string& s) { |
| 52 | return toLowerStr(trimDefault(s)); |
Yi Jin | 4ef28b7 | 2017-08-14 14:45:28 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 55 | // This is similiar to Split in android-base/file.h, but it won't add empty string |
Yi Jin | 4ef28b7 | 2017-08-14 14:45:28 -0700 | [diff] [blame] | 56 | static void split(const std::string& line, std::vector<std::string>& words, |
| 57 | const trans_func& func, const std::string& delimiters) { |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 58 | words.clear(); // clear the buffer before split |
| 59 | |
| 60 | size_t base = 0; |
| 61 | size_t found; |
| 62 | while (true) { |
| 63 | found = line.find_first_of(delimiters, base); |
| 64 | if (found != base) { |
Yi Jin | 4ef28b7 | 2017-08-14 14:45:28 -0700 | [diff] [blame] | 65 | std::string word = (*func) (line.substr(base, found - base)); |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 66 | if (!word.empty()) { |
| 67 | words.push_back(word); |
| 68 | } |
| 69 | } |
| 70 | if (found == line.npos) break; |
| 71 | base = found + 1; |
| 72 | } |
| 73 | } |
| 74 | |
Yi Jin | 4ef28b7 | 2017-08-14 14:45:28 -0700 | [diff] [blame] | 75 | header_t parseHeader(const std::string& line, const std::string& delimiters) { |
| 76 | header_t header; |
| 77 | trans_func f = &trimHeader; |
| 78 | split(line, header, f, delimiters); |
| 79 | return header; |
| 80 | } |
| 81 | |
| 82 | record_t parseRecord(const std::string& line, const std::string& delimiters) { |
| 83 | record_t record; |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 84 | trans_func f = &trimDefault; |
Yi Jin | 4ef28b7 | 2017-08-14 14:45:28 -0700 | [diff] [blame] | 85 | split(line, record, f, delimiters); |
| 86 | return record; |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 89 | record_t parseRecordByColumns(const std::string& line, const std::vector<int>& indices, const std::string& delimiters) { |
| 90 | record_t record; |
| 91 | int lastIndex = 0; |
| 92 | int lineSize = (int)line.size(); |
| 93 | for (std::vector<int>::const_iterator it = indices.begin(); it != indices.end(); ++it) { |
| 94 | int idx = *it; |
| 95 | if (lastIndex > idx || idx > lineSize) { |
| 96 | record.clear(); // The indices is wrong, return empty; |
| 97 | return record; |
| 98 | } |
| 99 | while (idx < lineSize && delimiters.find(line[idx++]) == std::string::npos); |
| 100 | record.push_back(trimDefault(line.substr(lastIndex, idx - lastIndex))); |
| 101 | lastIndex = idx; |
| 102 | } |
| 103 | record.push_back(trimDefault(line.substr(lastIndex, lineSize - lastIndex))); |
| 104 | return record; |
| 105 | } |
| 106 | |
| 107 | bool stripPrefix(std::string* line, const char* key, bool endAtDelimiter) { |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 108 | const auto head = line->find_first_not_of(DEFAULT_WHITESPACE); |
| 109 | if (head == std::string::npos) return false; |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 110 | int len = (int)line->length(); |
| 111 | int i = 0; |
| 112 | int j = head; |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 113 | while (key[i] != '\0') { |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 114 | if (j >= len || key[i++] != line->at(j++)) { |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 115 | return false; |
| 116 | } |
| 117 | } |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 118 | |
| 119 | if (endAtDelimiter) { |
| 120 | // this means if the line only have prefix or no delimiter, we still return false. |
| 121 | if (j == len || isValidChar(line->at(j))) return false; |
| 122 | } |
| 123 | |
| 124 | line->assign(trimDefault(line->substr(j))); |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | bool stripSuffix(std::string* line, const char* key, bool endAtDelimiter) { |
| 129 | const auto tail = line->find_last_not_of(DEFAULT_WHITESPACE); |
| 130 | if (tail == std::string::npos) return false; |
| 131 | int i = 0; |
| 132 | while (key[++i] != '\0'); // compute the size of the key |
| 133 | int j = tail; |
| 134 | while (i > 0) { |
| 135 | if (j < 0 || key[--i] != line->at(j--)) { |
| 136 | return false; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | if (endAtDelimiter) { |
| 141 | // this means if the line only have suffix or no delimiter, we still return false. |
| 142 | if (j < 0 || isValidChar(line->at(j))) return false; |
| 143 | } |
| 144 | |
| 145 | line->assign(trimDefault(line->substr(0, j+1))); |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 146 | return true; |
| 147 | } |
| 148 | |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 149 | int toInt(const std::string& s) { |
| 150 | return atoi(s.c_str()); |
| 151 | } |
| 152 | |
| 153 | long long toLongLong(const std::string& s) { |
| 154 | return atoll(s.c_str()); |
| 155 | } |
| 156 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 157 | double toDouble(const std::string& s) { |
| 158 | return atof(s.c_str()); |
| 159 | } |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 160 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 161 | // ============================================================================== |
| 162 | Reader::Reader(const int fd) |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 163 | { |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 164 | mFile = fdopen(fd, "r"); |
| 165 | mStatus = mFile == NULL ? "Invalid fd " + std::to_string(fd) : ""; |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | Reader::~Reader() |
| 169 | { |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 170 | if (mFile != NULL) fclose(mFile); |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 171 | } |
| 172 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 173 | bool Reader::readLine(std::string* line) { |
| 174 | if (mFile == NULL) return false; |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 175 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 176 | char* buf = NULL; |
| 177 | size_t len = 0; |
| 178 | ssize_t read = getline(&buf, &len, mFile); |
| 179 | if (read != -1) { |
| 180 | std::string s(buf); |
| 181 | line->assign(trim(s, DEFAULT_NEWLINE)); |
| 182 | } else if (errno == EINVAL) { |
| 183 | mStatus = "Bad Argument"; |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 184 | } |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 185 | free(buf); |
| 186 | return read != -1; |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Yi Jin | 810b14f | 2017-09-11 19:01:08 -0700 | [diff] [blame] | 189 | bool Reader::ok(std::string* error) { |
| 190 | error->assign(mStatus); |
Yi Jin | b44f7d4 | 2017-07-21 12:12:59 -0700 | [diff] [blame] | 191 | return mStatus.empty(); |
| 192 | } |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 193 | |
| 194 | // ============================================================================== |
| 195 | Table::Table(const char* names[], const uint64_t ids[], const int count) |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 196 | :mEnums(), |
| 197 | mEnumValuesByName() |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 198 | { |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 199 | map<std::string, uint64_t> fields; |
| 200 | for (int i = 0; i < count; i++) { |
| 201 | fields[names[i]] = ids[i]; |
| 202 | } |
| 203 | mFields = fields; |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | Table::~Table() |
| 207 | { |
| 208 | } |
| 209 | |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 210 | void |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 211 | Table::addEnumTypeMap(const char* field, const char* enumNames[], const int enumValues[], const int enumSize) |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 212 | { |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 213 | if (mFields.find(field) == mFields.end()) return; |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 214 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 215 | map<std::string, int> enu; |
| 216 | for (int i = 0; i < enumSize; i++) { |
| 217 | enu[enumNames[i]] = enumValues[i]; |
| 218 | } |
| 219 | mEnums[field] = enu; |
| 220 | } |
| 221 | |
| 222 | void |
| 223 | Table::addEnumNameToValue(const char* enumName, const int enumValue) |
| 224 | { |
| 225 | mEnumValuesByName[enumName] = enumValue; |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | bool |
| 229 | Table::insertField(ProtoOutputStream* proto, const std::string& name, const std::string& value) |
| 230 | { |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 231 | if (mFields.find(name) == mFields.end()) return false; |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 232 | |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 233 | uint64_t found = mFields[name]; |
| 234 | record_t repeats; // used for repeated fields |
| 235 | switch ((found & FIELD_COUNT_MASK) | (found & FIELD_TYPE_MASK)) { |
| 236 | case FIELD_COUNT_SINGLE | FIELD_TYPE_DOUBLE: |
| 237 | case FIELD_COUNT_SINGLE | FIELD_TYPE_FLOAT: |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 238 | proto->write(found, toDouble(value)); |
| 239 | break; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 240 | case FIELD_COUNT_SINGLE | FIELD_TYPE_STRING: |
| 241 | case FIELD_COUNT_SINGLE | FIELD_TYPE_BYTES: |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 242 | proto->write(found, value); |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 243 | break; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 244 | case FIELD_COUNT_SINGLE | FIELD_TYPE_INT64: |
| 245 | case FIELD_COUNT_SINGLE | FIELD_TYPE_SINT64: |
| 246 | case FIELD_COUNT_SINGLE | FIELD_TYPE_UINT64: |
| 247 | case FIELD_COUNT_SINGLE | FIELD_TYPE_FIXED64: |
| 248 | case FIELD_COUNT_SINGLE | FIELD_TYPE_SFIXED64: |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 249 | proto->write(found, toLongLong(value)); |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 250 | break; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 251 | case FIELD_COUNT_SINGLE | FIELD_TYPE_BOOL: |
| 252 | if (strcmp(toLowerStr(value).c_str(), "true") == 0 || strcmp(value.c_str(), "1") == 0) { |
| 253 | proto->write(found, true); |
| 254 | break; |
| 255 | } |
| 256 | if (strcmp(toLowerStr(value).c_str(), "false") == 0 || strcmp(value.c_str(), "0") == 0) { |
| 257 | proto->write(found, false); |
| 258 | break; |
| 259 | } |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 260 | return false; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 261 | case FIELD_COUNT_SINGLE | FIELD_TYPE_ENUM: |
| 262 | // if the field has its own enum mapping, use this, otherwise use general name to value mapping. |
| 263 | if (mEnums.find(name) != mEnums.end()) { |
| 264 | if (mEnums[name].find(value) != mEnums[name].end()) { |
| 265 | proto->write(found, mEnums[name][value]); |
| 266 | } else { |
| 267 | proto->write(found, 0); // TODO: should get the default enum value (Unknown) |
| 268 | } |
| 269 | } else if (mEnumValuesByName.find(value) != mEnumValuesByName.end()) { |
| 270 | proto->write(found, mEnumValuesByName[value]); |
| 271 | } else { |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 272 | return false; |
| 273 | } |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 274 | break; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 275 | case FIELD_COUNT_SINGLE | FIELD_TYPE_INT32: |
| 276 | case FIELD_COUNT_SINGLE | FIELD_TYPE_SINT32: |
| 277 | case FIELD_COUNT_SINGLE | FIELD_TYPE_UINT32: |
| 278 | case FIELD_COUNT_SINGLE | FIELD_TYPE_FIXED32: |
| 279 | case FIELD_COUNT_SINGLE | FIELD_TYPE_SFIXED32: |
Yi Jin | e2f7f79 | 2017-11-01 17:08:27 -0700 | [diff] [blame] | 280 | proto->write(found, toInt(value)); |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 281 | break; |
Yi Jin | 0dfa752 | 2017-11-06 17:43:47 -0800 | [diff] [blame] | 282 | // REPEATED TYPE below: |
| 283 | case FIELD_COUNT_REPEATED | FIELD_TYPE_INT32: |
| 284 | repeats = parseRecord(value, COMMA_DELIMITER); |
| 285 | for (size_t i=0; i<repeats.size(); i++) { |
| 286 | proto->write(found, toInt(repeats[i])); |
| 287 | } |
| 288 | break; |
| 289 | case FIELD_COUNT_REPEATED | FIELD_TYPE_STRING: |
| 290 | repeats = parseRecord(value, COMMA_DELIMITER); |
| 291 | for (size_t i=0; i<repeats.size(); i++) { |
| 292 | proto->write(found, repeats[i]); |
| 293 | } |
| 294 | break; |
Yi Jin | 04625ad | 2017-10-17 18:29:33 -0700 | [diff] [blame] | 295 | default: |
| 296 | return false; |
| 297 | } |
| 298 | return true; |
| 299 | } |
Yi Jin | 9299af93 | 2017-12-05 17:44:48 -0800 | [diff] [blame] | 300 | |
| 301 | // ================================================================================ |
| 302 | Message::Message(Table* table) |
| 303 | :mTable(table), |
| 304 | mPreviousField(""), |
| 305 | mTokens(), |
| 306 | mSubMessages() |
| 307 | { |
| 308 | } |
| 309 | |
| 310 | Message::~Message() |
| 311 | { |
| 312 | } |
| 313 | |
| 314 | void |
| 315 | Message::addSubMessage(uint64_t fieldId, Message* fieldMsg) |
| 316 | { |
| 317 | for (auto iter = mTable->mFields.begin(); iter != mTable->mFields.end(); iter++) { |
| 318 | if (iter->second == fieldId) { |
| 319 | mSubMessages[iter->first] = fieldMsg; |
| 320 | return; |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | bool |
| 326 | Message::insertField(ProtoOutputStream* proto, const std::string& name, const std::string& value) |
| 327 | { |
| 328 | // If the field name can be found, it means the name is a primitive field. |
| 329 | if (mTable->mFields.find(name) != mTable->mFields.end()) { |
| 330 | endSession(proto); |
| 331 | // The only edge case is for example ro.hardware itself is a message, so a field called "value" |
| 332 | // would be defined in proto Ro::Hardware and it must be the first field. |
| 333 | if (mSubMessages.find(name) != mSubMessages.end()) { |
| 334 | startSession(proto, name); |
| 335 | return mSubMessages[name]->insertField(proto, "value", value); |
| 336 | } else { |
| 337 | return mTable->insertField(proto, name, value); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | // Try to find the message field which is the prefix of name, so the value would be inserted |
| 342 | // recursively into the submessage. |
| 343 | string mutableName = name; |
| 344 | for (auto iter = mSubMessages.begin(); iter != mSubMessages.end(); iter++) { |
| 345 | string fieldName = iter->first; |
| 346 | string prefix = fieldName + "_"; // underscore is the delimiter in the name |
| 347 | if (stripPrefix(&mutableName, prefix.c_str())) { |
| 348 | if (mPreviousField != fieldName) { |
| 349 | endSession(proto); |
| 350 | startSession(proto, fieldName); |
| 351 | } |
| 352 | return mSubMessages[fieldName]->insertField(proto, mutableName, value); |
| 353 | } |
| 354 | } |
| 355 | // Can't find the name in proto definition, handle it separately. |
| 356 | return false; |
| 357 | } |
| 358 | |
| 359 | void |
| 360 | Message::startSession(ProtoOutputStream* proto, const string& name) |
| 361 | { |
| 362 | uint64_t fieldId = mTable->mFields[name]; |
| 363 | long long token = proto->start(fieldId); |
| 364 | mPreviousField = name; |
| 365 | mTokens.push(token); |
| 366 | } |
| 367 | |
| 368 | void |
| 369 | Message::endSession(ProtoOutputStream* proto) |
| 370 | { |
| 371 | if (mPreviousField == "") return; |
| 372 | if (mSubMessages.find(mPreviousField) != mSubMessages.end()) { |
| 373 | mSubMessages[mPreviousField]->endSession(proto); |
| 374 | } |
| 375 | proto->end(mTokens.top()); |
| 376 | mTokens.pop(); |
| 377 | mPreviousField = ""; |
| 378 | } |