Files
flatbuffers/src/bfbs_namer.h
Dan Lapid 872a497464 [Nim] Bfbs Nim Generator (#7534)
* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* Bfbs Nim Generator

* Remove commented out tests

* add missing line to idl.h

* Commit python reflection changes

* Commit python reflection changes and move tests

* Remove default string addition

* Move tests to python file

* Fix element size check when element is table

* remove whitespace changes

* add element_type docs and commit further to namer and remove kkeep

* remove unused variables

* added tests to ci

* added tests to ci

* fixes

* Added reflection type Field, Variable to namer

* Moved reflection namer impl to bfbsnamer

* Remove whitespace at end of line

* Added nim to generated code

* Revert whitespace removal

Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-21 14:30:04 -04:00

51 lines
1.3 KiB
C++

#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