Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers StringMover.hpp Source File

StringMover.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Namespace.hpp>
00008 #include <ArduinoJson/Strings/StoragePolicy.hpp>
00009 
00010 namespace ARDUINOJSON_NAMESPACE {
00011 
00012 class StringMover {
00013  public:
00014   StringMover(char* ptr) : _writePtr(ptr) {}
00015 
00016   void startString() {
00017     _startPtr = _writePtr;
00018   }
00019 
00020   const char* save() const {
00021     return _startPtr;
00022   }
00023 
00024   void append(char c) {
00025     *_writePtr++ = c;
00026   }
00027 
00028   bool isValid() const {
00029     return true;
00030   }
00031 
00032   const char* c_str() const {
00033     return _startPtr;
00034   }
00035 
00036   typedef storage_policies::store_by_address storage_policy;
00037 
00038  private:
00039   char* _writePtr;
00040   char* _startPtr;
00041 };
00042 }  // namespace ARDUINOJSON_NAMESPACE