Skip to content

Commit 9cbf8c5

Browse files
committed
0.3.3 XMLWriter
1 parent 685c941 commit 9cbf8c5

File tree

8 files changed

+191
-102
lines changed

8 files changed

+191
-102
lines changed

libraries/XMLWriter/.arduino-ci.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
116
compile:
217
# Choosing to run compilation tests on 2 different Arduino platforms
318
platforms:
@@ -7,8 +22,10 @@ compile:
722
- leonardo
823
- m4
924
- esp32
10-
# - esp8266
11-
# - mega2560
25+
# - esp8266 # causes analog pins to fail
26+
- mega2560
27+
- rpipico
28+
1229
libraries:
1330
- "Ethernet"
1431
- "SD"

libraries/XMLWriter/CHANGELOG.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Change Log XMLWriter
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.3.3] - 2022-11-27
10+
- Add RP2040 support to build-CI.
11+
- Add CHANGELOG.md
12+
- update readme.md
13+
14+
15+
## [0.3.2] - 2021-12-29
16+
- update library.json
17+
- update readme.md
18+
- update license
19+
- update unit test
20+
- minor edits
21+
22+
## [0.3.1] - 2021-11-11
23+
- refactor naming to improve readability
24+
- update build-CI,
25+
- update readme.md, Badges.
26+
27+
## [0.3.0] - 2021-01-09
28+
- Arduino-ci + unit tests
29+
- add getIndentSize()
30+
- add version()
31+
- add debug()
32+
33+
----
34+
## [0.2.4] - 2020-07-07
35+
- fix #6 Print interface made public
36+
37+
## [0.2.3] - 2020-06-19
38+
- fix library.json
39+
40+
## [0.2.2] - 2020-04-29
41+
= dynamic buffer size in constructor
42+
43+
## [0.2.1] - 2020-04-26
44+
- performance optimized
45+
- add setconfig()
46+
- add newLine()
47+
48+
## [0.2.0] - 2020-04-24
49+
- refactor
50+
- add examples
51+
- add #pragma
52+
- add print as base class
53+
54+
----
55+
56+
## [0.1.9] - 2017-12-09
57+
- add PROGMEM support for escape() strings
58+
59+
## [0.1.8] - 2017-12-09
60+
- fix casting issue #83 (long -> int32_t);
61+
62+
## [0.1.7] - 2017-07-26
63+
- add const where possible
64+
65+
## [0.1.6] - 2016-03-16
66+
- added incrIndent(), decrIndent()
67+
- add indent()
68+
- add raw()
69+
70+
## [0.1.05] - 2015-05-23
71+
- added XMLWRITER_MAXTAGSIZE 15 (to support KML coordinates tag)
72+
73+
## [0.1.04] - 2015-05-21
74+
- refactored - reduce RAM -> used F() macro etc.
75+
76+
## [0.1.03] - 2015-03-07
77+
- refactored - footprint + interface
78+
79+
## [0.1.02] - 2013-11-07
80+
- add setIndentSize()
81+
= corrected history
82+
- add escape support
83+
84+
## [0.1.01] - 2013-11-07
85+
- rework interfaces
86+
87+
## [0.1.00] - 2013-11-06
88+
- initial version
89+

libraries/XMLWriter/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ and choose one that is appropriate.
2828
Indicative sizes based upon the examples.
2929
Run your tests to find your application optimum.
3030

31-
| STREAM | SIZE |
32-
|:---------|:-----------|
33-
| Ethernet | 20-30 |
34-
| Serial | 5 |
35-
| SD File | 10-16 |
31+
| STREAM | SIZE |
32+
|:-----------|:-----------|
33+
| Ethernet | 20-30 |
34+
| Serial | 5 |
35+
| SD File | 10-16 |
3636

3737
**IMPORTANT:** When using buffering you should always call **XML.flush()**
3838
at the end of the XML generation. This will flush the last bytes in the internal buffer into the output stream.
@@ -130,12 +130,12 @@ can inject strings.
130130

131131
## Configuration flags
132132

133-
| Flag | Value | Description |
134-
|:-----------------|:------|:------------------|
135-
|XMLWRITER_NONE | 0x00 | minimize output, smaller & faster |
136-
|XMLWRITER_COMMENT | 0x01 | allow comments |
137-
|XMLWRITER_INDENT | 0x02 | allow indentation |
138-
|XMLWRITER_NEWLINE | 0x04 | allow newlines |
133+
| Flag | Value | Description |
134+
|:--------------------|:--------|:--------------------|
135+
| XMLWRITER_NONE | 0x00 | minimize output, smaller & faster |
136+
| XMLWRITER_COMMENT | 0x01 | allow comments |
137+
| XMLWRITER_INDENT | 0x02 | allow indentation |
138+
| XMLWRITER_NEWLINE | 0x04 | allow newlines |
139139

140140

141141
- **setConfig(XMLWRITER_NONE);** to minimize the output in bytes.
@@ -151,7 +151,12 @@ See examples
151151

152152
## Future
153153

154+
#### must
154155
- update documentation
155-
-
156+
157+
#### should
158+
159+
#### could
160+
- move code to .cpp
156161

157162

libraries/XMLWriter/XMLWriter.cpp

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
//
22
// FILE: XMLWriter.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.2
4+
// VERSION: 0.3.3
55
// DATE: 2013-11-06
6-
// PURPOSE: Arduino library for creating XML
7-
//
8-
// HISTORY:
9-
// 0.1.00 2013-11-06 initial version
10-
// 0.1.01 2013-11-07 rework interfaces
11-
// 0.1.02 2013-11-07 +setIndentSize(), corrected history, +escape support
12-
// 0.1.03 2015-03-07 refactored - footprint + interface
13-
// 0.1.04 2015-05-21 refactored - reduce RAM -> used F() macro etc.
14-
// 0.1.05 2015-05-23 added XMLWRITER_MAXTAGSIZE 15 (to support KML coordinates tag)
15-
// 0.1.6 2016-03-16 added incrIndent(), decrIndent(), indent(), raw();
16-
// 0.1.7 2017-07-26 added const where possible
17-
// 0.1.8 2017-12-09 fix casting issue #83 (long -> int32_t);
18-
// 0.1.9 2017-12-09 add PROGMEM support for escape() strings
19-
// 0.2.0 2020-04-24 refactor, added examples, #pragma, print as base class
20-
// 0.2.1 2020-04-26 performance optimized, setconfig() + newLine() added
21-
// 0.2.2 2020-04-29 dynamic buffer size in constructor
22-
// 0.2.3 2020-06-19 fix library.json
23-
// 0.2.4 2020-07-07 fix #6 Print interface made public
24-
// 0.3.0 2021-01-09 Arduino-ci + unit tests
25-
// add getIndentSize(); version(); debug();
26-
// 0.3.1 2021-11-11 refactor naming to improve readability
27-
// update build-CI,
28-
// update readme.md, Badges.
29-
// 0.3.2 2021-12-29 update library.json, readme, license, unit test, minor edits
6+
// PURPOSE: Arduino library for creating XML
307

318

329
#include "XMLWriter.h"
@@ -202,7 +179,7 @@ void XMLWriter::writeNode(const char* tag, const char* str)
202179

203180
///////////////////////////////////////////////////////////////
204181
//
205-
// TAGFIELD
182+
// TAGFIELD
206183
//
207184
void XMLWriter::tagField(const char *field, const uint8_t value, const uint8_t base)
208185
{
@@ -258,7 +235,7 @@ void XMLWriter::tagField(const char *field, const bool value)
258235
{
259236
print(' ');
260237
print(field);
261-
// F() is slower & uses less RAM but 15 bytes saved
238+
// F() is slower & uses less RAM but 15 bytes saved
262239
print(value ? F("=\"true\"") : F("=\"false\""));
263240
}
264241

@@ -275,7 +252,7 @@ void XMLWriter::tagField(const char *field, const double value, const uint8_t de
275252

276253
///////////////////////////////////////////////////////////////
277254
//
278-
// WRITENODE
255+
// WRITENODE
279256
//
280257
void XMLWriter::writeNode(const char* tag, const uint8_t value, const uint8_t base)
281258
{
@@ -326,7 +303,7 @@ void XMLWriter::writeNode(const char* tag, const int32_t value, const uint8_t ba
326303
void XMLWriter::writeNode(const char* tag, const bool value)
327304
{
328305
tagOpen(tag, "", NONEWLINE);
329-
// F() is slower & uses less RAM but saves 9 bytes
306+
// F() is slower & uses less RAM but saves 9 bytes
330307
print(value ? F("true") : F("false"));
331308
tagClose(NOINDENT);
332309
}
@@ -344,8 +321,8 @@ void XMLWriter::indent()
344321
{
345322
if (_config & XMLWRITER_INDENT)
346323
{
347-
// as indentation is a multiple of 2
348-
// this is nice balance between speed and RAM.
324+
// as indentation is a multiple of 2
325+
// this is nice balance between speed and RAM.
349326
for (uint8_t i = _indent; i > 0; i-= 2) print(" ");
350327
}
351328
}
@@ -365,16 +342,16 @@ void XMLWriter::flush()
365342
if (_bufferIndex > 0)
366343
{
367344
_buffer[_bufferIndex] = 0;
368-
_stream->write(_buffer, _bufferIndex); // saves ~40 bytes on UNO.
369-
// _stream->print(_buffer);
345+
_stream->write(_buffer, _bufferIndex); // saves ~40 bytes on UNO.
346+
// _stream->print(_buffer);
370347
_bufferIndex = 0;
371348
}
372349
};
373350

374351

375352
////////////////////////////////////////////////////////////////////
376353
//
377-
// ESCAPE
354+
// ESCAPE
378355
//
379356

380357
#ifdef XMLWRITER_ESCAPE_SUPPORT
@@ -393,7 +370,7 @@ PROGMEM const char* const expanded[] =
393370
};
394371

395372
#else
396-
// NOTE: & and ; are handled in code. // 25 bytes RAM
373+
// NOTE: & and ; are handled in code. // 25 bytes RAM
397374
static char expanded[][5] = { "quot", "apos","lt","gt","amp"};
398375

399376
#endif
@@ -406,7 +383,7 @@ void XMLWriter::escape(const char* str)
406383
char* q = strchr(c, *p);
407384
if (q == NULL) print(*p);
408385
#ifdef __PROGMEM__
409-
else
386+
else
410387
{
411388
char buf[8];
412389
strcpy_P(buf, (char*)pgm_read_word(&(expanded[q - c])));
@@ -416,7 +393,7 @@ void XMLWriter::escape(const char* str)
416393
else
417394
{
418395
print('&');
419-
print(expanded[q - c]); // uint8_t idx = q-c;
396+
print(expanded[q - c]); // uint8_t idx = q-c;
420397
print(';');
421398
}
422399
#endif
@@ -426,5 +403,5 @@ void XMLWriter::escape(const char* str)
426403
#endif
427404

428405

429-
// -- END OF FILE --
406+
// -- END OF FILE --
430407

0 commit comments

Comments
 (0)