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

Side by Side Diff: base/version.h

Issue 7541015: Add a convenience function to Version (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 13 matching lines...) Expand all
24 ~Version(); 24 ~Version();
25 25
26 // Initializes from a decimal dotted version number, like "0.1.1". 26 // Initializes from a decimal dotted version number, like "0.1.1".
27 // Each component is limited to a uint16. Call IsValid() to learn 27 // Each component is limited to a uint16. Call IsValid() to learn
28 // the outcome. 28 // the outcome.
29 explicit Version(const std::string& version_str); 29 explicit Version(const std::string& version_str);
30 30
31 // Returns true if the object contains a valid version number. 31 // Returns true if the object contains a valid version number.
32 bool IsValid() const; 32 bool IsValid() const;
33 33
34 // Commonly used pattern. Given a valid version object, compare if a
35 // |version_str| results in a newer version. Returns true if the
36 // string represents valid version and if the version is greater than
37 // than the version of this object.
38 bool IsOlderThan(const std::string& version_str) const;
39
34 // Returns NULL if the string is not in the proper format. 40 // Returns NULL if the string is not in the proper format.
35 // Caller is responsible for freeing the Version object once done. 41 // Caller is responsible for freeing the Version object once done.
36 // DO NOT USE FOR NEWER CODE. 42 // DO NOT USE FOR NEWER CODE.
37 static Version* GetVersionFromString(const std::string& version_str); 43 static Version* GetVersionFromString(const std::string& version_str);
38 44
39 // Creates a copy of this version object. Caller takes ownership. 45 // Creates a copy of this version object. Caller takes ownership.
40 // DO NOT USE FOR NEWER CODE. 46 // DO NOT USE FOR NEWER CODE.
41 Version* Clone() const; 47 Version* Clone() const;
42 48
43 bool Equals(const Version& other) const; 49 bool Equals(const Version& other) const;
44 50
45 // Returns -1, 0, 1 for <, ==, >. 51 // Returns -1, 0, 1 for <, ==, >.
46 int CompareTo(const Version& other) const; 52 int CompareTo(const Version& other) const;
47 53
48 // Return the string representation of this version. 54 // Return the string representation of this version.
49 const std::string GetString() const; 55 const std::string GetString() const;
50 56
51 const std::vector<uint16>& components() const { return components_; } 57 const std::vector<uint16>& components() const { return components_; }
52 58
53 private: 59 private:
54 std::vector<uint16> components_; 60 std::vector<uint16> components_;
55 }; 61 };
56 62
57 #endif // BASE_VERSION_H_ 63 #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