mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-07 22:03:40 +00:00
[C++] Fix for printing of enum in case output_enum_identifiers=1. (#5706)
* Add test-case for testing of the future Color in json (output_enum_identifiers = true) * Refactoring of idl_gen_text.cpp. Fix for printing of bit-enum with active output_enum_identifiers=1. * Move GenerateText implementation into class * Remove unnecessary code from flatbuffers.h
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
c4b2b0a25d
commit
01189d7edd
@@ -443,6 +443,13 @@ template<typename T, uint16_t length> class Array {
|
||||
|
||||
return_type operator[](uoffset_t i) const { return Get(i); }
|
||||
|
||||
// If this is a Vector of enums, T will be its storage type, not the enum
|
||||
// type. This function makes it convenient to retrieve value with enum
|
||||
// type E.
|
||||
template<typename E> E GetEnum(uoffset_t i) const {
|
||||
return static_cast<E>(Get(i));
|
||||
}
|
||||
|
||||
const_iterator begin() const { return const_iterator(Data(), 0); }
|
||||
const_iterator end() const { return const_iterator(Data(), size()); }
|
||||
|
||||
@@ -518,10 +525,12 @@ template<typename T, uint16_t length> class Array<Offset<T>, length> {
|
||||
static_assert(flatbuffers::is_same<T, void>::value, "unexpected type T");
|
||||
|
||||
public:
|
||||
typedef const void* return_type;
|
||||
|
||||
const uint8_t *Data() const { return data_; }
|
||||
|
||||
// Make idl_gen_text.cpp::PrintContainer happy.
|
||||
const void *operator[](uoffset_t) const {
|
||||
return_type operator[](uoffset_t) const {
|
||||
FLATBUFFERS_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user