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

Unified Diff: base/version.h

Issue 7105008: Clean up base/Version (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/version.cc » ('j') | base/version.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/version.h
===================================================================
--- base/version.h (revision 86383)
+++ base/version.h (working copy)
@@ -15,22 +15,29 @@
// Version represents a dotted version number, like "1.2.3.4", supporting
// parsing and comparison.
-// Each component is limited to a uint16.
class BASE_API Version {
public:
- // Exposed only so that a Version can be stored in STL containers;
- // any call to the methods below on a default-constructed Version
- // will DCHECK.
+ // The only two things you can legally do to a default constructed
+ // Version object is assign to it and call InitFromString().
Version();
- ~Version();
+ // Initializes from a decimal dotted version number. See InitFromString()
+ // for constraints on the inputs.
Evan Martin 2011/06/06 23:35:13 What happens to the return value of InitFromString
+ explicit Version(const std::string& version_str);
- // The version string must be made up of 1 or more uint16's separated
- // by '.'. Returns NULL if string is not in this format.
- // Caller is responsible for freeing the Version object once done.
+ // Initializes from a decimal dotted version number, like "0.1.1".
+ // Each component is limited to a uint16. Returns false if any of the
+ // components is not convertible to uint16.
+ bool InitFromString(const std::string& version_str);
+
+ // Same as InitFromString Returns NULL if the string is not in the
+ // propper format. Caller is responsible for freeing the Version
Evan Martin 2011/06/06 23:35:13 Typo: maybe meant a period before capitalized "Ret
+ // object once done.
+ // DO NOT USE FOR NEWER CODE.
static Version* GetVersionFromString(const std::string& version_str);
// Creates a copy of this version. Caller takes ownership.
+ // DO NOT USE FOR NEWER CODE.
Version* Clone() const;
bool Equals(const Version& other) const;
@@ -38,20 +45,17 @@
// Returns -1, 0, 1 for <, ==, >.
int CompareTo(const Version& other) const;
+ // Returns true if at least the version has one valid
+ // component. For example 12 and 12.2 are both valid versions.
+ bool IsValid() const;
+
// Return the string representation of this version.
const std::string GetString() const;
const std::vector<uint16>& components() const { return components_; }
private:
- bool InitFromString(const std::string& version_str);
-
- bool is_valid_;
std::vector<uint16> components_;
-
- FRIEND_TEST_ALL_PREFIXES(VersionTest, DefaultConstructor);
- FRIEND_TEST_ALL_PREFIXES(VersionTest, GetVersionFromString);
- FRIEND_TEST_ALL_PREFIXES(VersionTest, Compare);
};
#endif // BASE_VERSION_H_
« 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