Coverage for /Syzygy/version/syzygy_version.h

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

Line-by-line coverage:

   1    :  // Copyright 2011 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    :  // Version defines.
  16    :  
  17    :  #ifndef SYZYGY_VERSION_SYZYGY_VERSION_H_
  18    :  #define SYZYGY_VERSION_SYZYGY_VERSION_H_
  19    :  
  20    :  #include <stdint.h>
  21    :  #include <string>
  22    :  
  23    :  #include "base/logging.h"
  24    :  #include "syzygy/version/version.gen"
  25    :  
  26    :  namespace version {
  27    :  
  28    :  class SyzygyVersion {
  29    :   public:
  30    :    SyzygyVersion();
  31    :  
  32    :    SyzygyVersion(uint16_t major,
  33    :                  uint16_t minor,
  34    :                  uint16_t build,
  35    :                  uint16_t patch,
  36    :                  const char* last_change);
  37    :  
  38    :    // A comparison operator. If this version is less than @p rhs, returns a value
  39    :    // less than zero. If identical, returns 0. If greater than @p rhs, returns a
  40    :    // value greater than 0. This only compares the version octet, ignoring the
  41    :    // last-change string.
  42    :    int CompareOctet(const SyzygyVersion& rhs) const;
  43    :  
  44    :    // We need an equality operator for serialization testing. This uses strict
  45    :    // equality, including a comparison of the last change string.
  46    :    bool operator==(const SyzygyVersion& rhs) const;
  47    :    bool operator!=(const SyzygyVersion& rhs) const { return !(*this == rhs); }
  48    :  
  49    :    // This returns true if the data/modules created by the given version of the
  50    :    // toolchain are compatible with this version of the toolchain. For now, this
  51    :    // returns true iff the two versions are completely identical, including the
  52    :    // last-change string.
  53    :    bool IsCompatible(const SyzygyVersion& rhs) const;
  54    :  
  55    :    // Returns the whole version as a version string.
  56    :    std::string GetVersionString() const;
  57    :  
  58  E :    uint16_t major() const { return major_; }
  59  E :    uint16_t minor() const { return minor_; }
  60  E :    uint16_t build() const { return build_; }
  61  E :    uint16_t patch() const { return patch_; }
  62  E :    const std::string& last_change() const { return last_change_; }
  63    :  
  64  E :    void set_major(uint16_t major) { major_ = major; }
  65  E :    void set_minor(uint16_t minor) { minor_ = minor; }
  66  E :    void set_build(uint16_t build) { build_ = build; }
  67  E :    void set_patch(uint16_t patch) { patch_ = patch; }
  68  E :    void set_last_change(const char* last_change) {
  69  E :      DCHECK(last_change != NULL);
  70  E :      last_change_ = last_change;
  71  E :    }
  72    :  
  73    :    // For serialization. These are kept templated to remove any dependency
  74    :    // on core_lib, where serialization lives.
  75  E :    template<class OutArchive> bool Save(OutArchive* out_archive) const {
  76  E :      DCHECK(out_archive != NULL);
  77  E :      return out_archive->Save(major_) && out_archive->Save(minor_) &&
  78    :          out_archive->Save(build_) && out_archive->Save(patch_) &&
  79    :          out_archive->Save(last_change_);
  80  E :    }
  81  E :    template<class InArchive> bool Load(InArchive* in_archive) {
  82  E :      DCHECK(in_archive != NULL);
  83  E :      return in_archive->Load(&major_) && in_archive->Load(&minor_) &&
  84    :          in_archive->Load(&build_) && in_archive->Load(&patch_) &&
  85    :          in_archive->Load(&last_change_);
  86  E :    }
  87    :  
  88    :   private:
  89    :    uint16_t major_;
  90    :    uint16_t minor_;
  91    :    uint16_t build_;
  92    :    uint16_t patch_;
  93    :    std::string last_change_;
  94    :  };
  95    :  
  96    :  extern const SyzygyVersion kSyzygyVersion;
  97    :  
  98    :  }  // namespace version
  99    :  
 100    :  #endif  // SYZYGY_VERSION_SYZYGY_VERSION_H_

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