Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ArrayFunctions.hpp Source File

ArrayFunctions.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Collection/CollectionData.hpp>
00008 
00009 namespace ARDUINOJSON_NAMESPACE {
00010 
00011 inline VariantData *arrayAdd(CollectionData *arr, MemoryPool *pool) {
00012   return arr ? arr->addElement(pool) : 0;
00013 }
00014 
00015 template <typename TVisitor>
00016 inline typename TVisitor::result_type arrayAccept(const CollectionData *arr,
00017                                                   TVisitor &visitor) {
00018   if (arr)
00019     return visitor.visitArray(*arr);
00020   else
00021     return visitor.visitNull();
00022 }
00023 
00024 inline bool arrayEquals(const CollectionData *lhs, const CollectionData *rhs) {
00025   if (lhs == rhs)
00026     return true;
00027   if (!lhs || !rhs)
00028     return false;
00029   return lhs->equalsArray(*rhs);
00030 }
00031 }  // namespace ARDUINOJSON_NAMESPACE