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

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

Issue 10829324: Add mux-stream transport support in session description (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | remoting/protocol/session_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Helper functions that allow to map enum values to strings.
6
7 namespace remoting {
8 namespace protocol {
9
10 template <typename T>
11 struct NameMapElement {
12 const T value;
13 const char* const name;
14 };
15
16 template <typename T, size_t N>
17 const char* ValueToName(const NameMapElement<T> (&map)[N], T value) {
18 for (size_t i = 0; i < N; ++i) {
19 if (map[i].value == value)
20 return map[i].name;
21 }
22 NOTREACHED();
23 return NULL;
24 }
25
26 template <typename T, size_t N>
27 bool NameToValue(const NameMapElement<T> (&map)[N],
28 const std::string& name,
29 T* result) {
30 for (size_t i = 0; i < N; ++i) {
31 if (map[i].name == name) {
32 *result = map[i].value;
33 return true;
34 }
35 }
36 return false;
37 }
38
39 } // namespace protocol
40 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_messages.cc ('k') | remoting/protocol/session_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698