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

Side by Side Diff: base/version.h

Issue 2163033002: base::Version constructor from std::vector<uint32_t> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes based on nit comments Created 4 years, 5 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') | no next file with comments »
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 9
10 #include <iosfwd> 10 #include <iosfwd>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/base_export.h" 14 #include "base/base_export.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 // Version represents a dotted version number, like "1.2.3.4", supporting 18 // Version represents a dotted version number, like "1.2.3.4", supporting
19 // parsing and comparison. 19 // parsing and comparison.
20 class BASE_EXPORT Version { 20 class BASE_EXPORT Version {
21 public: 21 public:
22 // The only thing you can legally do to a default constructed 22 // The only thing you can legally do to a default constructed
23 // Version object is assign to it. 23 // Version object is assign to it.
24 Version(); 24 Version();
25 25
26 Version(const Version& other); 26 Version(const Version& other);
27 27
28 ~Version();
29
30 // Initializes from a decimal dotted version number, like "0.1.1". 28 // Initializes from a decimal dotted version number, like "0.1.1".
31 // Each component is limited to a uint16_t. Call IsValid() to learn 29 // Each component is limited to a uint16_t. Call IsValid() to learn
32 // the outcome. 30 // the outcome.
33 explicit Version(const std::string& version_str); 31 explicit Version(const std::string& version_str);
34 32
33 // Initializes from a vector of components, like {1, 2, 3, 4}. Call IsValid()
34 // to learn the outcome.
35 explicit Version(std::vector<uint32_t> components);
36
37 ~Version();
38
35 // Returns true if the object contains a valid version number. 39 // Returns true if the object contains a valid version number.
36 bool IsValid() const; 40 bool IsValid() const;
37 41
38 // Returns true if the version wildcard string is valid. The version wildcard 42 // Returns true if the version wildcard string is valid. The version wildcard
39 // string may end with ".*" (e.g. 1.2.*, 1.*). Any other arrangement with "*" 43 // string may end with ".*" (e.g. 1.2.*, 1.*). Any other arrangement with "*"
40 // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard 44 // is invalid (e.g. 1.*.3 or 1.2.3*). This functions defaults to standard
41 // Version behavior (IsValid) if no wildcard is present. 45 // Version behavior (IsValid) if no wildcard is present.
42 static bool IsValidWildcardString(const std::string& wildcard_string); 46 static bool IsValidWildcardString(const std::string& wildcard_string);
43 47
44 // Returns -1, 0, 1 for <, ==, >. 48 // Returns -1, 0, 1 for <, ==, >.
(...skipping 22 matching lines...) Expand all
67 BASE_EXPORT bool operator>=(const Version& v1, const Version& v2); 71 BASE_EXPORT bool operator>=(const Version& v1, const Version& v2);
68 BASE_EXPORT std::ostream& operator<<(std::ostream& stream, const Version& v); 72 BASE_EXPORT std::ostream& operator<<(std::ostream& stream, const Version& v);
69 73
70 } // namespace base 74 } // namespace base
71 75
72 // TODO(xhwang) remove this when all users are updated to explicitly use the 76 // TODO(xhwang) remove this when all users are updated to explicitly use the
73 // namespace 77 // namespace
74 using base::Version; 78 using base::Version;
75 79
76 #endif // BASE_VERSION_H_ 80 #endif // BASE_VERSION_H_
OLDNEW
« no previous file with comments | « no previous file | base/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698