summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorShivendra Agarwal <shiva.agarwal0@gmail.com>2018-09-28 01:04:27 +0530
committerWouter van Oortmerssen <aardappel@gmail.com>2018-09-27 12:34:27 -0700
commit0bffce5aefee03f8e52aa77cc0154772236adad5 (patch)
tree66e19796fe6857fe74aa70cd4813188e901a464a /include
parentd48f08acfe30733bbcc8a672a3fbee2e4813eef3 (diff)
downloadflatbuffers-0bffce5aefee03f8e52aa77cc0154772236adad5.tar.gz
flatbuffers-0bffce5aefee03f8e52aa77cc0154772236adad5.tar.bz2
flatbuffers-0bffce5aefee03f8e52aa77cc0154772236adad5.zip
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
Diffstat (limited to 'include')
-rw-r--r--include/flatbuffers/flexbuffers.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/flatbuffers/flexbuffers.h b/include/flatbuffers/flexbuffers.h
index 99345d97..1874859f 100644
--- a/include/flatbuffers/flexbuffers.h
+++ b/include/flatbuffers/flexbuffers.h
@@ -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);