Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ObjectShortcuts.hpp Source File

ObjectShortcuts.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Polyfills/attributes.hpp>
00008 #include <ArduinoJson/Polyfills/type_traits.hpp>
00009 #include <ArduinoJson/Strings/StringAdapters.hpp>
00010 
00011 namespace ARDUINOJSON_NAMESPACE {
00012 template <typename TParent, typename TStringRef>
00013 class MemberProxy;
00014 
00015 template <typename TObject>
00016 class ObjectShortcuts {
00017  public:
00018   // containsKey(const std::string&) const
00019   // containsKey(const String&) const
00020   template <typename TString>
00021   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type
00022   containsKey(const TString &key) const;
00023 
00024   // containsKey(char*) const
00025   // containsKey(const char*) const
00026   // containsKey(const __FlashStringHelper*) const
00027   template <typename TChar>
00028   FORCE_INLINE typename enable_if<IsString<TChar *>::value, bool>::type
00029   containsKey(TChar *key) const;
00030 
00031   // operator[](const std::string&) const
00032   // operator[](const String&) const
00033   template <typename TString>
00034   FORCE_INLINE typename enable_if<IsString<TString>::value,
00035                                   MemberProxy<TObject, TString> >::type
00036   operator[](const TString &key) const;
00037 
00038   // operator[](char*) const
00039   // operator[](const char*) const
00040   // operator[](const __FlashStringHelper*) const
00041   template <typename TChar>
00042   FORCE_INLINE typename enable_if<IsString<TChar *>::value,
00043                                   MemberProxy<TObject, TChar *> >::type
00044   operator[](TChar *key) const;
00045 
00046   // createNestedArray(const std::string&) const
00047   // createNestedArray(const String&) const
00048   template <typename TString>
00049   FORCE_INLINE ArrayRef createNestedArray(const TString &key) const;
00050 
00051   // createNestedArray(char*) const
00052   // createNestedArray(const char*) const
00053   // createNestedArray(const __FlashStringHelper*) const
00054   template <typename TChar>
00055   FORCE_INLINE ArrayRef createNestedArray(TChar *key) const;
00056 
00057   // createNestedObject(const std::string&) const
00058   // createNestedObject(const String&) const
00059   template <typename TString>
00060   ObjectRef createNestedObject(const TString &key) const;
00061 
00062   // createNestedObject(char*) const
00063   // createNestedObject(const char*) const
00064   // createNestedObject(const __FlashStringHelper*) const
00065   template <typename TChar>
00066   ObjectRef createNestedObject(TChar *key) const;
00067 
00068  private:
00069   const TObject *impl() const {
00070     return static_cast<const TObject *>(this);
00071   }
00072 };
00073 }  // namespace ARDUINOJSON_NAMESPACE