Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: base/version.h

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/version.cc » ('j') | base/version.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « no previous file | base/version.cc » ('j') | base/version.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698