Coverage for /Syzygy/pdb/pdb_stream_reader.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%110.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc. All Rights Reserved.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  
  15    :  #ifndef SYZYGY_PDB_PDB_STREAM_READER_H_
  16    :  #define SYZYGY_PDB_PDB_STREAM_READER_H_
  17    :  
  18    :  #include "syzygy/common/binary_stream.h"
  19    :  #include "syzygy/pdb/pdb_stream.h"
  20    :  
  21    :  namespace pdb {
  22    :  
  23    :  // An adapter class that implements a BinaryStreamReader over a subset of
  24    :  // a PdbStream.
  25    :  class PdbStreamReaderWithPosition : public common::BinaryStreamReader {
  26    :   public:
  27    :    // Creates a reader over the entirety of @p stream.
  28    :    // @param stream the stream to read.
  29    :    explicit PdbStreamReaderWithPosition(PdbStream* stream);
  30    :    // Creates a reader over a sub-range of @p stream.
  31    :    // @param start_offset where to start reading in @p stream.
  32    :    // @param len the length, in bytes this reader will read.
  33    :    // @param stream the stream to read.
  34    :    // @pre @p start_offset + @p len <= stream->length().
  35    :    PdbStreamReaderWithPosition(size_t start_offset,
  36    :                                size_t len,
  37    :                                PdbStream* stream);
  38    :  
  39    :    // Creates an invalid reader, SetStream must be invoked before using this
  40    :    // instance.
  41    :    PdbStreamReaderWithPosition();
  42    :  
  43    :    // Set the stream this reader presents.
  44    :    // @param start_offset where to start reading in @p stream.
  45    :    // @param len the length, in bytes this reader will read.
  46    :    // @param stream the stream to read.
  47    :    // @pre @p start_offset + @p len <= stream->length().
  48    :    // @pre stream() == nullptr.
  49    :    void SetStream(size_t start_offset, size_t len, PdbStream* stream);
  50    :  
  51    :    // @name BinaryStreamReader implementation.
  52    :    // @pre stream() != nullptr.
  53    :    // @{
  54    :    bool Read(size_t len, void* out) override;
  55    :    size_t Position() const override;
  56    :    bool AtEnd() const override;
  57    :    // @}
  58    :  
  59    :    // Consumes the next @p len bytes.
  60    :    // @param len the number of bytes to consume.
  61    :    // @returns true on success, false on failure. On failure the stream position
  62    :    //     is unchanged.
  63    :    bool Consume(size_t len);
  64    :  
  65    :    // @name Accessors.
  66    :    // @{
  67  E :    scoped_refptr<PdbStream> stream() const { return stream_; }
  68    :    // @}
  69    :  
  70    :   private:
  71    :    // The start offset into stream_.
  72    :    size_t start_offset_;
  73    :  
  74    :    // The length of this stream.
  75    :    size_t length_;
  76    :  
  77    :    // The read position within this stream, from 0 to length_.
  78    :    size_t pos_;
  79    :  
  80    :    // The PdbStream exposed on this reader.
  81    :    scoped_refptr<PdbStream> stream_;
  82    :  
  83    :    DISALLOW_ASSIGN(PdbStreamReaderWithPosition);
  84    :  };
  85    :  
  86    :  }  // namespace pdb
  87    :  
  88    :  #endif  // SYZYGY_PDB_PDB_STREAM_READER_H_

Coverage information generated Fri Jul 29 11:00:21 2016.