37 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 38 "<root name1=\"value1\" name2=\"420\" name3=\"0.666\">\n" 39 " <record name=\"nixon\"\n" 42 " <quote>I'm not a crook.</quote>\n" 45 " <record name=\""Penn & Teller"\">\n" 46 " <quote>'Bull<shit!'</quote>\n" 48 " <record name=\"clinton\"\n" 51 " <quote>I did <em>not</em> have sexual relations with that woman.</quote>\n" 54 " <record name=\"bush\"\n" 57 " <quote>Mission accomplished.</quote>\n" 64 virtual void update(
const string& output)
87 const char* piData =
"version=\"1.0\" encoding=\"UTF-8\"";
93 attributes.push_back(make_pair(
"name1",
"value1"));
94 attributes.push_back(make_pair(
"name2",
"420"));
95 attributes.push_back(make_pair(
"name3",
"0.666"));
102 attributes.push_back(make_pair(
"name",
"nixon"));
103 attributes.push_back(make_pair(
"color",
"red"));
104 attributes.push_back(make_pair(
"number",
"37"));
105 writer.
pushStyle(XMLWriter::StyleFlag_AttributesOnMultipleLines);
117 attributes.push_back(make_pair(
"name",
"\"Penn & Teller\""));
127 attributes.push_back(make_pair(
"name",
"clinton"));
128 attributes.push_back(make_pair(
"color",
"blue"));
129 attributes.push_back(make_pair(
"number",
"42"));
130 writer.
pushStyle(XMLWriter::StyleFlag_AttributesOnMultipleLines);
141 writer.
characters(
" have sexual relations with that woman.");
149 attributes.push_back(make_pair(
"name",
"bush"));
150 attributes.push_back(make_pair(
"color",
"red"));
151 attributes.push_back(make_pair(
"number",
"43"));
152 writer.
pushStyle(XMLWriter::StyleFlag_AttributesOnMultipleLines);
164 if (
os_) *
os_ <<
"test: (" << oss.str().size() <<
")\n" << oss.str() << endl;
170 if (
os_) *
os_ <<
"outputObserver cache:\n" << outputObserver.
cache << endl;
176 string id1(
"1invalid ID");
181 string id2(
"_invalid-ID_#2_<3>");
185 string crazyId(
"!!!");
191 #ifndef __APPLE__ // TODO: how to test that this works with Darwin's compiler? 194 attributes.
add(
"1", 2.2250738585072014e-309);
195 attributes.
add(
"2", -2.2250738585072014e-309);
202 int main(
int argc,
char* argv[])
208 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
void processingInstruction(const std::string &name, const std::string &data)
writes a processing instruction
The XMLWriter class provides simple, tag-level XML syntax writing.
void pushStyle(unsigned int flags)
pushes style flags onto the internal style stack
unsigned int indentationStep
void endElement()
writes element end tag
initial configuration of the XMLWriter
void characters(const std::string &text, bool autoEscape=true)
writes character data; autoEscape writes reserved XML characters in the input text in their escaped f...
virtual void update(const string &output)
#define unit_assert_operator_equal(expected, actual)
interface to allow outside observation of data sent to output stream
PWIZ_API_DECL std::string encode_xml_id_copy(const std::string &str)
Encodes any characters not suitable in an xml:ID or xml:IDREF with their hexadecimal value...
void popStyle()
pops the style stack
stream_offset position() const
returns current stream position
vector of name/value pairs to be written as XML attributes
void add(const std::string &name, const double &value)
stream_offset positionNext() const
returns stream position of next element start tag
#define TEST_PROLOG(argc, argv)
void startElement(const std::string &name, const Attributes &attributes=Attributes(), EmptyElementTag emptyElementTag=NotEmptyElement)
writes element start tag
PWIZ_API_DECL std::string & encode_xml_id(std::string &str)
Encodes any characters not suitable in an xml:ID or xml:IDREF with their hexadecimal value...
OutputObserver * outputObserver
int main(int argc, char *argv[])