diff --git a/examples/address.cxx b/examples/address.cxx
index 8911e1b..019035c 100644
--- a/examples/address.cxx
+++ b/examples/address.cxx
@@ -45,7 +45,7 @@ int main(int, char**) try {
http://swissign.com\
http://swissign.ch\
");
- std::auto_ptr author(addrTpl.read(ss));
+ std::unique_ptr author(addrTpl.read(ss));
// write to stdout
std::cout<<"Successfully read:"<Hello\n"
" \n"
"");
- std::auto_ptr file(test.read(ss));
+ std::unique_ptr file(test.read(ss));
std::cout<<"The text in element is: "
<<(*file)[xml::name::child][xml::name::element].text()
<Hello\n"
" \n"
"");
- std::auto_ptr file(test.read(ss));
+ std::unique_ptr file(test.read(ss));
std::cout<<"The element is: "
<<(*file)["child"]["element"]
< persons(test.read(std::ifstream("file.xml)));
+ std::unique_ptr persons(test.read(std::ifstream("file.xml)));
// Here we can be sure, that our structure is valid,
// but we must check optional elements before access, otherwise
// we get an exception.
@@ -784,7 +784,7 @@ namespace xml {
Node(const Node& o) throw();
virtual ~Node() throw();
virtual Node& operator=(const Node& o) throw();
- virtual std::auto_ptr clone() const throw();
+ virtual std::unique_ptr clone() const throw();
virtual std::ostream& out(std::ostream& o, unsigned int level=0) const
throw();
virtual std::string text() const throw();
@@ -836,7 +836,7 @@ namespace xml {
Attributes _attributes;
private:
Node* find(const std::string& child) const throw();
- virtual std::auto_ptr clone(Node* p) const throw();
+ virtual std::unique_ptr clone(Node* p) const throw();
Node(); // not implemented
Contents _contents;
std::string _name;
@@ -854,7 +854,7 @@ namespace xml {
String(std::string name, const std::string& text,
Node::size_type min=0, Node::size_type max=0) throw();
virtual ~String() throw() {}
- virtual std::auto_ptr clone() const throw();
+ virtual std::unique_ptr clone() const throw();
virtual std::string text() const throw();
virtual String& text(const std::string& txt) throw(tag_expected,
type_mismatch);
@@ -885,7 +885,7 @@ namespace xml {
public:
UnsignedInteger(std::string name, unsigned long i=0,
size_type min=0, size_type max=0) throw();
- virtual std::auto_ptr clone() const throw();
+ virtual std::unique_ptr clone() const throw();
virtual ~UnsignedInteger() throw() {}
virtual UnsignedInteger& text(const std::string& txt)
throw(tag_expected, type_mismatch);
@@ -954,7 +954,7 @@ namespace xml {
throw(factory_not_valid);
static std::ostream& print(std::ostream& os, const Node& node,
unsigned int level=0) throw();
- std::auto_ptr read(std::istream& is)
+ std::unique_ptr read(std::istream& is)
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch,
second_slash_in_tag, character_after_slash,
missing_end_tag, attribute_value_not_quoted, access_error,
@@ -972,7 +972,7 @@ namespace xml {
Node& operator*() throw(factory_not_valid);
Node*const operator->() throw(factory_not_valid);
bool ws(char c) throw();
- std::auto_ptr read(std::istream& is, const Node& position)
+ std::unique_ptr read(std::istream& is, const Node& position)
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch,
second_slash_in_tag, character_after_slash,
missing_end_tag,
@@ -980,9 +980,9 @@ namespace xml {
attributes_in_end_tag,
illegal_attribute, mandatory_attribute_missing,
wrong_node_number);
- std::auto_ptr checkChildren(const xml::Node& tpl,
- std::auto_ptr node,
- std::istream& is) const
+ std::unique_ptr checkChildren(const xml::Node& tpl,
+ std::unique_ptr node,
+ std::istream& is) const
throw(wrong_node_number);
Tag tag(std::istream& is, const Node& position)
throw(second_slash_in_tag, wrong_start_tag, character_after_slash,
@@ -1302,7 +1302,7 @@ namespace xml {
checkInit();
xml::Factory factory(_xmlFactory);
if (name.size()) factory->name(name);
- std::auto_ptr node(factory.read(is));
+ std::unique_ptr node(factory.read(is));
CONTAINER_TYPE::clear();
for (xml::Node::size_type i(0); ichildren(); ++i) {
typename CONTAINER_TYPE::value_type tmp;
@@ -1317,13 +1317,13 @@ namespace xml {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
- std::auto_ptr tpl(node[0].clone());
+ std::unique_ptr tpl(node[0].clone());
node.clear();
for (typename Container::const_iterator it = this->begin();
it!=this->end(); ++it) {
typename CONTAINER_TYPE::value_type tmp;
tmp = *it;
- std::auto_ptr item(tpl->clone());
+ std::unique_ptr item(tpl->clone());
Serialize::toNode(&tmp, *item);
node<<*item;
}
@@ -1366,7 +1366,7 @@ namespace xml {
checkInit();
xml::Factory factory(_xmlFactory);
if (name.size()) factory->name(name);
- std::auto_ptr node(factory.read(is));
+ std::unique_ptr node(factory.read(is));
CONTAINER_TYPE::clear();
for (xml::Node::size_type i(0); ichildren(); ++i) {
typename CONTAINER_TYPE::value_type tmp;
@@ -1381,13 +1381,13 @@ namespace xml {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
- std::auto_ptr tpl(node[0].clone());
+ std::unique_ptr tpl(node[0].clone());
node.clear();
for (typename CONTAINER_TYPE::const_iterator it = this->begin();
it!=this->end(); ++it) {
typename CONTAINER_TYPE::value_type tmp;
tmp = *it;
- std::auto_ptr item(tpl->clone());
+ std::unique_ptr item(tpl->clone());
Serialize::toNode(&tmp, *item);
node<<*item;
}
@@ -1433,7 +1433,7 @@ namespace xml {
checkInit();
xml::Factory factory(_xmlFactory);
if (name.size()) factory->name(name);
- std::auto_ptr node(factory.read(is));
+ std::unique_ptr node(factory.read(is));
CONTAINER_TYPE::clear();
for (xml::Node::size_type i(0); ichildren(); ++i) {
typename CONTAINER_TYPE::key_type key;
@@ -1450,8 +1450,8 @@ namespace xml {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
- std::auto_ptr tpl1(node[0].clone());
- std::auto_ptr tpl2(node[1].clone());
+ std::unique_ptr tpl1(node[0].clone());
+ std::unique_ptr tpl2(node[1].clone());
node.clear(); // "node" is now invalid
for (typename AssociativeMap::const_iterator it = this->begin();
it!=this->end(); ++it) {
@@ -1459,9 +1459,9 @@ namespace xml {
typename CONTAINER_TYPE::mapped_type data;
key = it->first;
data = it->second;
- std::auto_ptr item1(tpl1->clone());
+ std::unique_ptr item1(tpl1->clone());
Serialize::toNode(&key, *item1);
- std::auto_ptr item2(tpl2->clone());
+ std::unique_ptr item2(tpl2->clone());
Serialize::toNode(&data, *item2);
node<<*item1<<*item2;
}
diff --git a/src/xml.cxx b/src/xml.cxx
index 7528c6e..8ea3df8 100644
--- a/src/xml.cxx
+++ b/src/xml.cxx
@@ -272,8 +272,8 @@ namespace xml {
The user of this library doesn't have to and is not able to care
about the parenting. */
- std::auto_ptr Node::clone() const throw() {
- std::auto_ptr res(new Node(*this));
+ std::unique_ptr Node::clone() const throw() {
+ std::unique_ptr res(new Node(*this));
res->_parent = 0;
return res;
}
@@ -600,8 +600,8 @@ namespace xml {
return 0;
}
//! Clone a node, but assign a new parent.
- std::auto_ptr Node::clone(Node* p) const throw() {
- std::auto_ptr c(clone());
+ std::unique_ptr Node::clone(Node* p) const throw() {
+ std::unique_ptr c(clone());
c->_parent = p;
return c;
}
@@ -620,8 +620,8 @@ namespace xml {
Node::size_type min, Node::size_type max) throw():
Node(name, min, max), _text(text) {
}
- std::auto_ptr String::clone() const throw() {
- return std::auto_ptr(new String(*this));
+ std::unique_ptr String::clone() const throw() {
+ return std::unique_ptr(new String(*this));
}
std::string String::text() const throw() {
return _text;
@@ -740,8 +740,8 @@ namespace xml {
size_type min, size_type max) throw():
String(name, mrw::string(i), min, max) {
}
- std::auto_ptr UnsignedInteger::clone() const throw() {
- return std::auto_ptr(new UnsignedInteger(*this));
+ std::unique_ptr UnsignedInteger::clone() const throw() {
+ return std::unique_ptr(new UnsignedInteger(*this));
}
//! An xml::UnsignedInteger must only contain an number.
/*! En exception is thrown, if the contents does not match a number. */
@@ -876,7 +876,7 @@ namespace xml {
return os;
}
//! Restore a xml::Node tree from a stream, according to the given schema.
- std::auto_ptr Factory::read(std::istream& is)
+ std::unique_ptr Factory::read(std::istream& is)
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch,
second_slash_in_tag,
character_after_slash, missing_end_tag, attribute_value_not_quoted,
@@ -888,7 +888,7 @@ namespace xml {
try {
_line=1;
_open=0;
- std::auto_ptr node(read(is, _template));
+ std::unique_ptr node(read(is, _template));
if (node->children()==0)
throw tag_expected(_template[0],
"nothing found, possibly empty stream");
@@ -919,14 +919,14 @@ namespace xml {
last = c;
return c==' '||c=='\t'||c=='\n'||c=='\r';
}
- std::auto_ptr Factory::read(std::istream& is, const Node& node)
+ std::unique_ptr Factory::read(std::istream& is, const Node& node)
throw(wrong_end_tag, wrong_start_tag, tag_expected, type_mismatch,
second_slash_in_tag,
character_after_slash, missing_end_tag, attribute_value_not_quoted,
access_error, duplicate_attribute, attributes_in_end_tag,
illegal_attribute, mandatory_attribute_missing,
wrong_node_number) {
- std::auto_ptr result(node.clone());
+ std::unique_ptr result(node.clone());
result->clear();
while (true) {
Tag res(tag(is, node));
@@ -939,9 +939,9 @@ namespace xml {
if (res.name!=node.name()) throw wrong_end_tag(node, is, res);
} return result;
case EMPTY: {
- std::auto_ptr current(node[res.name].clone());
+ std::unique_ptr current(node[res.name].clone());
current->clear()< Factory::checkChildren(const xml::Node& tpl,
- std::auto_ptr node,
- std::istream& is) const
+ std::unique_ptr Factory::checkChildren(const xml::Node& tpl,
+ std::unique_ptr node,
+ std::istream& is) const
throw(wrong_node_number) {
for (Node::size_type i(0); i0 && node->list(tpl[i].name()).size()name(name);
- std::auto_ptr node(factory.read(is));
+ std::unique_ptr node(factory.read(is));
for (std::map::const_iterator
it(_xmlNames.begin());
it!=_xmlNames.end(); ++it)
diff --git a/test/xml_test.cxx b/test/xml_test.cxx
index c841812..a638acb 100644
--- a/test/xml_test.cxx
+++ b/test/xml_test.cxx
@@ -22,7 +22,7 @@ class NodeTest: public CppUnit::TestFixture {
}
void clone() {
xml::Node t("test");
- std::auto_ptr p(t.clone());
+ std::unique_ptr p(t.clone());
CPPUNIT_ASSERT_EQUAL(std::string("test"), p->name());
}
void shift() {
@@ -100,7 +100,7 @@ class StringTest: public CppUnit::TestFixture {
}
void clone() {
xml::String t("test");
- std::auto_ptr p(t.clone());
+ std::unique_ptr p(t.clone());
CPPUNIT_ASSERT_EQUAL(std::string("test"), p->name());
}
void shift() {
@@ -181,7 +181,7 @@ class ComplexTest: public CppUnit::TestFixture {
<<""
<<"< otherchild >< / otherchild >< otherchild / >"<";
- std::auto_ptr node(factory.read(file1)); // should work
+ std::unique_ptr node(factory.read(file1)); // should work
CPPUNIT_ASSERT_EQUAL((size_t)2, node->list("child").size());
CPPUNIT_ASSERT_EQUAL((size_t)3, (*node)[0].list("childofchild").size());
CPPUNIT_ASSERT_EQUAL((size_t)4, (*node)[0].list("number").size());
@@ -354,7 +354,7 @@ class FunTest: public CppUnit::TestFixture {
< read(factory.read(ss)); // read back the example
+ std::unique_ptr read(factory.read(ss)); // read back the example
std::stringstream ss2;
read->out(ss2);
CPPUNIT_ASSERT_EQUAL(contents, ss2.str());