summaryrefslogtreecommitdiff
path: root/cpp/src/IceXML/Output.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2002-01-29 02:03:02 +0000
committerMatthew Newhook <matthew@zeroc.com>2002-01-29 02:03:02 +0000
commit1a347f053ed10e965411c4768567d3c6d0b0e424 (patch)
tree56685aadd79e5e7b954850369616e4d7915dbe1b /cpp/src/IceXML/Output.cpp
parentfix (diff)
downloadice-1a347f053ed10e965411c4768567d3c6d0b0e424.tar.bz2
ice-1a347f053ed10e965411c4768567d3c6d0b0e424.tar.xz
ice-1a347f053ed10e965411c4768567d3c6d0b0e424.zip
Added test/IceXML/encoding. Various bug fixes for IceXML.
Diffstat (limited to 'cpp/src/IceXML/Output.cpp')
-rw-r--r--cpp/src/IceXML/Output.cpp80
1 files changed, 50 insertions, 30 deletions
diff --git a/cpp/src/IceXML/Output.cpp b/cpp/src/IceXML/Output.cpp
index 8646d34fcee..291b89e55ae 100644
--- a/cpp/src/IceXML/Output.cpp
+++ b/cpp/src/IceXML/Output.cpp
@@ -17,8 +17,9 @@ namespace IceXML
{
NextLine nl;
-StartBlock sb;
-EndBlock eb;
+//StartBlock sb;
+//EndBlock eb;
+EndElement ee;
Separator sp;
}
@@ -32,8 +33,7 @@ IceXML::Output::Output() :
_pos(0),
_indent(0),
_separator(true),
- _blockStart("{"),
- _blockEnd("}"),
+ _printed(true),
_useTab(true),
_indentSize(4)
{
@@ -44,8 +44,7 @@ IceXML::Output::Output(ostream& os) :
_pos(0),
_indent(0),
_separator(true),
- _blockStart("{"),
- _blockEnd("}"),
+ _printed(true),
_useTab(true),
_indentSize(4)
{
@@ -56,8 +55,7 @@ IceXML::Output::Output(const char* s) :
_pos(0),
_indent(0),
_separator(true),
- _blockStart("{"),
- _blockEnd("}"),
+ _printed(true),
_useTab(true),
_indentSize(4)
{
@@ -73,6 +71,11 @@ IceXML::Output::open(const char* s)
void
IceXML::Output::print(const char* s)
{
+ if (!_printed)
+ {
+ _out << '>';
+ _printed = true;
+ }
for (unsigned int i = 0; i < strlen(s); ++i)
{
if (s[i] == '\n')
@@ -124,18 +127,6 @@ IceXML::Output::restoreIndent()
}
void
-IceXML::Output::setBeginBlock(const char *bb)
-{
- _blockStart = bb;
-}
-
-void
-IceXML::Output::setEndBlock(const char *eb)
-{
- _blockEnd = eb;
-}
-
-void
IceXML::Output::setIndent(int indentSize)
{
_indentSize = indentSize;
@@ -150,6 +141,12 @@ IceXML::Output::setUseTab(bool useTab)
void
IceXML::Output::nl()
{
+ if (!_printed)
+ {
+ _printed = true;
+ _out << '>';
+ }
+
_out << '\n';
_pos = 0;
_separator = true;
@@ -186,28 +183,51 @@ IceXML::Output::nl()
}
void
-IceXML::Output::sb()
+IceXML::Output::se(const std::string& element)
{
- if (_blockStart.length())
+ nl();
+
+ //
+ // The output of the '>' character is deferred until either the
+ //end-element (in which case a /> is emitted) or until something
+ //is displayed.
+ //
+ _out << '<' << element;
+
+ string::size_type pos = element.find_first_of(" \t");
+ if (pos == string::npos)
+ {
+ _elementStack.push(element);
+ }
+ else
{
- nl();
- _out << _blockStart;
+ _elementStack.push(element.substr(0, pos));
}
- ++_pos;
+
+ ++_pos; // TODO: ???
inc();
_separator = false;
+ _printed = false;
}
void
-IceXML::Output::eb()
+IceXML::Output::ee()
{
+ string element = _elementStack.top();
+ _elementStack.pop();
+
dec();
- if (_blockEnd.length())
+ if (!_printed)
+ {
+ _out << "/>";
+ }
+ else
{
- nl();
- _out << _blockEnd;
+ nl();
+ _out << "</" << element << '>';
}
- --_pos;
+ --_pos; // TODO: ???
+ _printed = true;
}
void