Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ConstRamStringAdapter.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 #include <stddef.h> // size_t 00008 #include <string.h> // strcmp 00009 00010 #include <ArduinoJson/Polyfills/safe_strcmp.hpp> 00011 #include <ArduinoJson/Strings/IsString.hpp> 00012 #include <ArduinoJson/Strings/StoragePolicy.hpp> 00013 00014 namespace ARDUINOJSON_NAMESPACE { 00015 00016 class ConstRamStringAdapter { 00017 public: 00018 ConstRamStringAdapter(const char* str = 0) : _str(str) {} 00019 00020 int compare(const char* other) const { 00021 return safe_strcmp(_str, other); 00022 } 00023 00024 bool equals(const char* expected) const { 00025 return compare(expected) == 0; 00026 } 00027 00028 bool isNull() const { 00029 return !_str; 00030 } 00031 00032 size_t size() const { 00033 if (!_str) 00034 return 0; 00035 return strlen(_str); 00036 } 00037 00038 const char* data() const { 00039 return _str; 00040 } 00041 00042 const char* begin() const { 00043 return _str; 00044 } 00045 00046 typedef storage_policies::store_by_address storage_policy; 00047 00048 protected: 00049 const char* _str; 00050 }; 00051 00052 template <> 00053 struct IsString<const char*> : true_type {}; 00054 00055 template <int N> 00056 struct IsString<const char[N]> : true_type {}; 00057 00058 inline ConstRamStringAdapter adaptString(const char* str) { 00059 return ConstRamStringAdapter(str); 00060 } 00061 00062 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2