Rev | Line | |
---|
[209] | 1 | // Copyright Benoit Blanchon 2014-2016
|
---|
| 2 | // MIT License
|
---|
| 3 | //
|
---|
| 4 | // Arduino JSON library
|
---|
| 5 | // https://github.com/bblanchon/ArduinoJson
|
---|
| 6 | // If you like this project, please add a star!
|
---|
| 7 |
|
---|
| 8 | #pragma once
|
---|
| 9 |
|
---|
| 10 | #include "../Arduino/Print.hpp"
|
---|
| 11 |
|
---|
| 12 | namespace ArduinoJson {
|
---|
| 13 | namespace Internals {
|
---|
| 14 |
|
---|
| 15 | class Encoding {
|
---|
| 16 | public:
|
---|
| 17 | // Optimized for code size on a 8-bit AVR
|
---|
| 18 | static char escapeChar(char c) {
|
---|
| 19 | const char *p = _escapeTable;
|
---|
| 20 | while (p[0] && p[1] != c) {
|
---|
| 21 | p += 2;
|
---|
| 22 | }
|
---|
| 23 | return p[0];
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | // Optimized for code size on a 8-bit AVR
|
---|
| 27 | static char unescapeChar(char c) {
|
---|
| 28 | const char *p = _escapeTable + 4;
|
---|
| 29 | for (;;) {
|
---|
| 30 | if (p[0] == '\0') return c;
|
---|
| 31 | if (p[0] == c) return p[1];
|
---|
| 32 | p += 2;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | private:
|
---|
| 37 | static const char _escapeTable[];
|
---|
| 38 | };
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.