diff options
| author | Stefan Boberg <[email protected]> | 2021-09-01 11:16:29 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-01 11:16:29 +0200 |
| commit | 9b56218bd354b46b157ecdefd3254fa8d5c3e94d (patch) | |
| tree | 88a679f2e770b39e34eecb120460e2d43ab49c74 /zencore/include | |
| parent | Fixed a race in bucket open/create logic (diff) | |
| download | zen-9b56218bd354b46b157ecdefd3254fa8d5c3e94d.tar.xz zen-9b56218bd354b46b157ecdefd3254fa8d5c3e94d.zip | |
CompactBinary: Added explicit operator bool for array and object types
p4 CL16069971
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/compactbinary.h | 6 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinarypackage.h | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/zencore/include/zencore/compactbinary.h b/zencore/include/zencore/compactbinary.h index 2dc9c0ce0..839218940 100644 --- a/zencore/include/zencore/compactbinary.h +++ b/zencore/include/zencore/compactbinary.h @@ -821,6 +821,9 @@ public: /** Construct an array from an array field. No type check is performed! */ static inline CbArrayView FromFieldView(const CbFieldView& Field) { return CbArrayView(Field); } + /** Whether the array has any fields. */ + inline explicit operator bool() const { return Num() > 0; } + /** Returns the size of the array in bytes if serialized by itself with no name. */ ZENCORE_API uint64_t GetSize() const; @@ -903,6 +906,9 @@ public: /** Construct an object from an object field. No type check is performed! */ static inline CbObjectView FromFieldView(const CbFieldView& Field) { return CbObjectView(Field); } + /** Whether the object has any fields. */ + ZENCORE_API explicit operator bool() const; + /** Returns the size of the object in bytes if serialized by itself with no name. */ ZENCORE_API uint64_t GetSize() const; diff --git a/zencore/include/zencore/compactbinarypackage.h b/zencore/include/zencore/compactbinarypackage.h index d7a8ea7fc..493eb2ba7 100644 --- a/zencore/include/zencore/compactbinarypackage.h +++ b/zencore/include/zencore/compactbinarypackage.h @@ -193,7 +193,7 @@ public: inline explicit operator bool() const { return !IsNull(); } /** Whether the package has an empty object and no attachments. */ - inline bool IsNull() const { return !Object.CreateIterator() && Attachments.size() == 0; } + inline bool IsNull() const { return !Object && Attachments.size() == 0; } /** Returns the compact binary object for the package. */ inline const CbObject& GetObject() const { return Object; } |