Browse Source

Cleanup some water

Signed-off-by: falkTX <falktx@gmail.com>
tags/v2.1-alpha1-winvst
falkTX 5 years ago
parent
commit
6f20d4c636
5 changed files with 20 additions and 23 deletions
  1. +2
    -2
      source/modules/water/containers/Array.h
  2. +1
    -11
      source/modules/water/text/NewLine.h
  3. +2
    -4
      source/modules/water/text/String.cpp
  4. +12
    -5
      source/modules/water/xml/XmlElement.cpp
  5. +3
    -1
      source/modules/water/xml/XmlElement.h

+ 2
- 2
source/modules/water/containers/Array.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
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
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -120,7 +120,7 @@ public:
/** Destructor. */
~Array() noexcept
{
deleteAllElements();
clear();
}
/** Copies another array.


+ 1
- 11
source/modules/water/text/NewLine.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
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
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.


+ 2
- 4
source/modules/water/text/String.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
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
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


+ 12
- 5
source/modules/water/xml/XmlElement.cpp View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
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
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 << "<?xml version=\"1.0\" encoding=\"" << encodingType << "\"?>";
@@ -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;
}


+ 3
- 1
source/modules/water/xml/XmlElement.h View File

@@ -3,7 +3,7 @@
This file is part of the Water library.
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
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.


Loading…
Cancel
Save