OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
Scott Hess - ex-Googler
2011/06/07 17:52:25
Sneaky. I like it.
| |
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 #include "base/version.h" | 5 #include "base/version.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 | 13 |
14 Version::Version() { | 14 Version::Version() { |
15 } | 15 } |
16 | 16 |
17 Version::~Version() { | |
18 } | |
19 | |
17 Version::Version(const std::string& version_str) { | 20 Version::Version(const std::string& version_str) { |
18 std::vector<std::string> numbers; | 21 std::vector<std::string> numbers; |
19 base::SplitString(version_str, '.', &numbers); | 22 base::SplitString(version_str, '.', &numbers); |
20 if (numbers.empty()) | 23 if (numbers.empty()) |
21 return; | 24 return; |
22 std::vector<uint16> parsed; | 25 std::vector<uint16> parsed; |
23 for (std::vector<std::string>::iterator i = numbers.begin(); | 26 for (std::vector<std::string>::iterator i = numbers.begin(); |
24 i != numbers.end(); ++i) { | 27 i != numbers.end(); ++i) { |
25 int num; | 28 int num; |
26 if (!base::StringToInt(*i, &num)) | 29 if (!base::StringToInt(*i, &num)) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 DCHECK(IsValid()); | 93 DCHECK(IsValid()); |
91 std::string version_str; | 94 std::string version_str; |
92 size_t count = components_.size(); | 95 size_t count = components_.size(); |
93 for (size_t i = 0; i < count - 1; ++i) { | 96 for (size_t i = 0; i < count - 1; ++i) { |
94 version_str.append(base::IntToString(components_[i])); | 97 version_str.append(base::IntToString(components_[i])); |
95 version_str.append("."); | 98 version_str.append("."); |
96 } | 99 } |
97 version_str.append(base::IntToString(components_[count - 1])); | 100 version_str.append(base::IntToString(components_[count - 1])); |
98 return version_str; | 101 return version_str; |
99 } | 102 } |
OLD | NEW |