Sha256: c2002d2651566e8554ffee3cd001e948678096c3723dca1da4a02f3421f9a1a6

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

/**
 * @file
 * Defines helpers for parsing various version strings
 */
#pragma once

#include <string>
#include <tuple>

namespace facter { namespace util { namespace versions {
    /**
     * Helper function for parsing X.Y from an arbitrary version
     * string. If there is a .Z component, it will be ignored.
     * @param version the version string to parse
     * @return A tuple of <maj, min>
     */
    inline std::tuple<std::string, std::string> major_minor(const std::string& version)
    {
         std::string major, minor;
         auto pos = version.find('.');
         if (pos != std::string::npos) {
              auto second = version.find('.', pos+1);
              decltype(second) end;
              major = version.substr(0, pos);
              if (second != std::string::npos) {
                   end = second - (pos + 1);
              } else {
                   end = std::string::npos;
              }
              minor = version.substr(pos+1, end);
         }
         return std::make_tuple(std::move(major), std::move(minor));
    }
}}}  // namespace facter::util::versions

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/inc/internal/util/versions.hpp
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/inc/internal/util/versions.hpp
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/inc/internal/util/versions.hpp