本文整理汇总了C++中TextWriter::newline方法的典型用法代码示例。如果您正苦于以下问题:C++ TextWriter::newline方法的具体用法?C++ TextWriter::newline怎么用?C++ TextWriter::newline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextWriter
的用法示例。
在下文中一共展示了TextWriter::newline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
XMLNode::serialiseR(const XMLNodeData *pEntry, TextWriter &writer, int nFormat)
{
unsigned cb;
int nChildFormat = -1;
bool bHasChildren = false;
assert(pEntry);
// If the element has no name then assume this is the head node.
if (!string_is_empty(pEntry->lpszName)) {
// "<elementname "
cb = nFormat == -1 ? 0 : nFormat;
write_indent(writer, cb);
writer.write('<');
if (pEntry->isDeclaration)
writer.write('?');
writer.write(pEntry->lpszName);
// Enumerate attributes and add them to the string
for (auto i = pEntry->pAttribute.begin(), end = pEntry->pAttribute.end();
i != end; ++i) {
const XMLNodeData::Attribute *pAttr = &*i;
writer.write(' ');
writer.write(pAttr->lpszName);
writer.write('=');
writer.write('"');
if (pAttr->lpszValue != NULL)
write_xml_string(writer, pAttr->lpszValue);
writer.write('"');
pAttr++;
}
bHasChildren = pEntry->HasChildren();
if (pEntry->isDeclaration) {
writer.write('?');
writer.write('>');
if (nFormat != -1)
writer.newline();
} else
// If there are child nodes we need to terminate the start tag
if (bHasChildren) {
writer.write('>');
if (nFormat != -1)
writer.newline();
}
}
// Calculate the child format for when we recurse. This is used to
// determine the number of spaces used for prefixes.
if (nFormat != -1) {
if (!string_is_empty(pEntry->lpszName))
nChildFormat = nFormat + 1;
else
nChildFormat = nFormat;
}
/* write the child elements */
for (auto i = pEntry->begin(), end = pEntry->end(); i != end; ++i)
serialiseR(i->d, writer, nChildFormat);
/* write the text */
if (!pEntry->text.empty()) {
if (nFormat != -1) {
write_indent(writer, nFormat + 1);
write_xml_string(writer, pEntry->text.c_str());
writer.newline();
} else {
write_xml_string(writer, pEntry->text.c_str());
}
}
if (!string_is_empty(pEntry->lpszName) && !pEntry->isDeclaration) {
// If we have child entries we need to use long XML notation for
// closing the element - "<elementname>blah blah blah</elementname>"
if (bHasChildren) {
// "</elementname>\0"
if (nFormat != -1)
write_indent(writer, nFormat);
writer.write("</");
writer.write(pEntry->lpszName);
writer.write('>');
} else {
// If there are no children we can use shorthand XML notation -
// "<elementname/>"
// "/>\0"
writer.write("/>");
}
if (nFormat != -1)
writer.newline();
}
}