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

Side by Side Diff: remoting/base/name_value_map.h

Issue 2807803002: Move name_value_map to remoting/base (Closed)
Patch Set: sync Created 3 years, 8 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 | « remoting/base/chromoting_event.cc ('k') | remoting/host/host_exit_codes.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 // Helper functions that allow to map enum values to strings. 5 // Helper functions that allow to map enum values to strings.
6 6
7 #ifndef REMOTING_PROTOCOL_NAME_VALUE_MAP_H_ 7 #ifndef REMOTING_BASE_NAME_VALUE_MAP_H_
8 #define REMOTING_PROTOCOL_NAME_VALUE_MAP_H_ 8 #define REMOTING_BASE_NAME_VALUE_MAP_H_
9 9
10 #include <stddef.h> 10 #include <stddef.h>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 namespace protocol {
16 15
17 template <typename T> 16 template <typename T>
18 struct NameMapElement { 17 struct NameMapElement {
19 const T value; 18 const T value;
20 const char* const name; 19 const char* const name;
21 }; 20 };
22 21
23 template <typename T, size_t N> 22 template <typename T, size_t N>
24 const char* ValueToName(const NameMapElement<T> (&map)[N], T value) { 23 const char* ValueToName(const NameMapElement<T> (&map)[N], T value) {
25 for (size_t i = 0; i < N; ++i) { 24 for (size_t i = 0; i < N; ++i) {
(...skipping 10 matching lines...) Expand all
36 T* result) { 35 T* result) {
37 for (size_t i = 0; i < N; ++i) { 36 for (size_t i = 0; i < N; ++i) {
38 if (map[i].name == name) { 37 if (map[i].name == name) {
39 *result = map[i].value; 38 *result = map[i].value;
40 return true; 39 return true;
41 } 40 }
42 } 41 }
43 return false; 42 return false;
44 } 43 }
45 44
46 } // namespace protocol
47 } // namespace remoting 45 } // namespace remoting
48 46
49 #endif // REMOTING_PROTOCOL_NAME_VALUE_MAP_H_ 47 #endif // REMOTING_BASE_NAME_VALUE_MAP_H_
OLDNEW
« no previous file with comments | « remoting/base/chromoting_event.cc ('k') | remoting/host/host_exit_codes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698