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.
StaticStringWriter.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 00009 namespace ARDUINOJSON_NAMESPACE { 00010 00011 // A Print implementation that allows to write in a char[] 00012 class StaticStringWriter { 00013 public: 00014 StaticStringWriter(char *buf, size_t size) : end(buf + size - 1), p(buf) { 00015 *p = '\0'; 00016 } 00017 00018 size_t write(uint8_t c) { 00019 if (p >= end) 00020 return 0; 00021 *p++ = static_cast<char>(c); 00022 *p = '\0'; 00023 return 1; 00024 } 00025 00026 size_t write(const uint8_t *s, size_t n) { 00027 char *begin = p; 00028 while (p < end && n > 0) { 00029 *p++ = static_cast<char>(*s++); 00030 n--; 00031 } 00032 *p = '\0'; 00033 return size_t(p - begin); 00034 } 00035 00036 private: 00037 char *end; 00038 char *p; 00039 }; 00040 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2