mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-08 14:15:17 +00:00
Added VectorLength helper function that works on nullptr.
Change-Id: Ie62096f7337a476bee7a6d46d652e594fb3124d2 Tested: on Linux. Bug: 18201051
This commit is contained in:
@@ -296,6 +296,12 @@ protected:
|
||||
uoffset_t length_;
|
||||
};
|
||||
|
||||
// Convenient helper function to get the length of any vector, regardless
|
||||
// of wether it is null or not (the field is not set).
|
||||
template<typename T> static inline size_t VectorLength(const Vector<T> *v) {
|
||||
return v ? v->Length() : 0;
|
||||
}
|
||||
|
||||
struct String : public Vector<char> {
|
||||
const char *c_str() const { return reinterpret_cast<const char *>(Data()); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user