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:
Shivendra Agarwal
2018-09-28 01:04:27 +05:30
committed by Wouter van Oortmerssen
parent d48f08acfe
commit 0bffce5aef

View File

@@ -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);