security/sandbox/chromium/base/version.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/version.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_VERSION_H_
     1.9 +#define BASE_VERSION_H_
    1.10 +
    1.11 +#include <string>
    1.12 +#include <vector>
    1.13 +
    1.14 +#include "base/base_export.h"
    1.15 +#include "base/basictypes.h"
    1.16 +
    1.17 +namespace base {
    1.18 +
    1.19 +// Version represents a dotted version number, like "1.2.3.4", supporting
    1.20 +// parsing and comparison.
    1.21 +class BASE_EXPORT Version {
    1.22 + public:
    1.23 +  // The only thing you can legally do to a default constructed
    1.24 +  // Version object is assign to it.
    1.25 +  Version();
    1.26 +
    1.27 +  ~Version();
    1.28 +
    1.29 +  // Initializes from a decimal dotted version number, like "0.1.1".
    1.30 +  // Each component is limited to a uint16. Call IsValid() to learn
    1.31 +  // the outcome.
    1.32 +  explicit Version(const std::string& version_str);
    1.33 +
    1.34 +  // Returns true if the object contains a valid version number.
    1.35 +  bool IsValid() const;
    1.36 +
    1.37 +  // Returns true if the version wildcard string is valid. The version wildcard
    1.38 +  // string may end with ".*" (e.g. 1.2.*, 1.*). Any other arrangement with "*"
    1.39 +  // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard
    1.40 +  // Version behavior (IsValid) if no wildcard is present.
    1.41 +  static bool IsValidWildcardString(const std::string& wildcard_string);
    1.42 +
    1.43 +  // Commonly used pattern. Given a valid version object, compare if a
    1.44 +  // |version_str| results in a newer version. Returns true if the
    1.45 +  // string represents valid version and if the version is greater than
    1.46 +  // than the version of this object.
    1.47 +  bool IsOlderThan(const std::string& version_str) const;
    1.48 +
    1.49 +  bool Equals(const Version& other) const;
    1.50 +
    1.51 +  // Returns -1, 0, 1 for <, ==, >.
    1.52 +  int CompareTo(const Version& other) const;
    1.53 +
    1.54 +  // Given a valid version object, compare if a |wildcard_string| results in a
    1.55 +  // newer version. This function will default to CompareTo if the string does
    1.56 +  // not end in wildcard sequence ".*". IsValidWildcard(wildcard_string) must be
    1.57 +  // true before using this function.
    1.58 +  int CompareToWildcardString(const std::string& wildcard_string) const;
    1.59 +
    1.60 +  // Return the string representation of this version.
    1.61 +  const std::string GetString() const;
    1.62 +
    1.63 +  const std::vector<uint16>& components() const { return components_; }
    1.64 +
    1.65 + private:
    1.66 +  std::vector<uint16> components_;
    1.67 +};
    1.68 +
    1.69 +}  // namespace base
    1.70 +
    1.71 +// TODO(xhwang) remove this when all users are updated to explicitly use the
    1.72 +// namespace
    1.73 +using base::Version;
    1.74 +
    1.75 +#endif  // BASE_VERSION_H_

mercurial