1 /*
2 **
3 ** Copyright 2016, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18 #include "keymaster_tags.h"
19
20 namespace android {
21 namespace hardware {
22 namespace keymaster {
23 namespace V3_0 {
24
25 template <typename TagList> struct TagStringifier;
26
27 template <typename... Tags> struct TagStringifier<MetaList<Tags...>> {
28 template <TagType tag_type, Tag tag>
29 static TypedTag<tag_type, tag> chooseString(TypedTag<tag_type, tag> ttag, Tag runtime_tag,
30 const char** result) {
31 if (tag == runtime_tag) {
32 *result = Tag2String<tag>::value();
33 }
34 return ttag;
35 }
36 static const char* stringify(Tag tag) {
37 const char* result = "unknown tag";
__anon8113e1d20102(Tags&&...) 38 [](Tags&&...) {}(chooseString(Tags(), tag, &result)...);
39 return result;
40 }
41 };
42
stringifyTag(Tag tag)43 const char* stringifyTag(Tag tag) {
44 return TagStringifier<all_tags_t>::stringify(tag);
45 }
46
47 } // namespace V3_0
48 } // namespace keymaster
49 } // namespace hardware
50 } // namespace android
51