• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef FLATBUFFERS_BFBS_NAMER
2 #define FLATBUFFERS_BFBS_NAMER
3 
4 #include "flatbuffers/reflection.h"
5 #include "namer.h"
6 
7 namespace flatbuffers {
8 
9 // Provides Namer capabilities to types defined in the flatbuffers reflection.
10 class BfbsNamer : public Namer {
11  public:
BfbsNamer(Config config,std::set<std::string> keywords)12   explicit BfbsNamer(Config config, std::set<std::string> keywords)
13       : Namer(config, std::move(keywords)) {}
14 
15   using Namer::Constant;
16   using Namer::Denamespace;
17   using Namer::Directories;
18   using Namer::Field;
19   using Namer::File;
20   using Namer::Function;
21   using Namer::Method;
22   using Namer::Namespace;
23   using Namer::NamespacedType;
24   using Namer::ObjectType;
25   using Namer::Type;
26   using Namer::Variable;
27   using Namer::Variant;
28 
29   template<typename T>
30   std::string Denamespace(T t, std::string &namespace_prefix,
31                           const char delimiter = '.') const {
32     return Namer::Denamespace(t->name()->c_str(), namespace_prefix, delimiter);
33   }
34 
35   template<typename T>
36   std::string Denamespace(T t, const char delimiter = '.') const {
37     return Namer::Denamespace(t->name()->c_str(), delimiter);
38   }
39 
Field(const::reflection::Field & f)40   virtual std::string Field(const ::reflection::Field &f) const {
41     return Field(f.name()->str());
42   }
43 
Variable(const::reflection::Field & f)44   virtual std::string Variable(const ::reflection::Field &f) const {
45     return Variable(f.name()->str());
46   }
47 };
48 
49 }  // namespace flatbuffers
50 
51 #endif  // FLATBUFFERS_BFBS_NAMER
52