security/sandbox/chromium/base/version.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_VERSION_H_
michael@0 6 #define BASE_VERSION_H_
michael@0 7
michael@0 8 #include <string>
michael@0 9 #include <vector>
michael@0 10
michael@0 11 #include "base/base_export.h"
michael@0 12 #include "base/basictypes.h"
michael@0 13
michael@0 14 namespace base {
michael@0 15
michael@0 16 // Version represents a dotted version number, like "1.2.3.4", supporting
michael@0 17 // parsing and comparison.
michael@0 18 class BASE_EXPORT Version {
michael@0 19 public:
michael@0 20 // The only thing you can legally do to a default constructed
michael@0 21 // Version object is assign to it.
michael@0 22 Version();
michael@0 23
michael@0 24 ~Version();
michael@0 25
michael@0 26 // Initializes from a decimal dotted version number, like "0.1.1".
michael@0 27 // Each component is limited to a uint16. Call IsValid() to learn
michael@0 28 // the outcome.
michael@0 29 explicit Version(const std::string& version_str);
michael@0 30
michael@0 31 // Returns true if the object contains a valid version number.
michael@0 32 bool IsValid() const;
michael@0 33
michael@0 34 // Returns true if the version wildcard string is valid. The version wildcard
michael@0 35 // string may end with ".*" (e.g. 1.2.*, 1.*). Any other arrangement with "*"
michael@0 36 // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard
michael@0 37 // Version behavior (IsValid) if no wildcard is present.
michael@0 38 static bool IsValidWildcardString(const std::string& wildcard_string);
michael@0 39
michael@0 40 // Commonly used pattern. Given a valid version object, compare if a
michael@0 41 // |version_str| results in a newer version. Returns true if the
michael@0 42 // string represents valid version and if the version is greater than
michael@0 43 // than the version of this object.
michael@0 44 bool IsOlderThan(const std::string& version_str) const;
michael@0 45
michael@0 46 bool Equals(const Version& other) const;
michael@0 47
michael@0 48 // Returns -1, 0, 1 for <, ==, >.
michael@0 49 int CompareTo(const Version& other) const;
michael@0 50
michael@0 51 // Given a valid version object, compare if a |wildcard_string| results in a
michael@0 52 // newer version. This function will default to CompareTo if the string does
michael@0 53 // not end in wildcard sequence ".*". IsValidWildcard(wildcard_string) must be
michael@0 54 // true before using this function.
michael@0 55 int CompareToWildcardString(const std::string& wildcard_string) const;
michael@0 56
michael@0 57 // Return the string representation of this version.
michael@0 58 const std::string GetString() const;
michael@0 59
michael@0 60 const std::vector<uint16>& components() const { return components_; }
michael@0 61
michael@0 62 private:
michael@0 63 std::vector<uint16> components_;
michael@0 64 };
michael@0 65
michael@0 66 } // namespace base
michael@0 67
michael@0 68 // TODO(xhwang) remove this when all users are updated to explicitly use the
michael@0 69 // namespace
michael@0 70 using base::Version;
michael@0 71
michael@0 72 #endif // BASE_VERSION_H_

mercurial