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

Side by Side Diff: utils.h

Issue 3530011: AU: ApplyMap utility function (Closed) Base URL: ssh://git@chromiumos-git/update_engine.git
Patch Set: fixes for review 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 | « no previous file | utils_unittest.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 OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
7 7
8 #include <errno.h> 8 #include <errno.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 vect.end(), 175 vect.end(),
176 value); 176 value);
177 if (it == vect.end()) { 177 if (it == vect.end()) {
178 return false; 178 return false;
179 } else { 179 } else {
180 *out_index = it - vect.begin(); 180 *out_index = it - vect.begin();
181 return true; 181 return true;
182 } 182 }
183 } 183 }
184 184
185 template<typename ValueType>
186 void ApplyMap(std::vector<ValueType>* collection,
187 const std::map<ValueType, ValueType>& the_map) {
188 for (typename std::vector<ValueType>::iterator it = collection->begin();
189 it != collection->end(); ++it) {
190 typename std::map<ValueType, ValueType>::const_iterator map_it =
191 the_map.find(*it);
192 if (map_it != the_map.end()) {
193 *it = map_it->second;
194 }
195 }
196 }
197
185 // Returns the currently booted device. "/dev/sda3", for example. 198 // Returns the currently booted device. "/dev/sda3", for example.
186 // This will not interpret LABEL= or UUID=. You'll need to use findfs 199 // This will not interpret LABEL= or UUID=. You'll need to use findfs
187 // or something with equivalent funcionality to interpret those. 200 // or something with equivalent funcionality to interpret those.
188 const std::string BootDevice(); 201 const std::string BootDevice();
189 202
190 // Returns the currently booted kernel device, "dev/sda2", for example. 203 // Returns the currently booted kernel device, "dev/sda2", for example.
191 // Client must pass in the boot device. The suggested calling convention 204 // Client must pass in the boot device. The suggested calling convention
192 // is: BootKernelDevice(BootDevice()). 205 // is: BootKernelDevice(BootDevice()).
193 // This function works by doing string modification on boot_device. 206 // This function works by doing string modification on boot_device.
194 // Returns empty string on failure. 207 // Returns empty string on failure.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 bool _success = (_x); \ 350 bool _success = (_x); \
338 if (!_success) { \ 351 if (!_success) { \
339 LOG(ERROR) << #_x " failed."; \ 352 LOG(ERROR) << #_x " failed."; \
340 return; \ 353 return; \
341 } \ 354 } \
342 } while (0) 355 } while (0)
343 356
344 357
345 358
346 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 359 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
OLDNEW
« no previous file with comments | « no previous file | utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698