Browse Source

When saving plugin data, split big chunks into new lines

tags/1.9.4
falkTX 10 years ago
parent
commit
377819f2a4
1 changed files with 27 additions and 2 deletions
  1. +27
    -2
      source/utils/CarlaStateUtils.cpp

+ 27
- 2
source/utils/CarlaStateUtils.cpp View File

@@ -27,6 +27,30 @@ using juce::XmlElement;

CARLA_BACKEND_START_NAMESPACE

// -----------------------------------------------------------------------
// getNewLineSplittedString

static String getNewLineSplittedString(const String& string)
{
static const int kLineWidth = 120;

int i=0;
const int length=string.length();

String newString;
newString.preallocateBytes(static_cast<size_t>(length + length/120 + 2));

for (; i+kLineWidth < length; i += kLineWidth)
{
newString += string.substring(i, i+kLineWidth);
newString += "\n";
}

newString += string.substring(i);

return newString;
}

// -----------------------------------------------------------------------
// xmlSafeString

@@ -377,7 +401,8 @@ bool StateSave::fillFromXmlElement(const XmlElement* const xmlElement)

else if (tag.equalsIgnoreCase("chunk"))
{
chunk = xmlSafeStringCharDup(text, false);
const String nText(text.replace("\n", ""));
chunk = xmlSafeStringCharDup(nText, false);
}
}
}
@@ -554,7 +579,7 @@ String StateSave::toString() const
if (chunk != nullptr && chunk[0] != '\0')
{
String chunkXml("\n"" <Chunk>\n");
chunkXml << chunk << "\n </Chunk>\n";
chunkXml << getNewLineSplittedString(chunk) << "\n </Chunk>\n";

content << chunkXml;
}


Loading…
Cancel
Save