41 *
writer <<
"<?xml version=\"" << version.c_str() <<
"\" ";
47 *
writer <<
"standalone=\"yes\" ";
56 cerr <<
"XMLWriter::ReferToDTD cannot be called twice" << endl;
59 *
writer <<
"<!DOCTYPE " << name.c_str() <<
" PUBLIC \"" << pid.c_str() <<
"\" \"" << ref.c_str() <<
"\">" << endl;
64 cerr <<
"XMLWriter::ReferToDTD cannot be called twice";
67 *
writer <<
"<!DOCTYPE " << name.c_str() <<
" SYSTEM \"" << system.c_str() <<
"\">" << endl;
72 if (!openTags.empty()) {
73 if (!force) cerr <<
"Not all tags were closed before closing XML document:" << endl;
74 while (!openTags.empty()) {
78 cerr <<
" </" << openTags.top().c_str() <<
">" << endl;
88 if (comment.find(
"--") != string::npos) {
89 cerr <<
"XMLWriter::printComment '--' sequence not allowed in comment" << endl;
109 if (openTags.empty() && dtdName.compare(
"") && dtdName.compare(name)) {
110 cerr <<
"XMLWriter::openTag(), First tag: '" << name <<
"' not equal to DTD id: '" << dtdName <<
"'" << endl;
112 *
writer <<
"<" << name.c_str();
120 if (openTags.empty()) {
122 cerr <<
"XMLWriter::closeTag(), No open tags" << endl;
124 string name = openTags.top();
127 *
writer <<
"</" << name.c_str() <<
">" << endl;
132 *
writer <<
"<" << name.c_str();
142 attributes[name] = value;
147 if (name ==
"value")
setAttribute(
"type", (std::string)
"Color");
152 if (name ==
"value")
setAttribute(
"type", (std::string)
"long");
157 if (name ==
"showlabel") {
161 if (name ==
"value")
setAttribute(
"type", (std::string)
"int");
167 if (name ==
"value")
setAttribute(
"type", (std::string)
"boolean");
172 if (name ==
"value")
setAttribute(
"type", (std::string)
"double");
177 int width = tagLength + 1;
178 bool extraIndent =
false;
179 for (map<string,string>::iterator i = attributes.begin(); i != attributes.end(); i++) {
180 string key = i->first;
183 int length = key.length() + value.length() + 3;
195 *
writer << key.c_str() <<
"=\"" << value.c_str() <<
"\"";
205 int len = s.length();
206 for (
int i = 0; i < len; i++) {
222 str.append(
""");
227 sprintf(
buffer,
"&#%ud", ch);
250 int len = s.length();
251 for (
int i = 0; i < len; i++) {
std::string toShowLabel()
std::string getAsString()
std::string getIndentString() const
void setIndentString(const std::string &indentString)
XMLWriter(std::ostream *out, std::string indentString=" ", std::string defaultNameSpace="")
void printComment(std::string comment)
void checkNameValid(std::string s)
void openTag(std::string name)
IndentPrintWriter * writer
void print(std::string text)
std::string normalize(std::string s)
std::string normalizeText(std::string s)
void openDoc(std::string version="1.0", std::string encoding="", bool standalone=false)
void closeDoc(bool force=false)
void referToDTD(std::string name, std::string pid, std::string ref)
void setAttribute(std::string name, char *value)
void printAttributes(int tagLength)
void printTag(std::string name)
void println(std::string text)
void printPlain(std::string text)