diff --git a/source/modules/water/containers/Array.h b/source/modules/water/containers/Array.h index 73837902c..1205b7ceb 100644 --- a/source/modules/water/containers/Array.h +++ b/source/modules/water/containers/Array.h @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017-2018 Filipe Coelho + Copyright (C) 2017-2019 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -120,7 +120,7 @@ public: /** Destructor. */ ~Array() noexcept { - deleteAllElements(); + clear(); } /** Copies another array. diff --git a/source/modules/water/text/NewLine.h b/source/modules/water/text/NewLine.h index 7942d7218..8a65234e8 100644 --- a/source/modules/water/text/NewLine.h +++ b/source/modules/water/text/NewLine.h @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017 Filipe Coelho + Copyright (C) 2017-2019 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -60,16 +60,6 @@ public: operator StringRef() const noexcept { return getDefault(); } }; -//============================================================================== -/** A predefined object representing a new-line, which can be written to a string or stream. - - To write a new-line to a stream, you can use the predefined 'newLine' variable like this: - @code - myOutputStream << "Hello World" << newLine << newLine; - @endcode -*/ -extern NewLine newLine; - //============================================================================== /** Writes a new-line sequence to a string. You can use the predefined object 'newLine' to invoke this, e.g. diff --git a/source/modules/water/text/String.cpp b/source/modules/water/text/String.cpp index 4ffd33e28..a71e54be5 100644 --- a/source/modules/water/text/String.cpp +++ b/source/modules/water/text/String.cpp @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017-2018 Filipe Coelho + Copyright (C) 2017-2019 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -43,8 +43,6 @@ namespace water { -NewLine newLine; - //============================================================================== // (Mirrors the structure of StringHolder, but without the atomic member, so can be statically constructed) struct EmptyString @@ -54,7 +52,7 @@ struct EmptyString String::CharPointerType::CharType text; }; -static const EmptyString emptyString = { 0x3fffffff, sizeof (String::CharPointerType::CharType), 0 }; +static const EmptyString emptyString = { 0x3fffffff, sizeof (String::CharPointerType::CharType), '\0' }; //============================================================================== class StringHolder diff --git a/source/modules/water/xml/XmlElement.cpp b/source/modules/water/xml/XmlElement.cpp index 24ce2958a..a274c3030 100644 --- a/source/modules/water/xml/XmlElement.cpp +++ b/source/modules/water/xml/XmlElement.cpp @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017 Filipe Coelho + Copyright (C) 2017-2019 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -272,6 +272,8 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, { using namespace XmlOutputFunctions; + NewLine newLine; + if (indentationLevel >= 0) writeSpaces (outputStream, (size_t) indentationLevel); @@ -369,6 +371,8 @@ void XmlElement::writeToStream (OutputStream& output, { using namespace XmlOutputFunctions; + NewLine newLine; + if (includeXmlHeader) { output << ""; @@ -854,7 +858,10 @@ bool XmlElement::isTextElement() const noexcept return tagName.isEmpty(); } -static const String water_xmltextContentAttributeName ("text"); +static const String water_xmltextContentAttributeName () +{ + return String ("text"); +} const String& XmlElement::getText() const noexcept { @@ -862,13 +869,13 @@ const String& XmlElement::getText() const noexcept // isn't actually a text element.. If this contains text sub-nodes, you // probably want to use getAllSubText instead. - return getStringAttribute (water_xmltextContentAttributeName); + return getStringAttribute (water_xmltextContentAttributeName()); } void XmlElement::setText (const String& newText) { CARLA_SAFE_ASSERT_RETURN(isTextElement(),); - setAttribute (water_xmltextContentAttributeName, newText); + setAttribute (water_xmltextContentAttributeName(), newText); } String XmlElement::getAllSubText() const @@ -898,7 +905,7 @@ String XmlElement::getChildElementAllSubText (StringRef childTagName, const Stri XmlElement* XmlElement::createTextElement (const String& text) { XmlElement* const e = new XmlElement ((int) 0); - e->setAttribute (water_xmltextContentAttributeName, text); + e->setAttribute (water_xmltextContentAttributeName(), text); return e; } diff --git a/source/modules/water/xml/XmlElement.h b/source/modules/water/xml/XmlElement.h index 611f40877..d27b7d98d 100644 --- a/source/modules/water/xml/XmlElement.h +++ b/source/modules/water/xml/XmlElement.h @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2016 ROLI Ltd. - Copyright (C) 2017 Filipe Coelho + Copyright (C) 2017-2019 Filipe Coelho Permission is granted to use this software under the terms of the ISC license http://www.isc.org/downloads/software-support-policy/isc-license/ @@ -235,6 +235,7 @@ public: StringRef encodingType = "UTF-8", int lineWrapLength = 60) const; +#if 0 /** Writes the element to a file as an XML document. To improve safety in case something goes wrong while writing the file, this @@ -258,6 +259,7 @@ public: StringRef dtdToUse, StringRef encodingType = "UTF-8", int lineWrapLength = 60) const; +#endif //============================================================================== /** Returns this element's tag type name.