OLD | NEW |
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> |
11 | 11 |
12 #include "base/base_api.h" | 12 #include "base/base_api.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 | 15 |
16 // Version represents a dotted version number, like "1.2.3.4", supporting | 16 // Version represents a dotted version number, like "1.2.3.4", supporting |
17 // parsing and comparison. | 17 // parsing and comparison. |
18 class BASE_API Version { | 18 class BASE_API Version { |
19 public: | 19 public: |
20 // The only thing you can legally do to a default constructed | 20 // The only thing you can legally do to a default constructed |
21 // Version object is assign to it. | 21 // Version object is assign to it. |
22 Version(); | 22 Version(); |
23 | 23 |
| 24 ~Version(); |
| 25 |
24 // Initializes from a decimal dotted version number, like "0.1.1". | 26 // Initializes from a decimal dotted version number, like "0.1.1". |
25 // Each component is limited to a uint16. Call IsValid() to learn | 27 // Each component is limited to a uint16. Call IsValid() to learn |
26 // the outcome. | 28 // the outcome. |
27 explicit Version(const std::string& version_str); | 29 explicit Version(const std::string& version_str); |
28 | 30 |
29 // Returns true if the object contains a valid version number. | 31 // Returns true if the object contains a valid version number. |
30 bool IsValid() const; | 32 bool IsValid() const; |
31 | 33 |
32 // Returns NULL if the string is not in the proper format. | 34 // Returns NULL if the string is not in the proper format. |
33 // Caller is responsible for freeing the Version object once done. | 35 // Caller is responsible for freeing the Version object once done. |
(...skipping 12 matching lines...) Expand all Loading... |
46 // Return the string representation of this version. | 48 // Return the string representation of this version. |
47 const std::string GetString() const; | 49 const std::string GetString() const; |
48 | 50 |
49 const std::vector<uint16>& components() const { return components_; } | 51 const std::vector<uint16>& components() const { return components_; } |
50 | 52 |
51 private: | 53 private: |
52 std::vector<uint16> components_; | 54 std::vector<uint16> components_; |
53 }; | 55 }; |
54 | 56 |
55 #endif // BASE_VERSION_H_ | 57 #endif // BASE_VERSION_H_ |
OLD | NEW |