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

Side by Side Diff: base/version.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « base/string_util.h ('k') | chrome/app/breakpad_win.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "base/version.h" 5 #include "base/version.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 version_str.append(base::IntToString(components_[i])); 68 version_str.append(base::IntToString(components_[i]));
69 version_str.append("."); 69 version_str.append(".");
70 } 70 }
71 version_str.append(base::IntToString(components_[count - 1])); 71 version_str.append(base::IntToString(components_[count - 1]));
72 return version_str; 72 return version_str;
73 } 73 }
74 74
75 bool Version::InitFromString(const std::string& version_str) { 75 bool Version::InitFromString(const std::string& version_str) {
76 DCHECK(!is_valid_); 76 DCHECK(!is_valid_);
77 std::vector<std::string> numbers; 77 std::vector<std::string> numbers;
78 SplitString(version_str, '.', &numbers); 78 base::SplitString(version_str, '.', &numbers);
79 if (numbers.empty()) 79 if (numbers.empty())
80 return false; 80 return false;
81 for (std::vector<std::string>::iterator i = numbers.begin(); 81 for (std::vector<std::string>::iterator i = numbers.begin();
82 i != numbers.end(); ++i) { 82 i != numbers.end(); ++i) {
83 int num; 83 int num;
84 if (!base::StringToInt(*i, &num)) 84 if (!base::StringToInt(*i, &num))
85 return false; 85 return false;
86 if (num < 0) 86 if (num < 0)
87 return false; 87 return false;
88 const uint16 max = 0xFFFF; 88 const uint16 max = 0xFFFF;
89 if (num > max) 89 if (num > max)
90 return false; 90 return false;
91 // This throws out things like +3, or 032. 91 // This throws out things like +3, or 032.
92 if (base::IntToString(num) != *i) 92 if (base::IntToString(num) != *i)
93 return false; 93 return false;
94 uint16 component = static_cast<uint16>(num); 94 uint16 component = static_cast<uint16>(num);
95 components_.push_back(component); 95 components_.push_back(component);
96 } 96 }
97 is_valid_ = true; 97 is_valid_ = true;
98 return true; 98 return true;
99 } 99 }
OLDNEW
« no previous file with comments | « base/string_util.h ('k') | chrome/app/breakpad_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698