|
|
@ -306,7 +306,7 @@ class MethodTrace { |
|
|
|
" <element>Hello</element>\n" |
|
|
|
" <element>Hello</element>\n" |
|
|
|
" </child>\n" |
|
|
|
" </child>\n" |
|
|
|
"</base>"); |
|
|
|
"</base>"); |
|
|
|
std::auto_ptr<xml::Node> file(test.read(ss)); |
|
|
|
std::unique_ptr<xml::Node> file(test.read(ss)); |
|
|
|
std::cout<<"The element is: " |
|
|
|
std::cout<<"The element is: " |
|
|
|
<<(*file)["child"]["element"] |
|
|
|
<<(*file)["child"]["element"] |
|
|
|
<<std::endl; |
|
|
|
<<std::endl; |
|
|
@ -432,7 +432,7 @@ class MethodTrace { |
|
|
|
.attr("id", xml::mandatory))))); |
|
|
|
.attr("id", xml::mandatory))))); |
|
|
|
[...] |
|
|
|
[...] |
|
|
|
try { |
|
|
|
try { |
|
|
|
std::auto_ptr<xml::Node> persons(test.read(std::ifstream("file.xml))); |
|
|
|
std::unique_ptr<xml::Node> persons(test.read(std::ifstream("file.xml))); |
|
|
|
// Here we can be sure, that our structure is valid,
|
|
|
|
// Here we can be sure, that our structure is valid,
|
|
|
|
// but we must check optional elements before access, otherwise
|
|
|
|
// but we must check optional elements before access, otherwise
|
|
|
|
// we get an exception.
|
|
|
|
// we get an exception.
|
|
|
@ -784,7 +784,7 @@ namespace xml { |
|
|
|
Node(const Node& o) throw(); |
|
|
|
Node(const Node& o) throw(); |
|
|
|
virtual ~Node() throw(); |
|
|
|
virtual ~Node() throw(); |
|
|
|
virtual Node& operator=(const Node& o) throw(); |
|
|
|
virtual Node& operator=(const Node& o) throw(); |
|
|
|
virtual std::auto_ptr<Node> clone() const throw(); |
|
|
|
virtual std::unique_ptr<Node> clone() const throw(); |
|
|
|
virtual std::ostream& out(std::ostream& o, unsigned int level=0) const |
|
|
|
virtual std::ostream& out(std::ostream& o, unsigned int level=0) const |
|
|
|
throw(); |
|
|
|
throw(); |
|
|
|
virtual std::string text() const throw(); |
|
|
|
virtual std::string text() const throw(); |
|
|
@ -836,7 +836,7 @@ namespace xml { |
|
|
|
Attributes _attributes; |
|
|
|
Attributes _attributes; |
|
|
|
private: |
|
|
|
private: |
|
|
|
Node* find(const std::string& child) const throw(); |
|
|
|
Node* find(const std::string& child) const throw(); |
|
|
|
virtual std::auto_ptr<Node> clone(Node* p) const throw(); |
|
|
|
virtual std::unique_ptr<Node> clone(Node* p) const throw(); |
|
|
|
Node(); // not implemented
|
|
|
|
Node(); // not implemented
|
|
|
|
Contents _contents; |
|
|
|
Contents _contents; |
|
|
|
std::string _name; |
|
|
|
std::string _name; |
|
|
@ -854,7 +854,7 @@ namespace xml { |
|
|
|
String(std::string name, const std::string& text, |
|
|
|
String(std::string name, const std::string& text, |
|
|
|
Node::size_type min=0, Node::size_type max=0) throw(); |
|
|
|
Node::size_type min=0, Node::size_type max=0) throw(); |
|
|
|
virtual ~String() throw() {} |
|
|
|
virtual ~String() throw() {} |
|
|
|
virtual std::auto_ptr<Node> clone() const throw(); |
|
|
|
virtual std::unique_ptr<Node> clone() const throw(); |
|
|
|
virtual std::string text() const throw(); |
|
|
|
virtual std::string text() const throw(); |
|
|
|
virtual String& text(const std::string& txt) throw(tag_expected, |
|
|
|
virtual String& text(const std::string& txt) throw(tag_expected, |
|
|
|
type_mismatch); |
|
|
|
type_mismatch); |
|
|
@ -885,7 +885,7 @@ namespace xml { |
|
|
|
public: |
|
|
|
public: |
|
|
|
UnsignedInteger(std::string name, unsigned long i=0, |
|
|
|
UnsignedInteger(std::string name, unsigned long i=0, |
|
|
|
size_type min=0, size_type max=0) throw(); |
|
|
|
size_type min=0, size_type max=0) throw(); |
|
|
|
virtual std::auto_ptr<Node> clone() const throw(); |
|
|
|
virtual std::unique_ptr<Node> clone() const throw(); |
|
|
|
virtual ~UnsignedInteger() throw() {} |
|
|
|
virtual ~UnsignedInteger() throw() {} |
|
|
|
virtual UnsignedInteger& text(const std::string& txt) |
|
|
|
virtual UnsignedInteger& text(const std::string& txt) |
|
|
|
throw(tag_expected, type_mismatch); |
|
|
|
throw(tag_expected, type_mismatch); |
|
|
@ -954,7 +954,7 @@ namespace xml { |
|
|
|
throw(factory_not_valid); |
|
|
|
throw(factory_not_valid); |
|
|
|
static std::ostream& print(std::ostream& os, const Node& node, |
|
|
|
static std::ostream& print(std::ostream& os, const Node& node, |
|
|
|
unsigned int level=0) throw(); |
|
|
|
unsigned int level=0) throw(); |
|
|
|
std::auto_ptr<Node> read(std::istream& is) |
|
|
|
std::unique_ptr<Node> read(std::istream& is) |
|
|
|
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch, |
|
|
|
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch, |
|
|
|
second_slash_in_tag, character_after_slash, |
|
|
|
second_slash_in_tag, character_after_slash, |
|
|
|
missing_end_tag, attribute_value_not_quoted, access_error, |
|
|
|
missing_end_tag, attribute_value_not_quoted, access_error, |
|
|
@ -972,7 +972,7 @@ namespace xml { |
|
|
|
Node& operator*() throw(factory_not_valid); |
|
|
|
Node& operator*() throw(factory_not_valid); |
|
|
|
Node*const operator->() throw(factory_not_valid); |
|
|
|
Node*const operator->() throw(factory_not_valid); |
|
|
|
bool ws(char c) throw(); |
|
|
|
bool ws(char c) throw(); |
|
|
|
std::auto_ptr<Node> read(std::istream& is, const Node& position) |
|
|
|
std::unique_ptr<Node> read(std::istream& is, const Node& position) |
|
|
|
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch, |
|
|
|
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch, |
|
|
|
second_slash_in_tag, character_after_slash, |
|
|
|
second_slash_in_tag, character_after_slash, |
|
|
|
missing_end_tag, |
|
|
|
missing_end_tag, |
|
|
@ -980,9 +980,9 @@ namespace xml { |
|
|
|
attributes_in_end_tag, |
|
|
|
attributes_in_end_tag, |
|
|
|
illegal_attribute, mandatory_attribute_missing, |
|
|
|
illegal_attribute, mandatory_attribute_missing, |
|
|
|
wrong_node_number); |
|
|
|
wrong_node_number); |
|
|
|
std::auto_ptr<Node> checkChildren(const xml::Node& tpl, |
|
|
|
std::unique_ptr<Node> checkChildren(const xml::Node& tpl, |
|
|
|
std::auto_ptr<Node> node, |
|
|
|
std::unique_ptr<Node> node, |
|
|
|
std::istream& is) const |
|
|
|
std::istream& is) const |
|
|
|
throw(wrong_node_number); |
|
|
|
throw(wrong_node_number); |
|
|
|
Tag tag(std::istream& is, const Node& position) |
|
|
|
Tag tag(std::istream& is, const Node& position) |
|
|
|
throw(second_slash_in_tag, wrong_start_tag, character_after_slash, |
|
|
|
throw(second_slash_in_tag, wrong_start_tag, character_after_slash, |
|
|
@ -1302,7 +1302,7 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
std::auto_ptr<xml::Node> node(factory.read(is)); |
|
|
|
std::unique_ptr<xml::Node> node(factory.read(is)); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
@ -1317,13 +1317,13 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
std::auto_ptr<xml::Node> tpl(node[0].clone()); |
|
|
|
std::unique_ptr<xml::Node> tpl(node[0].clone()); |
|
|
|
node.clear(); |
|
|
|
node.clear(); |
|
|
|
for (typename Container::const_iterator it = this->begin(); |
|
|
|
for (typename Container::const_iterator it = this->begin(); |
|
|
|
it!=this->end(); ++it) { |
|
|
|
it!=this->end(); ++it) { |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
tmp = *it; |
|
|
|
tmp = *it; |
|
|
|
std::auto_ptr<xml::Node> item(tpl->clone()); |
|
|
|
std::unique_ptr<xml::Node> item(tpl->clone()); |
|
|
|
Serialize::toNode(&tmp, *item); |
|
|
|
Serialize::toNode(&tmp, *item); |
|
|
|
node<<*item; |
|
|
|
node<<*item; |
|
|
|
} |
|
|
|
} |
|
|
@ -1366,7 +1366,7 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
std::auto_ptr<xml::Node> node(factory.read(is)); |
|
|
|
std::unique_ptr<xml::Node> node(factory.read(is)); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
@ -1381,13 +1381,13 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
std::auto_ptr<xml::Node> tpl(node[0].clone()); |
|
|
|
std::unique_ptr<xml::Node> tpl(node[0].clone()); |
|
|
|
node.clear(); |
|
|
|
node.clear(); |
|
|
|
for (typename CONTAINER_TYPE::const_iterator it = this->begin(); |
|
|
|
for (typename CONTAINER_TYPE::const_iterator it = this->begin(); |
|
|
|
it!=this->end(); ++it) { |
|
|
|
it!=this->end(); ++it) { |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
typename CONTAINER_TYPE::value_type tmp; |
|
|
|
tmp = *it; |
|
|
|
tmp = *it; |
|
|
|
std::auto_ptr<xml::Node> item(tpl->clone()); |
|
|
|
std::unique_ptr<xml::Node> item(tpl->clone()); |
|
|
|
Serialize::toNode(&tmp, *item); |
|
|
|
Serialize::toNode(&tmp, *item); |
|
|
|
node<<*item; |
|
|
|
node<<*item; |
|
|
|
} |
|
|
|
} |
|
|
@ -1433,7 +1433,7 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
xml::Factory factory(_xmlFactory); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
if (name.size()) factory->name(name); |
|
|
|
std::auto_ptr<xml::Node> node(factory.read(is)); |
|
|
|
std::unique_ptr<xml::Node> node(factory.read(is)); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
CONTAINER_TYPE::clear(); |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
for (xml::Node::size_type i(0); i<node->children(); ++i) { |
|
|
|
typename CONTAINER_TYPE::key_type key; |
|
|
|
typename CONTAINER_TYPE::key_type key; |
|
|
@ -1450,8 +1450,8 @@ namespace xml { |
|
|
|
checkInit(); |
|
|
|
checkInit(); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
xml::Node node(*_xmlFactory); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
if (name.size()) node.name(name); |
|
|
|
std::auto_ptr<xml::Node> tpl1(node[0].clone()); |
|
|
|
std::unique_ptr<xml::Node> tpl1(node[0].clone()); |
|
|
|
std::auto_ptr<xml::Node> tpl2(node[1].clone()); |
|
|
|
std::unique_ptr<xml::Node> tpl2(node[1].clone()); |
|
|
|
node.clear(); // "node" is now invalid
|
|
|
|
node.clear(); // "node" is now invalid
|
|
|
|
for (typename AssociativeMap::const_iterator it = this->begin(); |
|
|
|
for (typename AssociativeMap::const_iterator it = this->begin(); |
|
|
|
it!=this->end(); ++it) { |
|
|
|
it!=this->end(); ++it) { |
|
|
@ -1459,9 +1459,9 @@ namespace xml { |
|
|
|
typename CONTAINER_TYPE::mapped_type data; |
|
|
|
typename CONTAINER_TYPE::mapped_type data; |
|
|
|
key = it->first; |
|
|
|
key = it->first; |
|
|
|
data = it->second; |
|
|
|
data = it->second; |
|
|
|
std::auto_ptr<xml::Node> item1(tpl1->clone()); |
|
|
|
std::unique_ptr<xml::Node> item1(tpl1->clone()); |
|
|
|
Serialize::toNode(&key, *item1); |
|
|
|
Serialize::toNode(&key, *item1); |
|
|
|
std::auto_ptr<xml::Node> item2(tpl2->clone()); |
|
|
|
std::unique_ptr<xml::Node> item2(tpl2->clone()); |
|
|
|
Serialize::toNode(&data, *item2); |
|
|
|
Serialize::toNode(&data, *item2); |
|
|
|
node<<*item1<<*item2; |
|
|
|
node<<*item1<<*item2; |
|
|
|
} |
|
|
|
} |
|
|
|