From 67649651b06e92f224e2e2e92e88dc54a7ce1702 Mon Sep 17 00:00:00 2001 From: rob tillaart Date: Wed, 29 Dec 2021 16:27:03 +0100 Subject: [PATCH] 0.3.2 XMLWriter --- libraries/XMLWriter/LICENSE | 2 +- libraries/XMLWriter/README.md | 21 ++++++++----- libraries/XMLWriter/XMLWriter.cpp | 5 ++-- libraries/XMLWriter/XMLWriter.h | 30 +++++++++---------- .../examples/KMLWriterTest/KMLWriterTest.ino | 4 +-- .../XMLWriterDefaultSerial.ino | 3 +- .../0.1.0/XMLWriterEthernet.ino | 3 +- .../XMLWriterEthernet/XMLWriterEthernet.ino | 2 -- .../XMLWriterPrint_1/XMLWriterPrint_1.ino | 6 ++-- .../XMLWriterPrint_3/XMLWriterPrint_3.ino | 7 ++--- .../XMLWriterPrint_4/XMLWriterPrint_4.ino | 5 ++-- .../XMLWriterSDcard/XMLWriterSDcard.ino | 16 +++++----- .../examples/XMLWriterTest/XMLWriterTest.ino | 3 +- .../XMLWriterdemo01/XMLWriterdemo01.ino | 4 +-- libraries/XMLWriter/keywords.txt | 2 ++ libraries/XMLWriter/library.json | 5 ++-- libraries/XMLWriter/library.properties | 2 +- libraries/XMLWriter/test/unit_test_001.cpp | 27 ++++++++++++++--- 18 files changed, 83 insertions(+), 64 deletions(-) diff --git a/libraries/XMLWriter/LICENSE b/libraries/XMLWriter/LICENSE index 39d07e31..c9bd779a 100644 --- a/libraries/XMLWriter/LICENSE +++ b/libraries/XMLWriter/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2013-2021 Rob Tillaart +Copyright (c) 2013-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/libraries/XMLWriter/README.md b/libraries/XMLWriter/README.md index 1df75a64..733d1996 100644 --- a/libraries/XMLWriter/README.md +++ b/libraries/XMLWriter/README.md @@ -1,12 +1,14 @@ [![Arduino CI](https://github.com/RobTillaart/XMLWriter/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci) +[![Arduino-lint](https://github.com/RobTillaart/XMLWriter/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/XMLWriter/actions/workflows/arduino-lint.yml) +[![JSON check](https://github.com/RobTillaart/XMLWriter/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/XMLWriter/actions/workflows/jsoncheck.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/XMLWriter/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/RobTillaart/XMLWriter.svg?maxAge=3600)](https://github.com/RobTillaart/XMLWriter/releases) # XMLWriter -Arduino Library to create simple XML (messages, files, print, ...) +Arduino Library to create simple XML (messages, files, print, ...). ## Description @@ -18,9 +20,9 @@ When instantiating an XMLWriter one can define the internal buffer size. A bigger buffer will make the output faster, especially for Ethernet and SD.File. The buffer size should be at least 2 bytes and max 250. How much faster depends on the properties of the stream and the platform used. -E.g. the baudrate and internal buffer of Serial, packet behaviour of Ethernet, +E.g. the baud rate and internal buffer of Serial, packet behaviour of Ethernet, or paging of SD cards. -If performance is low one should do testruns with different sizes for the buffer +If performance is low one should do test runs with different sizes for the buffer and choose one that is appropriate. Indicative sizes based upon the examples. @@ -128,12 +130,13 @@ can inject strings. ## Configuration flags -| Flag | Value | Description | -|:-----------------|:------|:-------------| +| Flag | Value | Description | +|:-----------------|:------|:------------------| |XMLWRITER_NONE | 0x00 | minimize output, smaller & faster | -|XMLWRITER_COMMENT | 0x01 | allow comments | +|XMLWRITER_COMMENT | 0x01 | allow comments | |XMLWRITER_INDENT | 0x02 | allow indentation | -|XMLWRITER_NEWLINE | 0x04 | allow newlines | +|XMLWRITER_NEWLINE | 0x04 | allow newlines | + - **setConfig(XMLWRITER_NONE);** to minimize the output in bytes. - **setConfig(XMLWRITER_NEWLINE);** to break an XML stream in lines. @@ -149,4 +152,6 @@ See examples ## Future - update documentation -- \ No newline at end of file +- + + diff --git a/libraries/XMLWriter/XMLWriter.cpp b/libraries/XMLWriter/XMLWriter.cpp index 43a3d5c8..99c8b121 100644 --- a/libraries/XMLWriter/XMLWriter.cpp +++ b/libraries/XMLWriter/XMLWriter.cpp @@ -1,7 +1,7 @@ // // FILE: XMLWriter.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.3.1 +// VERSION: 0.3.2 // DATE: 2013-11-06 // PURPOSE: Arduino library for creating XML // @@ -26,7 +26,7 @@ // 0.3.1 2021-11-11 refactor naming to improve readability // update build-CI, // update readme.md, Badges. -// +// 0.3.2 2021-12-29 update library.json, readme, license, unit test, minor edits #include "XMLWriter.h" @@ -427,3 +427,4 @@ void XMLWriter::escape(const char* str) // -- END OF FILE -- + diff --git a/libraries/XMLWriter/XMLWriter.h b/libraries/XMLWriter/XMLWriter.h index d84bdbad..37576e80 100644 --- a/libraries/XMLWriter/XMLWriter.h +++ b/libraries/XMLWriter/XMLWriter.h @@ -2,7 +2,7 @@ // // FILE: XMLWriter.h // AUTHOR: Rob Tillaart -// VERSION: 0.3.1 +// VERSION: 0.3.2 // DATE: 2013-11-06 // PURPOSE: Arduino library for creating XML // @@ -11,40 +11,40 @@ #include "Arduino.h" -#define XMLWRITER_VERSION (F("0.3.1")) +#define XMLWRITER_VERSION (F("0.3.2")) // for comment() -#define NOMULTILINE false -#define MULTILINE true +#define NOMULTILINE false +#define MULTILINE true // for tagOpen(), tagEnd() -#define NEWLINE true -#define NONEWLINE false -#define NOINDENT false // for tagClose() +#define NEWLINE true +#define NONEWLINE false +#define NOINDENT false // for tagClose() // for tagEnd() -#define SLASH true -#define NOSLASH false +#define SLASH true +#define NOSLASH false // deepness of XML tree 5..10 // needed for stack of tagStack #ifndef XMLWRITER_MAXLEVEL -#define XMLWRITER_MAXLEVEL 5 // adjust for deeper nested structures +#define XMLWRITER_MAXLEVEL 5 // adjust for deeper nested structures #endif #ifndef XMLWRITER_MAXTAGSIZE -#define XMLWRITER_MAXTAGSIZE 15 // adjust for longer fields - !! eats memory !! +#define XMLWRITER_MAXTAGSIZE 15 // adjust for longer fields - !! eats memory !! #endif // reduce footprint by commenting next line #define XMLWRITER_ESCAPE_SUPPORT // configuration - setConfig -#define XMLWRITER_NONE 0x00 -#define XMLWRITER_COMMENT 0x01 -#define XMLWRITER_INDENT 0x02 -#define XMLWRITER_NEWLINE 0x04 +#define XMLWRITER_NONE 0x00 +#define XMLWRITER_COMMENT 0x01 +#define XMLWRITER_INDENT 0x02 +#define XMLWRITER_NEWLINE 0x04 // uncomment next line to reduce ~30bytes RAM in escape() (AVR oonly) // #define __PROGMEM__ diff --git a/libraries/XMLWriter/examples/KMLWriterTest/KMLWriterTest.ino b/libraries/XMLWriter/examples/KMLWriterTest/KMLWriterTest.ino index 5e8e5a8e..4ec74fd4 100644 --- a/libraries/XMLWriter/examples/KMLWriterTest/KMLWriterTest.ino +++ b/libraries/XMLWriter/examples/KMLWriterTest/KMLWriterTest.ino @@ -1,11 +1,10 @@ // // FILE: KMLWriterTest.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.3 // PURPOSE: simple KML writer // DATE: 2015-05-21 // URL: https://github.com/RobTillaart/XMLWriter -// + #include @@ -96,3 +95,4 @@ This is a demo of the XMLWriter lib for Arduino // -- END OF FILE -- + diff --git a/libraries/XMLWriter/examples/XMLWriterDefaultSerial/XMLWriterDefaultSerial.ino b/libraries/XMLWriter/examples/XMLWriterDefaultSerial/XMLWriterDefaultSerial.ino index 5edb7143..81b1c960 100644 --- a/libraries/XMLWriter/examples/XMLWriterDefaultSerial/XMLWriterDefaultSerial.ino +++ b/libraries/XMLWriter/examples/XMLWriterDefaultSerial/XMLWriterDefaultSerial.ino @@ -1,11 +1,9 @@ // // FILE: XMLWriterDefaultSerial.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 // PURPOSE: make a simple XML generating lib // DATE: 2020-04-24 // URL: https://github.com/RobTillaart/XMLWriter -// #include @@ -133,3 +131,4 @@ void loop() // -- END OF FILE -- + diff --git a/libraries/XMLWriter/examples/XMLWriterEthernet/0.1.0/XMLWriterEthernet.ino b/libraries/XMLWriter/examples/XMLWriterEthernet/0.1.0/XMLWriterEthernet.ino index 0b21b075..7ca64fa7 100644 --- a/libraries/XMLWriter/examples/XMLWriterEthernet/0.1.0/XMLWriterEthernet.ino +++ b/libraries/XMLWriter/examples/XMLWriterEthernet/0.1.0/XMLWriterEthernet.ino @@ -1,11 +1,10 @@ // // FILE: XMLWriterEthernet.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: demo XML writer for EthernetClient // DATE: 2020-04-24 // URL: https://github.com/RobTillaart/XMLWriter -// + #include diff --git a/libraries/XMLWriter/examples/XMLWriterEthernet/XMLWriterEthernet.ino b/libraries/XMLWriter/examples/XMLWriterEthernet/XMLWriterEthernet.ino index f7fc4744..74e5cea2 100644 --- a/libraries/XMLWriter/examples/XMLWriterEthernet/XMLWriterEthernet.ino +++ b/libraries/XMLWriter/examples/XMLWriterEthernet/XMLWriterEthernet.ino @@ -1,11 +1,9 @@ // // FILE: XMLWriterEthernet.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 // PURPOSE: demo XML writer for EthernetClient // DATE: 2020-04-24 // URL: https://github.com/RobTillaart/XMLWriter -// #include diff --git a/libraries/XMLWriter/examples/XMLWriterPrint_1/XMLWriterPrint_1.ino b/libraries/XMLWriter/examples/XMLWriterPrint_1/XMLWriterPrint_1.ino index 59eb3ad0..77329af1 100644 --- a/libraries/XMLWriter/examples/XMLWriterPrint_1/XMLWriterPrint_1.ino +++ b/libraries/XMLWriter/examples/XMLWriterPrint_1/XMLWriterPrint_1.ino @@ -1,11 +1,10 @@ // // FILE: XMLWriterPrint_1.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 // PURPOSE: demo Print interface // DATE: 2020-07-07 // URL: https://github.com/RobTillaart/XMLWriter -// + #include @@ -24,7 +23,8 @@ void setup() XML.comment("XMLWriter Print interface"); XML.setConfig(0); // no indent, no (further) comments - // The {} are not mandatory shows the XML structure in the code... + // The {} and indentations are not mandatory + // however they shows the XML structure in the code... XML.tagOpen("Order"); { diff --git a/libraries/XMLWriter/examples/XMLWriterPrint_3/XMLWriterPrint_3.ino b/libraries/XMLWriter/examples/XMLWriterPrint_3/XMLWriterPrint_3.ino index a4b398f2..780b8519 100644 --- a/libraries/XMLWriter/examples/XMLWriterPrint_3/XMLWriterPrint_3.ino +++ b/libraries/XMLWriter/examples/XMLWriterPrint_3/XMLWriterPrint_3.ino @@ -1,14 +1,12 @@ // // FILE: XMLWriterPrint_3.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 // PURPOSE: demo Print interface - Printable data types // DATE: 2020-07-07 // URL: https://github.com/RobTillaart/XMLWriter // - -// example works for UNO but does not compile for ESP, -// to investigate [complex vs Complex] +// example works for UNO but does not compile for ESP, +// to investigate [complex vs Complex] #include @@ -47,3 +45,4 @@ void loop() // -- END OF FILE -- + diff --git a/libraries/XMLWriter/examples/XMLWriterPrint_4/XMLWriterPrint_4.ino b/libraries/XMLWriter/examples/XMLWriterPrint_4/XMLWriterPrint_4.ino index e6e77654..fda25aab 100644 --- a/libraries/XMLWriter/examples/XMLWriterPrint_4/XMLWriterPrint_4.ino +++ b/libraries/XMLWriter/examples/XMLWriterPrint_4/XMLWriterPrint_4.ino @@ -1,18 +1,16 @@ // // FILE: XMLWriterPrint_4.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 // PURPOSE: demo Print interface - PROGMEM strings // DATE: 2020-07-07 // URL: https://github.com/RobTillaart/XMLWriter -// #include XMLWriter XML(&Serial); -#define NUMBERZ F("1.2.3.4.5") +#define NUMBERZ (F("1.2.3.4.5")) void setup() @@ -41,3 +39,4 @@ void loop() // -- END OF FILE -- + diff --git a/libraries/XMLWriter/examples/XMLWriterSDcard/XMLWriterSDcard.ino b/libraries/XMLWriter/examples/XMLWriterSDcard/XMLWriterSDcard.ino index fe2fad3c..ec41ce3e 100644 --- a/libraries/XMLWriter/examples/XMLWriterSDcard/XMLWriterSDcard.ino +++ b/libraries/XMLWriter/examples/XMLWriterSDcard/XMLWriterSDcard.ino @@ -1,24 +1,22 @@ // -// FILE: XMLWriterSDcard.ino.ino +// FILE: XMLWriterSDcard.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 // PURPOSE: XML writing to SD card // DATE: 2020-04-24 // URL: https://github.com/RobTillaart/XMLWriter // // Note: this application will write to the SD card immediately // and it will append to the data.xml file every time started. -// #include #include -// SPI PINS -// MOSI 11 -// MISO 12 -// CLOCK 13 -// CS 10 -#define CS 10 // adjust this ChipSelect line if needed ! +// SPI PINS +// MOSI 11 +// MISO 12 +// CLOCK 13 +// CS 10 +#define CS 10 // adjust this ChipSelect line if needed ! #include diff --git a/libraries/XMLWriter/examples/XMLWriterTest/XMLWriterTest.ino b/libraries/XMLWriter/examples/XMLWriterTest/XMLWriterTest.ino index fd40b831..4902e93f 100644 --- a/libraries/XMLWriter/examples/XMLWriterTest/XMLWriterTest.ino +++ b/libraries/XMLWriter/examples/XMLWriterTest/XMLWriterTest.ino @@ -1,11 +1,10 @@ // // FILE: XMLWriterTest.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.6 // PURPOSE: make a simple XML generating lib // DATE: 2013-11-06 // URL: https://github.com/RobTillaart/XMLWriter -// + #include diff --git a/libraries/XMLWriter/examples/XMLWriterdemo01/XMLWriterdemo01.ino b/libraries/XMLWriter/examples/XMLWriterdemo01/XMLWriterdemo01.ino index 15c8dc35..2fda3c3e 100644 --- a/libraries/XMLWriter/examples/XMLWriterdemo01/XMLWriterdemo01.ino +++ b/libraries/XMLWriter/examples/XMLWriterdemo01/XMLWriterdemo01.ino @@ -1,11 +1,10 @@ // // FILE: XMLWriterDemo01.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.3 // PURPOSE: XML writer demo // DATE: 2016-03-16 // URL: https://github.com/RobTillaart/XMLWriter -// + #include @@ -106,3 +105,4 @@ void loop() // -- END OF FILE -- + diff --git a/libraries/XMLWriter/keywords.txt b/libraries/XMLWriter/keywords.txt index 6bd35026..442d9ec6 100644 --- a/libraries/XMLWriter/keywords.txt +++ b/libraries/XMLWriter/keywords.txt @@ -39,6 +39,8 @@ bytesWritten KEYWORD2 # Instances (KEYWORD2) # Constants (LITERAL1) +XMLWRITER_VERSION LITERAL1 + NOMULTILINE LITERAL1 MULTILINE LITERAL1 NEWLINE LITERAL1 diff --git a/libraries/XMLWriter/library.json b/libraries/XMLWriter/library.json index 878e53f7..1a6dfa7a 100644 --- a/libraries/XMLWriter/library.json +++ b/libraries/XMLWriter/library.json @@ -15,8 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/XMLWriter" }, - "version": "0.3.1", + "version": "0.3.2", "license": "MIT", "frameworks": "arduino", - "platforms": "*" + "platforms": "*", + "headers": "XMLWriter.h" } diff --git a/libraries/XMLWriter/library.properties b/libraries/XMLWriter/library.properties index 4c7127ef..ec91ac44 100644 --- a/libraries/XMLWriter/library.properties +++ b/libraries/XMLWriter/library.properties @@ -1,5 +1,5 @@ name=XMLWriter -version=0.3.1 +version=0.3.2 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for creating XML diff --git a/libraries/XMLWriter/test/unit_test_001.cpp b/libraries/XMLWriter/test/unit_test_001.cpp index 068c2cc5..9b853278 100644 --- a/libraries/XMLWriter/test/unit_test_001.cpp +++ b/libraries/XMLWriter/test/unit_test_001.cpp @@ -37,6 +37,7 @@ unittest_setup() { + fprintf(stderr, "XMLWRITER_VERSION: %s\n", (char *) XMLWRITER_VERSION); } unittest_teardown() @@ -44,10 +45,30 @@ unittest_teardown() } +unittest(test_constants) +{ + assertFalse(NOMULTILINE); + assertTrue(MULTILINE); + + assertTrue(NEWLINE); + assertFalse(NONEWLINE); + assertFalse(NOINDENT); + + assertTrue(SLASH); + assertFalse(NOSLASH); + + assertEqual( 5, XMLWRITER_MAXLEVEL); + assertEqual(15, XMLWRITER_MAXTAGSIZE); + + assertEqual(0x00, XMLWRITER_NONE ); + assertEqual(0x01, XMLWRITER_COMMENT); + assertEqual(0x02, XMLWRITER_INDENT ); + assertEqual(0x04, XMLWRITER_NEWLINE); +} + + unittest(test_constructor) { - fprintf(stderr, "VERSION: %s\n", XMLWRITER_VERSION); - XMLWriter XML(&Serial); assertEqual(0, XML.bytesWritten()); assertEqual(2, XML.getIndentSize()); @@ -59,8 +80,6 @@ unittest(test_constructor) unittest(test_header_flush) { - fprintf(stderr, "VERSION: %s\n", XMLWRITER_VERSION); - XMLWriter XML(&Serial); XML.header();