mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 20:15:34 +00:00
Add more apis to query vector types from a reference (#4823)
* Add more apis to query vector types from a reference https://github.com/google/flatbuffers/issues/4818 * changing order of apis * another reordering * removed vector element type api as not needed as for now
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
d48f08acfe
commit
0bffce5aef
@@ -368,6 +368,9 @@ class Reference {
|
||||
bool IsString() const { return type_ == FBT_STRING; }
|
||||
bool IsKey() const { return type_ == FBT_KEY; }
|
||||
bool IsVector() const { return type_ == FBT_VECTOR || type_ == FBT_MAP; }
|
||||
bool IsTypedVector() const { return flexbuffers::IsTypedVector(type_); }
|
||||
bool IsFixedTypedVector() const { return flexbuffers::IsFixedTypedVector(type_); }
|
||||
bool IsAnyVector() const { return (IsTypedVector() || IsFixedTypedVector() || IsVector());}
|
||||
bool IsMap() const { return type_ == FBT_MAP; }
|
||||
bool IsBlob() const { return type_ == FBT_BLOB; }
|
||||
|
||||
@@ -562,7 +565,7 @@ class Reference {
|
||||
}
|
||||
|
||||
TypedVector AsTypedVector() const {
|
||||
if (IsTypedVector(type_)) {
|
||||
if (IsTypedVector()) {
|
||||
return TypedVector(Indirect(), byte_width_,
|
||||
ToTypedVectorElementType(type_));
|
||||
} else {
|
||||
@@ -571,7 +574,7 @@ class Reference {
|
||||
}
|
||||
|
||||
FixedTypedVector AsFixedTypedVector() const {
|
||||
if (IsFixedTypedVector(type_)) {
|
||||
if (IsFixedTypedVector()) {
|
||||
uint8_t len = 0;
|
||||
auto vtype = ToFixedTypedVectorElementType(type_, &len);
|
||||
return FixedTypedVector(Indirect(), byte_width_, vtype, len);
|
||||
|
||||
Reference in New Issue
Block a user