Home | History | Annotate | Download | only in win
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/test/logging/win/mof_data_parser.h"
      6 
      7 namespace logging_win {
      8 
      9 MofDataParser::MofDataParser(const EVENT_TRACE* event)
     10     : scan_(reinterpret_cast<const uint8*>(event->MofData)),
     11       length_(event->MofLength) {
     12 }
     13 
     14 bool MofDataParser::ReadString(base::StringPiece* value) {
     15   const uint8* str_scan = scan_;
     16   const uint8* const str_end = str_scan + length_;
     17   while (str_scan < str_end && *str_scan != 0)
     18     ++str_scan;
     19   if (str_scan == str_end)
     20     return false;
     21   size_t string_length = str_scan - scan_;
     22   bool has_trailing_newline = (string_length > 0 && str_scan[-1] == '\n');
     23   value->set(reinterpret_cast<const char*>(scan_),
     24     has_trailing_newline ? string_length - 1 : string_length);
     25   Advance(string_length + 1);
     26   return true;
     27 }
     28 
     29 }  // namespace logging_win
     30