Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:11:56

0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2024 Google Inc.  All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007 
0008 // An RAII type for printing an ifdef guard.
0009 //
0010 // This can be used to ensure that appropriate ifdef guards are applied in
0011 // a generated header file.
0012 //
0013 // Example:
0014 // {
0015 //   Printer printer(output_stream.get(), '$');
0016 //   const IfdefGuardPrinter ifdef_guard(&printer, output_path);
0017 //   // #ifdef guard will be emitted here
0018 //   ...
0019 //   // #endif will be emitted here
0020 // }
0021 //
0022 // By default, the filename will be converted to a macro by substituting '/' and
0023 // '.' characters with '_'.  If a different transformation is required, an
0024 // optional transformation function can be provided.
0025 
0026 #ifndef GOOGLE_PROTOBUF_COMPILER_CPP_IFNDEF_GUARD_H__
0027 #define GOOGLE_PROTOBUF_COMPILER_CPP_IFNDEF_GUARD_H__
0028 
0029 #include <string>
0030 
0031 #include "absl/functional/any_invocable.h"
0032 #include "absl/strings/string_view.h"
0033 #include "google/protobuf/io/printer.h"
0034 
0035 // Must be included last.
0036 #include "google/protobuf/port_def.inc"
0037 
0038 namespace google {
0039 namespace protobuf {
0040 namespace compiler {
0041 namespace cpp {
0042 
0043 class PROTOC_EXPORT IfdefGuardPrinter final {
0044  public:
0045   explicit IfdefGuardPrinter(google::protobuf::io::Printer* p,
0046                              absl::string_view filename);
0047 
0048   explicit IfdefGuardPrinter(
0049       google::protobuf::io::Printer* p, absl::string_view filename,
0050       absl::AnyInvocable<std::string(absl::string_view)> make_ifdef_identifier);
0051 
0052   ~IfdefGuardPrinter();
0053 
0054  private:
0055   google::protobuf::io::Printer* const p_;
0056   const std::string ifdef_identifier_;
0057 };
0058 
0059 #include "google/protobuf/port_undef.inc"
0060 
0061 }  // namespace cpp
0062 }  // namespace compiler
0063 }  // namespace protobuf
0064 }  // namespace google
0065 
0066 #endif  // GOOGLE_PROTOBUF_COMPILER_CPP_IFNDEF_GUARD_H__