Coverage for /Syzygy/common/buffer_parser_impl.h

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

Line-by-line coverage:

   1    :  // Copyright 2015 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_COMMON_BUFFER_PARSER_IMPL_H_
  16    :  #define SYZYGY_COMMON_BUFFER_PARSER_IMPL_H_
  17    :  
  18    :  #ifndef SYZYGY_COMMON_BUFFER_PARSER_H_
  19    :  #error This file is only meant to be included from buffer_parser.h.
  20    :  #endif
  21    :  
  22    :  #include "syzygy/common/align.h"
  23    :  
  24    :  namespace common {
  25    :  
  26    :  namespace detail {
  27    :  
  28    :  // Utility template class for determining the alignment of a given type.
  29    :  template <typename DataType>
  30    :  struct GetAlignment {
  31    :    struct Helper {
  32    :      uint8 foo;
  33    :      DataType bar;
  34    :    };
  35    :    static const size_t kAlignment = offsetof(Helper, bar);
  36    :  };
  37    :  
  38    :  }  // namespace detail
  39    :  
  40    :  template <class DataType>
  41    :  bool BinaryBufferParser::GetAtImplicitAlignment(
  42  E :      size_t pos, size_t size, const DataType** data_ptr) const {
  43  E :    const size_t kAlign = detail::GetAlignment<DataType>::kAlignment;
  44  E :    return GetAtExplicitAlignment(pos, size, kAlign, data_ptr);
  45  E :  }
  46    :  
  47    :  template <class DataType>
  48    :  bool BinaryBufferParser::GetAtExplicitAlignment(
  49  E :      size_t pos, size_t size, size_t align, const DataType** data_ptr) const {
  50  E :    if (!common::IsAligned(data_ + pos, align))
  51  E :      return false;
  52  E :    return GetAt(pos, size, reinterpret_cast<const void**>(data_ptr));
  53  E :  }
  54    :  
  55    :  }  // namespace common
  56    :  
  57    :  #endif  // SYZYGY_COMMON_BUFFER_PARSER_IMPL_H_

Coverage information generated Thu Jan 14 17:40:38 2016.