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

Side by Side Diff: src/platform/update_engine/utils.h

Issue 578009: AU: Some graph types and a couple utility functions (Closed)
Patch Set: Created 10 years, 10 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
OLDNEW
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 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return s.find(k) != s.end(); 73 return s.find(k) != s.end();
74 } 74 }
75 75
76 template<typename ValueType> 76 template<typename ValueType>
77 std::set<ValueType> SetWithValue(const ValueType& value) { 77 std::set<ValueType> SetWithValue(const ValueType& value) {
78 std::set<ValueType> ret; 78 std::set<ValueType> ret;
79 ret.insert(value); 79 ret.insert(value);
80 return ret; 80 return ret;
81 } 81 }
82 82
83 template<typename T>
84 bool VectorContainsValue(const T& value, const std::vector<T>& vect) {
Daniel Erat 2010/02/05 17:55:19 this is easier (from <algorithm>): return std::fi
adlr 2010/02/22 23:27:31 Done.
85 for (typename std::vector<T>::const_iterator it = vect.begin();
86 it != vect.end(); ++it) {
87 if (*it == value)
88 return true;
89 }
90 return false;
91 }
92
83 // Returns the currently booted device. "/dev/sda1", for example. 93 // Returns the currently booted device. "/dev/sda1", for example.
84 // This will not interpret LABEL= or UUID=. You'll need to use findfs 94 // This will not interpret LABEL= or UUID=. You'll need to use findfs
85 // or something with equivalent funcionality to interpret those. 95 // or something with equivalent funcionality to interpret those.
86 const std::string BootDevice(); 96 const std::string BootDevice();
87 97
88 } // namespace utils 98 } // namespace utils
89 99
90 // Class to unmount FS when object goes out of scope 100 // Class to unmount FS when object goes out of scope
91 class ScopedFilesystemUnmounter { 101 class ScopedFilesystemUnmounter {
92 public: 102 public:
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 bool _success = (_x); \ 193 bool _success = (_x); \
184 if (!_success) { \ 194 if (!_success) { \
185 LOG(ERROR) << #_x " failed."; \ 195 LOG(ERROR) << #_x " failed."; \
186 return; \ 196 return; \
187 } \ 197 } \
188 } while (0) 198 } while (0)
189 199
190 200
191 201
192 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ 202 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698