aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/flatbuffers/src/bfbs_namer.h
blob: d197574cf71b917ee1cf8ef0b05667e6b2bfadf8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef FLATBUFFERS_BFBS_NAMER
#define FLATBUFFERS_BFBS_NAMER

#include "flatbuffers/reflection.h"
#include "namer.h"

namespace flatbuffers {

// Provides Namer capabilities to types defined in the flatbuffers reflection.
class BfbsNamer : public Namer {
 public:
  explicit BfbsNamer(Config config, std::set<std::string> keywords)
      : Namer(config, std::move(keywords)) {}

  using Namer::Constant;
  using Namer::Denamespace;
  using Namer::Directories;
  using Namer::Field;
  using Namer::File;
  using Namer::Function;
  using Namer::Method;
  using Namer::Namespace;
  using Namer::NamespacedType;
  using Namer::ObjectType;
  using Namer::Type;
  using Namer::Variable;
  using Namer::Variant;

  template<typename T>
  std::string Denamespace(T t, std::string &namespace_prefix,
                          const char delimiter = '.') const {
    return Namer::Denamespace(t->name()->c_str(), namespace_prefix, delimiter);
  }

  template<typename T>
  std::string Denamespace(T t, const char delimiter = '.') const {
    return Namer::Denamespace(t->name()->c_str(), delimiter);
  }

  virtual std::string Field(const ::reflection::Field &f) const {
    return Field(f.name()->str());
  }

  virtual std::string Variable(const ::reflection::Field &f) const {
    return Variable(f.name()->str());
  }
};

}  // namespace flatbuffers

#endif  // FLATBUFFERS_BFBS_NAMER