1 // 2 // Copyright (C) 2017 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef PROPERTY_INFO_SERIALIZER_H 18 #define PROPERTY_INFO_SERIALIZER_H 19 20 #include <string> 21 #include <vector> 22 23 namespace android { 24 namespace properties { 25 26 struct PropertyInfoEntry { 27 PropertyInfoEntry() {} 28 template <typename T, typename U, typename V> 29 PropertyInfoEntry(T&& name, U&& context, V&& type, bool exact_match) 30 : name(std::forward<T>(name)), 31 context(std::forward<U>(context)), 32 type(std::forward<V>(type)), 33 exact_match(exact_match) {} 34 std::string name; 35 std::string context; 36 std::string type; 37 bool exact_match; 38 }; 39 40 bool BuildTrie(const std::vector<PropertyInfoEntry>& property_info, 41 const std::string& default_context, const std::string& default_type, 42 std::string* serialized_trie, std::string* error); 43 44 void ParsePropertyInfoFile(const std::string& file_contents, 45 std::vector<PropertyInfoEntry>* property_infos, 46 std::vector<std::string>* errors); 47 48 } // namespace properties 49 } // namespace android 50 51 #endif 52