OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/logging/win/mof_data_parser.h" | 5 #include "chrome/test/logging/win/mof_data_parser.h" |
6 | 6 |
7 namespace logging_win { | 7 namespace logging_win { |
8 | 8 |
9 MofDataParser::MofDataParser(const EVENT_TRACE* event) | 9 MofDataParser::MofDataParser(const EVENT_TRACE* event) |
10 : scan_(reinterpret_cast<const uint8*>(event->MofData)), | 10 : scan_(reinterpret_cast<const uint8_t*>(event->MofData)), |
11 length_(event->MofLength) { | 11 length_(event->MofLength) {} |
12 } | |
13 | 12 |
14 bool MofDataParser::ReadString(base::StringPiece* value) { | 13 bool MofDataParser::ReadString(base::StringPiece* value) { |
15 const uint8* str_scan = scan_; | 14 const uint8_t* str_scan = scan_; |
16 const uint8* const str_end = str_scan + length_; | 15 const uint8_t* const str_end = str_scan + length_; |
17 while (str_scan < str_end && *str_scan != 0) | 16 while (str_scan < str_end && *str_scan != 0) |
18 ++str_scan; | 17 ++str_scan; |
19 if (str_scan == str_end) | 18 if (str_scan == str_end) |
20 return false; | 19 return false; |
21 size_t string_length = str_scan - scan_; | 20 size_t string_length = str_scan - scan_; |
22 bool has_trailing_newline = (string_length > 0 && str_scan[-1] == '\n'); | 21 bool has_trailing_newline = (string_length > 0 && str_scan[-1] == '\n'); |
23 value->set(reinterpret_cast<const char*>(scan_), | 22 value->set(reinterpret_cast<const char*>(scan_), |
24 has_trailing_newline ? string_length - 1 : string_length); | 23 has_trailing_newline ? string_length - 1 : string_length); |
25 Advance(string_length + 1); | 24 Advance(string_length + 1); |
26 return true; | 25 return true; |
27 } | 26 } |
28 | 27 |
29 } // namespace logging_win | 28 } // namespace logging_win |
OLD | NEW |