mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Fixed error "No such file or directory WString.h" (fixes #1381)
This commit is contained in:
		
							
								
								
									
										45
									
								
								extras/tests/Helpers/api/String.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								extras/tests/Helpers/api/String.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| // ArduinoJson - arduinojson.org | ||||
| // Copyright Benoit Blanchon 2014-2020 | ||||
| // MIT License | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <string> | ||||
|  | ||||
| // Reproduces Arduino's String class | ||||
| class String { | ||||
|  public: | ||||
|   String() {} | ||||
|   explicit String(const char* s) : _str(s) {} | ||||
|  | ||||
|   String& operator+=(const char* rhs) { | ||||
|     _str += rhs; | ||||
|     return *this; | ||||
|   } | ||||
|  | ||||
|   size_t length() const { | ||||
|     return _str.size(); | ||||
|   } | ||||
|  | ||||
|   const char* c_str() const { | ||||
|     return _str.c_str(); | ||||
|   } | ||||
|  | ||||
|   bool operator==(const char* s) const { | ||||
|     return _str == s; | ||||
|   } | ||||
|  | ||||
|   friend std::ostream& operator<<(std::ostream& lhs, const ::String& rhs) { | ||||
|     lhs << rhs._str; | ||||
|     return lhs; | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   std::string _str; | ||||
| }; | ||||
|  | ||||
| class StringSumHelper; | ||||
|  | ||||
| inline bool operator==(const std::string& lhs, const ::String& rhs) { | ||||
|   return lhs == rhs.c_str(); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user