@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com> | |||||
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com> | |||||
Permission is granted to use this software under the terms of the ISC license | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -120,7 +120,7 @@ public: | |||||
/** Destructor. */ | /** Destructor. */ | ||||
~Array() noexcept | ~Array() noexcept | ||||
{ | { | ||||
deleteAllElements(); | |||||
clear(); | |||||
} | } | ||||
/** Copies another array. | /** Copies another array. | ||||
@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com> | |||||
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com> | |||||
Permission is granted to use this software under the terms of the ISC license | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -60,16 +60,6 @@ public: | |||||
operator StringRef() const noexcept { return getDefault(); } | 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. | /** Writes a new-line sequence to a string. | ||||
You can use the predefined object 'newLine' to invoke this, e.g. | You can use the predefined object 'newLine' to invoke this, e.g. | ||||
@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017-2018 Filipe Coelho <falktx@falktx.com> | |||||
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com> | |||||
Permission is granted to use this software under the terms of the ISC license | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -43,8 +43,6 @@ | |||||
namespace water { | namespace water { | ||||
NewLine newLine; | |||||
//============================================================================== | //============================================================================== | ||||
// (Mirrors the structure of StringHolder, but without the atomic member, so can be statically constructed) | // (Mirrors the structure of StringHolder, but without the atomic member, so can be statically constructed) | ||||
struct EmptyString | struct EmptyString | ||||
@@ -54,7 +52,7 @@ struct EmptyString | |||||
String::CharPointerType::CharType text; | 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 | class StringHolder | ||||
@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com> | |||||
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com> | |||||
Permission is granted to use this software under the terms of the ISC license | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -272,6 +272,8 @@ void XmlElement::writeElementAsText (OutputStream& outputStream, | |||||
{ | { | ||||
using namespace XmlOutputFunctions; | using namespace XmlOutputFunctions; | ||||
NewLine newLine; | |||||
if (indentationLevel >= 0) | if (indentationLevel >= 0) | ||||
writeSpaces (outputStream, (size_t) indentationLevel); | writeSpaces (outputStream, (size_t) indentationLevel); | ||||
@@ -369,6 +371,8 @@ void XmlElement::writeToStream (OutputStream& output, | |||||
{ | { | ||||
using namespace XmlOutputFunctions; | using namespace XmlOutputFunctions; | ||||
NewLine newLine; | |||||
if (includeXmlHeader) | if (includeXmlHeader) | ||||
{ | { | ||||
output << "<?xml version=\"1.0\" encoding=\"" << encodingType << "\"?>"; | output << "<?xml version=\"1.0\" encoding=\"" << encodingType << "\"?>"; | ||||
@@ -854,7 +858,10 @@ bool XmlElement::isTextElement() const noexcept | |||||
return tagName.isEmpty(); | return tagName.isEmpty(); | ||||
} | } | ||||
static const String water_xmltextContentAttributeName ("text"); | |||||
static const String water_xmltextContentAttributeName () | |||||
{ | |||||
return String ("text"); | |||||
} | |||||
const String& XmlElement::getText() const noexcept | 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 | // isn't actually a text element.. If this contains text sub-nodes, you | ||||
// probably want to use getAllSubText instead. | // probably want to use getAllSubText instead. | ||||
return getStringAttribute (water_xmltextContentAttributeName); | |||||
return getStringAttribute (water_xmltextContentAttributeName()); | |||||
} | } | ||||
void XmlElement::setText (const String& newText) | void XmlElement::setText (const String& newText) | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(isTextElement(),); | CARLA_SAFE_ASSERT_RETURN(isTextElement(),); | ||||
setAttribute (water_xmltextContentAttributeName, newText); | |||||
setAttribute (water_xmltextContentAttributeName(), newText); | |||||
} | } | ||||
String XmlElement::getAllSubText() const | String XmlElement::getAllSubText() const | ||||
@@ -898,7 +905,7 @@ String XmlElement::getChildElementAllSubText (StringRef childTagName, const Stri | |||||
XmlElement* XmlElement::createTextElement (const String& text) | XmlElement* XmlElement::createTextElement (const String& text) | ||||
{ | { | ||||
XmlElement* const e = new XmlElement ((int) 0); | XmlElement* const e = new XmlElement ((int) 0); | ||||
e->setAttribute (water_xmltextContentAttributeName, text); | |||||
e->setAttribute (water_xmltextContentAttributeName(), text); | |||||
return e; | return e; | ||||
} | } | ||||
@@ -3,7 +3,7 @@ | |||||
This file is part of the Water library. | This file is part of the Water library. | ||||
Copyright (c) 2016 ROLI Ltd. | Copyright (c) 2016 ROLI Ltd. | ||||
Copyright (C) 2017 Filipe Coelho <falktx@falktx.com> | |||||
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com> | |||||
Permission is granted to use this software under the terms of the ISC license | Permission is granted to use this software under the terms of the ISC license | ||||
http://www.isc.org/downloads/software-support-policy/isc-license/ | http://www.isc.org/downloads/software-support-policy/isc-license/ | ||||
@@ -235,6 +235,7 @@ public: | |||||
StringRef encodingType = "UTF-8", | StringRef encodingType = "UTF-8", | ||||
int lineWrapLength = 60) const; | int lineWrapLength = 60) const; | ||||
#if 0 | |||||
/** Writes the element to a file as an XML document. | /** Writes the element to a file as an XML document. | ||||
To improve safety in case something goes wrong while writing the file, this | To improve safety in case something goes wrong while writing the file, this | ||||
@@ -258,6 +259,7 @@ public: | |||||
StringRef dtdToUse, | StringRef dtdToUse, | ||||
StringRef encodingType = "UTF-8", | StringRef encodingType = "UTF-8", | ||||
int lineWrapLength = 60) const; | int lineWrapLength = 60) const; | ||||
#endif | |||||
//============================================================================== | //============================================================================== | ||||
/** Returns this element's tag type name. | /** Returns this element's tag type name. | ||||