mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-29 17:12:01 +00:00
Add constant accessors to C++ unions (#4433)
* Add constant accessors to C++ unions * Remove redundant const pointer return type * Update generate_code.bat to reflect generate_code.sh * Add updated generated files * Remove extra space from generated code * Update generated files * Change directory back to tests after generating code
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
28920aff8f
commit
21a8121982
@@ -84,26 +84,50 @@ struct CharacterUnion {
|
||||
return type == Character_MuLan ?
|
||||
reinterpret_cast<AttackerT *>(value) : nullptr;
|
||||
}
|
||||
const AttackerT *AsMuLan() const {
|
||||
return type == Character_MuLan ?
|
||||
reinterpret_cast<const AttackerT *>(value) : nullptr;
|
||||
}
|
||||
Rapunzel *AsRapunzel() {
|
||||
return type == Character_Rapunzel ?
|
||||
reinterpret_cast<Rapunzel *>(value) : nullptr;
|
||||
}
|
||||
const Rapunzel *AsRapunzel() const {
|
||||
return type == Character_Rapunzel ?
|
||||
reinterpret_cast<const Rapunzel *>(value) : nullptr;
|
||||
}
|
||||
BookReader *AsBelle() {
|
||||
return type == Character_Belle ?
|
||||
reinterpret_cast<BookReader *>(value) : nullptr;
|
||||
}
|
||||
const BookReader *AsBelle() const {
|
||||
return type == Character_Belle ?
|
||||
reinterpret_cast<const BookReader *>(value) : nullptr;
|
||||
}
|
||||
BookReader *AsBookFan() {
|
||||
return type == Character_BookFan ?
|
||||
reinterpret_cast<BookReader *>(value) : nullptr;
|
||||
}
|
||||
const BookReader *AsBookFan() const {
|
||||
return type == Character_BookFan ?
|
||||
reinterpret_cast<const BookReader *>(value) : nullptr;
|
||||
}
|
||||
std::string *AsOther() {
|
||||
return type == Character_Other ?
|
||||
reinterpret_cast<std::string *>(value) : nullptr;
|
||||
}
|
||||
const std::string *AsOther() const {
|
||||
return type == Character_Other ?
|
||||
reinterpret_cast<const std::string *>(value) : nullptr;
|
||||
}
|
||||
std::string *AsUnused() {
|
||||
return type == Character_Unused ?
|
||||
reinterpret_cast<std::string *>(value) : nullptr;
|
||||
}
|
||||
const std::string *AsUnused() const {
|
||||
return type == Character_Unused ?
|
||||
reinterpret_cast<const std::string *>(value) : nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
bool VerifyCharacter(flatbuffers::Verifier &verifier, const void *obj, Character type);
|
||||
|
||||
Reference in New Issue
Block a user