/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include using namespace apache::thrift; using namespace static_reflection::demo; struct print_namespace { template void operator()(fatal::indexed_pair) const { std::cout << " namespace for '" << fatal::z_data() << "'\n"; } }; struct print_enum_member { template void operator()(fatal::indexed) const { std::cout << " " << fatal::z_data() << '\n'; } }; struct print_enum { template void operator()(fatal::indexed_pair) const { using info = fatal::enum_traits; std::cout << " enum " << fatal::z_data() << " {\n"; fatal::foreach(print_enum_member()); std::cout << " }\n\n"; } }; struct print_variant_member { template void operator()(fatal::indexed) const { std::cout << " " << fatal::z_data() << '\n'; } }; struct print_variant { template void operator()(fatal::indexed_pair) const { using info = fatal::variant_traits; std::cout << " variant " << fatal::z_data() << " {\n"; fatal::foreach(print_variant_member()); std::cout << " }\n\n"; } }; struct print_struct_member { template void operator()(fatal::indexed) const { std::cout << " " << fatal::z_data() << '\n'; } }; struct print_struct { template void operator()(fatal::indexed_pair) const { using info = reflect_struct; std::cout << " struct " << fatal::z_data() << " {\n"; fatal::foreach(print_struct_member()); std::cout << " }\n\n"; } }; template void print_module_info() { using info = reflect_module; std::cout << "module name: " << fatal::z_data() << '\n'; std::cout << '\n'; std::cout << "namespaces declared in module\n"; fatal::foreach(print_namespace()); std::cout << '\n'; std::cout << "enums declared in module\n"; fatal::foreach(print_enum()); std::cout << "variants declared in module\n"; fatal::foreach(print_variant()); std::cout << "structs declared in module\n"; fatal::foreach(print_struct()); } int main() { print_module_info(); return 0; }