Commit 0bffce5a authored by Shivendra Agarwal's avatar Shivendra Agarwal Committed by Wouter van Oortmerssen

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
parent d48f08ac
...@@ -368,6 +368,9 @@ class Reference { ...@@ -368,6 +368,9 @@ class Reference {
bool IsString() const { return type_ == FBT_STRING; } bool IsString() const { return type_ == FBT_STRING; }
bool IsKey() const { return type_ == FBT_KEY; } bool IsKey() const { return type_ == FBT_KEY; }
bool IsVector() const { return type_ == FBT_VECTOR || type_ == FBT_MAP; } 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 IsMap() const { return type_ == FBT_MAP; }
bool IsBlob() const { return type_ == FBT_BLOB; } bool IsBlob() const { return type_ == FBT_BLOB; }
...@@ -562,7 +565,7 @@ class Reference { ...@@ -562,7 +565,7 @@ class Reference {
} }
TypedVector AsTypedVector() const { TypedVector AsTypedVector() const {
if (IsTypedVector(type_)) { if (IsTypedVector()) {
return TypedVector(Indirect(), byte_width_, return TypedVector(Indirect(), byte_width_,
ToTypedVectorElementType(type_)); ToTypedVectorElementType(type_));
} else { } else {
...@@ -571,7 +574,7 @@ class Reference { ...@@ -571,7 +574,7 @@ class Reference {
} }
FixedTypedVector AsFixedTypedVector() const { FixedTypedVector AsFixedTypedVector() const {
if (IsFixedTypedVector(type_)) { if (IsFixedTypedVector()) {
uint8_t len = 0; uint8_t len = 0;
auto vtype = ToFixedTypedVectorElementType(type_, &len); auto vtype = ToFixedTypedVectorElementType(type_, &len);
return FixedTypedVector(Indirect(), byte_width_, vtype, len); return FixedTypedVector(Indirect(), byte_width_, vtype, len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment