OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
13 class Version { | 13 class Version { |
14 public: | 14 public: |
15 | |
16 // The version string must be made up of 1 or more uint16's separated | 15 // The version string must be made up of 1 or more uint16's separated |
17 // by '.'. Returns NULL if string is not in this format. | 16 // by '.'. Returns NULL if string is not in this format. |
18 // Caller is responsible for freeing the Version object once done. | 17 // Caller is responsible for freeing the Version object once done. |
19 static Version* GetVersionFromString(const std::wstring& version_str); | 18 static Version* GetVersionFromString(const std::wstring& version_str); |
20 static Version* GetVersionFromString(const std::string& version_str); | 19 static Version* GetVersionFromString(const std::string& version_str); |
21 | 20 |
22 ~Version() {} | 21 ~Version() {} |
23 | 22 |
24 bool Equals(const Version& other) const; | 23 bool Equals(const Version& other) const; |
25 | 24 |
26 // Returns -1, 0, 1 for <, ==, >. | 25 // Returns -1, 0, 1 for <, ==, >. |
27 int CompareTo(const Version& other) const; | 26 int CompareTo(const Version& other) const; |
28 | 27 |
29 // Return the string representation of this version. | 28 // Return the string representation of this version. |
30 const std::string GetString() const; | 29 const std::string GetString() const; |
31 | 30 |
32 const std::vector<uint16>& components() const { return components_; } | 31 const std::vector<uint16>& components() const { return components_; } |
33 | 32 |
34 private: | 33 private: |
35 Version() {} | 34 Version() {} |
36 bool InitFromString(const std::string& version_str); | 35 bool InitFromString(const std::string& version_str); |
37 | 36 |
38 std::vector<uint16> components_; | 37 std::vector<uint16> components_; |
39 | |
40 DISALLOW_COPY_AND_ASSIGN(Version); | |
41 }; | 38 }; |
42 | 39 |
43 #endif // BASE_VERSION_H_ | 40 #endif // BASE_VERSION_H_ |
44 | 41 |
OLD | NEW |