37 lines
		
	
	
		
			694 B
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			694 B
		
	
	
	
		
			C++
		
	
	
	
| #pragma once
 | |
| 
 | |
| 
 | |
| #ifdef PLATFORM_ESP32
 | |
| #include "Preferences.h"
 | |
| #endif 
 | |
| 
 | |
| 
 | |
| 
 | |
| #ifdef PLATFORM_NATIVE
 | |
| 
 | |
| #include <map>
 | |
| 
 | |
| class Preferences
 | |
| {
 | |
|   public:
 | |
|     std::string getString(const char * key, const std::string & defaultValue) const {
 | |
|       std::string strKey(key);
 | |
|       const auto it = strings_.find(strKey);
 | |
|       return (it == string_.end()) ? defaultValue : *it;
 | |
|     }
 | |
| 
 | |
|     size_t putString(const char * key, const char * value) {
 | |
|       strings_[std::string(key)] = std::string(value);
 | |
|       return std::strlen(value);
 | |
|     }
 | |
| 
 | |
|     bool remove(const char * key) {
 | |
|       return strings_.remove(key); 
 | |
|     }
 | |
| 
 | |
|   private:
 | |
|     std::map<std::string, std::string> strings_;
 | |
| };
 | |
| 
 | |
| #endif // PLATFORM_NATIVE
 |