/* * 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 #include #include #include using namespace static_reflection::demo; void print() { std::cout << '\n'; } template void print(T const& value, const Args&... args) { std::cout << value; print(args...); } FATAL_DATA_MEMBER_GETTER(audit_id_getter, audit_id); struct print_audit_id_visitor { template void impl(std::true_type, T const& member, const char* name) const { print("audit id for ", name, ": ", *member.audit_id_ref()); } template void impl(std::false_type, T const& member, const char* name) const { (void)member; print("no audit id available for ", name); } template void operator()(fatal::indexed, T const& variant) const { using has_audit_id = audit_id_getter::has; const auto& member = Member::get(variant); const auto member_name = fatal::z_data(); impl(has_audit_id(), member, member_name); } }; template void print_audit_id(T const& variant) { using info = fatal::variant_traits; fatal::scalar_search( variant.getType(), print_audit_id_visitor(), variant); } int main(int argc, char** argv) { (void)argc, (void)argv; print_audit_id(operations_constants::create_entity()); print_audit_id(operations_constants::query_entity()); print_audit_id(operations_constants::delete_entity()); print_audit_id(operations_constants::add_field()); print_audit_id(operations_constants::query_field()); print_audit_id(operations_constants::delete_field()); return 0; }