Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_VERSION_H_ | 5 #ifndef BASE_VERSION_H_ |
| 6 #define BASE_VERSION_H_ | 6 #define BASE_VERSION_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard | 36 // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard |
| 37 // Version behavior (IsValid) if no wildcard is present. | 37 // Version behavior (IsValid) if no wildcard is present. |
| 38 static bool IsValidWildcardString(const std::string& wildcard_string); | 38 static bool IsValidWildcardString(const std::string& wildcard_string); |
| 39 | 39 |
| 40 // Commonly used pattern. Given a valid version object, compare if a | 40 // Commonly used pattern. Given a valid version object, compare if a |
| 41 // |version_str| results in a newer version. Returns true if the | 41 // |version_str| results in a newer version. Returns true if the |
| 42 // string represents valid version and if the version is greater than | 42 // string represents valid version and if the version is greater than |
| 43 // than the version of this object. | 43 // than the version of this object. |
| 44 bool IsOlderThan(const std::string& version_str) const; | 44 bool IsOlderThan(const std::string& version_str) const; |
| 45 | 45 |
| 46 bool Equals(const Version& other) const; | |
| 47 | |
| 48 // Returns -1, 0, 1 for <, ==, >. | 46 // Returns -1, 0, 1 for <, ==, >. |
| 49 int CompareTo(const Version& other) const; | 47 int CompareTo(const Version& other) const; |
| 50 | 48 |
| 51 // Given a valid version object, compare if a |wildcard_string| results in a | 49 // Given a valid version object, compare if a |wildcard_string| results in a |
| 52 // newer version. This function will default to CompareTo if the string does | 50 // newer version. This function will default to CompareTo if the string does |
| 53 // not end in wildcard sequence ".*". IsValidWildcard(wildcard_string) must be | 51 // not end in wildcard sequence ".*". IsValidWildcard(wildcard_string) must be |
| 54 // true before using this function. | 52 // true before using this function. |
| 55 int CompareToWildcardString(const std::string& wildcard_string) const; | 53 int CompareToWildcardString(const std::string& wildcard_string) const; |
| 56 | 54 |
| 57 // Return the string representation of this version. | 55 // Return the string representation of this version. |
| 58 const std::string GetString() const; | 56 const std::string GetString() const; |
| 59 | 57 |
| 60 const std::vector<uint32_t>& components() const { return components_; } | 58 const std::vector<uint32_t>& components() const { return components_; } |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 std::vector<uint32_t> components_; | 61 std::vector<uint32_t> components_; |
| 64 }; | 62 }; |
| 65 | 63 |
| 64 BASE_EXPORT bool operator==(const Version& v1, const Version& v2); | |
| 65 BASE_EXPORT bool operator!=(const Version& v1, const Version& v2); | |
| 66 BASE_EXPORT bool operator<(const Version& v1, const Version& v2); | |
| 67 BASE_EXPORT bool operator<=(const Version& v1, const Version& v2); | |
| 68 BASE_EXPORT bool operator>(const Version& v1, const Version& v2); | |
| 69 BASE_EXPORT bool operator>=(const Version& v1, const Version& v2); | |
| 70 BASE_EXPORT std::ostream& operator<<(std::ostream& stream, const Version& v); | |
|
brettw
2016/01/08 19:31:16
I think you need to include iosfwd so ostream is d
Rob Percival
2016/01/09 23:54:03
Done.
| |
| 71 | |
| 66 } // namespace base | 72 } // namespace base |
| 67 | 73 |
| 68 // TODO(xhwang) remove this when all users are updated to explicitly use the | 74 // TODO(xhwang) remove this when all users are updated to explicitly use the |
| 69 // namespace | 75 // namespace |
| 70 using base::Version; | 76 using base::Version; |
| 71 | 77 |
| 72 #endif // BASE_VERSION_H_ | 78 #endif // BASE_VERSION_H_ |
| OLD | NEW |