mirror of https://github.com/AxioDL/tinyxml2.git
Changed indentation style to match tinyxml2 project.
This commit is contained in:
parent
9460e5093c
commit
bc785155f2
|
@ -37,51 +37,51 @@ static const char input[] =
|
||||||
class XMLPrinterHTML5 : public XMLPrinter
|
class XMLPrinterHTML5 : public XMLPrinter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XMLPrinterHTML5 (FILE* file=0, bool compact = false, int depth = 0) :
|
XMLPrinterHTML5 (FILE* file=0, bool compact = false, int depth = 0) :
|
||||||
XMLPrinter (file, compact, depth)
|
XMLPrinter (file, compact, depth)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CloseElement () {
|
virtual void CloseElement () {
|
||||||
if (_elementJustOpened && !isVoidElement (_stack.PeekTop())) {
|
if (_elementJustOpened && !isVoidElement (_stack.PeekTop())) {
|
||||||
SealElement();
|
SealElement();
|
||||||
}
|
}
|
||||||
XMLPrinter::CloseElement();
|
XMLPrinter::CloseElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isVoidElement (const char *name) {
|
virtual bool isVoidElement (const char *name) {
|
||||||
// Complete list of all HTML5 "void elements",
|
// Complete list of all HTML5 "void elements",
|
||||||
// http://dev.w3.org/html5/markup/syntax.html
|
// http://dev.w3.org/html5/markup/syntax.html
|
||||||
static const char *list[] = {
|
static const char *list[] = {
|
||||||
"area", "base", "br", "col", "command", "embed", "hr", "img",
|
"area", "base", "br", "col", "command", "embed", "hr", "img",
|
||||||
"input", "keygen", "link", "meta", "param", "source", "track", "wbr",
|
"input", "keygen", "link", "meta", "param", "source", "track", "wbr",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
// I could use 'bsearch', but I don't have MSVC to test on (it would work with gcc/libc).
|
// I could use 'bsearch', but I don't have MSVC to test on (it would work with gcc/libc).
|
||||||
for (const char **p = list; *p; ++p) {
|
for (const char **p = list; *p; ++p) {
|
||||||
if (!strcasecmp (name, *p)) {
|
if (!strcasecmp (name, *p)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
XMLDocument doc (false);
|
XMLDocument doc (false);
|
||||||
doc.Parse (input);
|
doc.Parse (input);
|
||||||
|
|
||||||
std::cout << "INPUT:\n" << input << "\n\n";
|
std::cout << "INPUT:\n" << input << "\n\n";
|
||||||
|
|
||||||
XMLPrinter prn (NULL, true);
|
XMLPrinter prn (NULL, true);
|
||||||
doc.Print (&prn);
|
doc.Print (&prn);
|
||||||
std::cout << "XMLPrinter (not valid HTML5):\n" << prn.CStr() << "\n\n";
|
std::cout << "XMLPrinter (not valid HTML5):\n" << prn.CStr() << "\n\n";
|
||||||
|
|
||||||
XMLPrinterHTML5 html5 (NULL, true);
|
XMLPrinterHTML5 html5 (NULL, true);
|
||||||
doc.Print (&html5);
|
doc.Print (&html5);
|
||||||
std::cout << "XMLPrinterHTML5:\n" << html5.CStr() << "\n";
|
std::cout << "XMLPrinterHTML5:\n" << html5.CStr() << "\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue