mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // ArduinoJson - https://arduinojson.org
 | |
| // Copyright Benoit Blanchon 2014-2021
 | |
| // MIT License
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <ArduinoJson/Strings/ConstRamStringAdapter.hpp>
 | |
| #include <ArduinoJson/Strings/IsString.hpp>
 | |
| #include <ArduinoJson/Strings/StoragePolicy.hpp>
 | |
| 
 | |
| namespace ARDUINOJSON_NAMESPACE {
 | |
| 
 | |
| class RamStringAdapter : public ConstRamStringAdapter {
 | |
|  public:
 | |
|   RamStringAdapter(const char* str) : ConstRamStringAdapter(str) {}
 | |
| 
 | |
|   void copyTo(char* p, size_t n) const {
 | |
|     memcpy(p, _str, n);
 | |
|   }
 | |
| 
 | |
|   typedef ARDUINOJSON_NAMESPACE::storage_policies::store_by_copy storage_policy;
 | |
| };
 | |
| 
 | |
| template <typename TChar>
 | |
| inline RamStringAdapter adaptString(const TChar* str) {
 | |
|   return RamStringAdapter(reinterpret_cast<const char*>(str));
 | |
| }
 | |
| 
 | |
| inline RamStringAdapter adaptString(char* str) {
 | |
|   return RamStringAdapter(str);
 | |
| }
 | |
| 
 | |
| template <typename TChar>
 | |
| struct IsString<TChar*> {
 | |
|   static const bool value = sizeof(TChar) == 1;
 | |
| };
 | |
| 
 | |
| template <>
 | |
| struct IsString<void*> {
 | |
|   static const bool value = false;
 | |
| };
 | |
| 
 | |
| }  // namespace ARDUINOJSON_NAMESPACE
 |