// Copyright 2020 Google LLC // // 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 // // https://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. #ifndef GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_DESCRIPTOR_UTILS_H #define GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_DESCRIPTOR_UTILS_H #include "generator/internal/generator_interface.h" #include "generator/internal/predicate_utils.h" #include "generator/internal/printer.h" #include #include #include #include #include #include #include namespace google { namespace cloud { namespace generator_internal { /** * Extracts service wide substitution data required by all class generators from * the provided descriptor. */ VarsDictionary CreateServiceVars( google::protobuf::ServiceDescriptor const& descriptor, std::vector> const& initial_values); /** * Extracts method specific substitution data for each method in the service. */ std::map CreateMethodVars( google::protobuf::ServiceDescriptor const& service); /** * Creates and initializes the collection of ClassGenerators necessary to * generate all code for the given service. */ std::vector> MakeGenerators( google::protobuf::ServiceDescriptor const* service, google::protobuf::compiler::GeneratorContext* context, std::vector> const& vars); /** * Determines which `MethodPattern` to use from patterns for the given method * and invokes the provided printer with the `PredicatedFragment`s in patterns * with the substitution data in vars. * * Exactly one `MethodPattern` in patters should match the method. If none or * more than one match, an error is returned. * * file and line are used to provide better diagnostic messages in case of a * substitution error. * */ Status PrintMethod(google::protobuf::MethodDescriptor const& method, Printer& printer, VarsDictionary const& vars, std::vector const& patterns, char const* file, int line); } // namespace generator_internal } // namespace cloud } // namespace google #endif // GOOGLE_CLOUD_CPP_GENERATOR_INTERNAL_DESCRIPTOR_UTILS_H