fix for C++17, requires at least C+17

This commit is contained in:
Marc Wäckerlin
2018-11-21 22:23:14 +00:00
parent 99b12cb4d9
commit b7b5c2d3ff
11 changed files with 1761 additions and 619 deletions

View File

@@ -23,26 +23,27 @@
#include <cassert>
#include <iostream>
#include <iomanip>
class MethodTrace {
public:
MethodTrace(const void* addr, const std::string& name) throw():
_addr(addr), _name(name) {
std::clog<<std::hex<<std::setw(15)<<_addr<<": "
<<std::dec<<std::setw(2+_level)
<<std::setfill(' ')<<"\\ "<<_name<<std::endl;
++_level;
}
~MethodTrace() throw() {
namespace xml {
class MethodTrace {
public:
MethodTrace(const void* addr, const std::string& name) noexcept:
_addr(addr), _name(name) {
std::clog<<std::hex<<std::setw(15)<<_addr<<": "
<<std::dec<<std::setw(2+_level)
<<std::setfill(' ')<<"\\ "<<_name<<std::endl;
++_level;
}
~MethodTrace() noexcept {
--_level;
std::clog<<std::hex<<std::setw(15)<<_addr<<": "<<std::dec
<<std::setw(2+_level)<<std::setfill(' ')
<<"/ "<<_name<<std::endl;
}
private:
const void* _addr;
const std::string _name;
static unsigned int _level;
};
}
private:
const void* _addr;
const std::string _name;
static unsigned int _level;
};
#define TRACE MethodTrace XXX_METHOD(this, __PRETTY_FUNCTION__)
#define LOG(X) std::clog<<__PRETTY_FUNCTION__<<"\t**** "<<X<<std::endl
#define ASSERT(X, Y) { \
@@ -50,8 +51,9 @@ class MethodTrace {
LOG(X); \
} \
assert(Y); \
}
//! @endcond
}
//! @endcond
/*! @mainpage
@@ -495,11 +497,11 @@ namespace xml {
//----------------------------------------------------------------------------
class exception: public std::exception {
public:
exception(std::string reason) throw();
exception(std::string reason, const Node& t) throw();
~exception() throw();
void line(unsigned long line) throw();
const char* what() const throw();
exception(std::string reason) noexcept;
exception(std::string reason, const Node& t) noexcept;
~exception() noexcept;
void line(unsigned long line) noexcept;
const char* what() const noexcept;
private:
std::string _what;
Node* _node;
@@ -518,7 +520,7 @@ namespace xml {
//----------------------------------------------------------------------------
class empty_attribute_list: public exception {
public:
empty_attribute_list(const std::string& name) throw():
empty_attribute_list(const std::string& name) noexcept:
exception("list of attribute is empty access to first element failed"
"\nattribute: "+name) {
}
@@ -526,60 +528,60 @@ namespace xml {
//----------------------------------------------------------------------------
class factory_not_valid: public exception {
public:
factory_not_valid() throw():
factory_not_valid() noexcept:
exception("a factory must be given a template node") {
}
};
//----------------------------------------------------------------------------
class no_parent: public exception {
public:
no_parent(const Node& t) throw(): exception("node has no parent", t) {}
no_parent(const Node& t) noexcept: exception("node has no parent", t) {}
};
//----------------------------------------------------------------------------
class tag_expected: public exception {
public:
tag_expected(const Node& t, const std::string& txt) throw():
tag_expected(const Node& t, const std::string& txt) noexcept:
exception("tag ('<') expected, text not allowed\ntext: "+txt, t) {}
};
//----------------------------------------------------------------------------
class type_mismatch: public exception {
public:
type_mismatch(const Node& t, const std::string& txt,
const std::string& comment) throw():
const std::string& comment) noexcept:
exception("wrong type, text contains mismatching character\n"+comment
+"\ntext: "+txt, t) {}
};
//----------------------------------------------------------------------------
class access_error: public exception {
public:
access_error(const Node& t, const std::string& name) throw();
~access_error() throw() {}
const char* what() const throw();
access_error(const Node& t, const std::string& name) noexcept;
~access_error() noexcept {}
const char* what() const noexcept;
private:
std::string _name;
};
//----------------------------------------------------------------------------
class out_of_range: public exception {
public:
out_of_range(const Node& t, size_t pos) throw();
~out_of_range() throw() {}
const char* what() const throw();
out_of_range(const Node& t, size_t pos) noexcept;
~out_of_range() noexcept {}
const char* what() const noexcept;
private:
size_t _pos;
};
//----------------------------------------------------------------------------
class cannot_have_children: public exception {
public:
cannot_have_children(const Node& parent, const Node& child) throw();
~cannot_have_children() throw();
const char* what() const throw();
cannot_have_children(const Node& parent, const Node& child) noexcept;
~cannot_have_children() noexcept;
const char* what() const noexcept;
private:
Node* _child;
};
//----------------------------------------------------------------------------
class attribute_not_available: public exception {
public:
attribute_not_available(const Node& t, const std::string& attr) throw():
attribute_not_available(const Node& t, const std::string& attr) noexcept:
exception("attribute \""+attr+"\" not set", t) {
}
};
@@ -587,11 +589,11 @@ namespace xml {
class stream_error: public exception {
public:
stream_error(const std::string& reason, const Node& t,
std::istream& is, const Tag& tag, char c=0) throw();
std::istream& is, const Tag& tag, char c=0) noexcept;
stream_error(const std::string& reason, const Node& t,
std::istream& is) throw();
~stream_error() throw();
const char* what() const throw();
std::istream& is) noexcept;
~stream_error() noexcept;
const char* what() const noexcept;
private:
std::istream::streampos _pos;
Tag* _tag;
@@ -601,7 +603,7 @@ namespace xml {
class wrong_end_tag: public stream_error {
public:
wrong_end_tag(const Node& t, std::istream& is, const Tag& tag, char c=0)
throw():
noexcept:
stream_error("mismatching end tag", t, is, tag, c) {
}
};
@@ -609,7 +611,7 @@ namespace xml {
class missing_end_tag: public stream_error {
public:
missing_end_tag(const Node& t, std::istream& is, const Tag& tag, char c=0)
throw():
noexcept:
stream_error("missing end tag, end of file reached", t, is, tag, c) {
}
};
@@ -617,7 +619,7 @@ namespace xml {
class wrong_start_tag: public stream_error {
public:
wrong_start_tag(const Node& t, std::istream& is, const Tag& tag, char c=0)
throw():
noexcept:
stream_error("start tag does not match expected tag", t, is, tag, c) {
}
};
@@ -626,7 +628,7 @@ namespace xml {
public:
second_slash_in_tag(const Node& t, std::istream& is, const Tag& tag,
char c=0)
throw():
noexcept:
stream_error("a tag may have no more than one slash", t, is, tag, c) {
}
};
@@ -635,7 +637,7 @@ namespace xml {
public:
character_after_slash(const Node& t, std::istream& is, const Tag& tag,
char c=0)
throw():
noexcept:
stream_error("unexpected character after empty-slash",
t, is, tag, c) {
}
@@ -644,7 +646,7 @@ namespace xml {
class attributes_in_end_tag: public stream_error {
public:
attributes_in_end_tag(const Node& t, std::istream& is, const Tag& tag)
throw():
noexcept:
stream_error("attributes are not allowed in end tags",t, is, tag) {
}
};
@@ -653,7 +655,7 @@ namespace xml {
public:
attribute_value_not_quoted(const Node& t, std::istream& is,
const Tag& tag,
char c, std::string attr) throw():
char c, std::string attr) noexcept:
stream_error("attribute values must be quoted (\")\nattribute: "+attr,
t, is, tag, c) {
}
@@ -662,7 +664,7 @@ namespace xml {
class duplicate_attribute: public stream_error {
public:
duplicate_attribute(const Node& t, std::istream& is, const Tag& tag,
std::string attr) throw():
std::string attr) noexcept:
stream_error("attribute duplicated\nattribute: "+attr,
t, is, tag, 0) {
}
@@ -671,7 +673,7 @@ namespace xml {
class illegal_attribute: public stream_error {
public:
illegal_attribute(const Node& t, std::istream& is, const Tag& tag,
std::string attr) throw():
std::string attr) noexcept:
stream_error("illegal attribute found\nattribute: "+attr,
t, is, tag, 0) {
}
@@ -680,7 +682,7 @@ namespace xml {
class mandatory_attribute_missing: public stream_error {
public:
mandatory_attribute_missing(const Node& t, std::istream& is,
const Tag& tag, std::string attr) throw():
const Tag& tag, std::string attr) noexcept:
stream_error("mandatory attribute missing\nattribute: "+attr,
t, is, tag, 0) {
}
@@ -691,14 +693,14 @@ namespace xml {
wrong_node_number(const Node& t, std::istream& is,
const std::string& name,
unsigned long num,
unsigned long min, unsigned long max) throw():
unsigned long min, unsigned long max) noexcept:
stream_error("wrong number of child nodes\nname of child: "+name
+"\nnumber of nodes: "+conv(num)
+"\nminimuml number: "+conv(min)
+"\nmaximum number: "+conv(max), t, is) {
}
private:
static std::string conv(unsigned long i) throw() {
static std::string conv(unsigned long i) noexcept {
std::stringstream ss;
ss<<i;
return ss.str();
@@ -730,29 +732,28 @@ namespace xml {
@note Simply use xml::Attr instead of xml::Attributes::Value. */
class Value: public value_type {
public:
Value(const value_type& o) throw();
Value(const std::string& name) throw();
Value(const std::string& name, const std::string& namevalue) throw();
Value& operator=(const std::string& value) throw();
const std::string& name() const throw();
const std::string& value() const throw();
std::string& value() throw();
operator bool() const throw();
bool toBool() const throw();
operator unsigned long() const throw();
unsigned long toNumber() const throw();
operator List() const throw();
List toList(const std::string& separators=" \t\n\r") const throw();
std::string front(const std::string& separators=" \t\n\r") const
throw(empty_attribute_list);
Value(const value_type& o) noexcept;
Value(const std::string& name) noexcept;
Value(const std::string& name, const std::string& namevalue) noexcept;
Value& operator=(const std::string& value) noexcept;
const std::string& name() const noexcept;
const std::string& value() const noexcept;
std::string& value() noexcept;
operator bool() const noexcept;
bool toBool() const noexcept;
operator unsigned long() const noexcept;
unsigned long toNumber() const noexcept;
operator List() const noexcept;
List toList(const std::string& separators=" \t\n\r") const noexcept;
std::string front(const std::string& separators=" \t\n\r") const;
private:
Value(); // not implemented, key must always be given
};
Attributes() throw();
Attributes(const std::string& empty) throw();
Attributes(const std::string& key, const std::string& value) throw();
Attributes& operator<<(const Value& v) throw();
Attributes& operator<<(const std::string& key) throw();
Attributes() noexcept;
Attributes(const std::string& empty) noexcept;
Attributes(const std::string& key, const std::string& value) noexcept;
Attributes& operator<<(const Value& v) noexcept;
Attributes& operator<<(const std::string& key) noexcept;
};
//! Simplification: Use xml::Attr instead of xml::Attributes::Value.
typedef Attributes::Value Attr;
@@ -780,63 +781,59 @@ namespace xml {
public:
typedef Contents::size_type size_type;
typedef std::vector<Node*> List;
Node(std::string name, size_type min=0, size_type max=0) throw();
Node(const Node& o) throw();
virtual ~Node() throw();
virtual Node& operator=(const Node& o) throw();
virtual std::unique_ptr<Node> clone() const throw();
Node(std::string name, size_type min=0, size_type max=0) noexcept;
Node(const Node& o) noexcept;
virtual ~Node() noexcept;
virtual Node& operator=(const Node& o) noexcept;
virtual std::unique_ptr<Node> clone() const noexcept;
virtual std::ostream& out(std::ostream& o, unsigned int level=0) const
throw();
virtual std::string text() const throw();
virtual Node& text(const std::string& txt) throw(tag_expected,
type_mismatch);
virtual Node& append(const Node& o) throw(cannot_have_children);
virtual Node& remove(Node& n) throw(access_error);
virtual Node& remove(const std::string& n) throw(access_error);
virtual Node& remove(size_type n) throw(out_of_range);
virtual Node& set(const Attributes& o) throw();
noexcept;
virtual std::string text() const noexcept;
virtual Node& text(const std::string& txt);
virtual Node& append(const Node& o);
virtual Node& remove(Node& n);
virtual Node& remove(const std::string& n);
virtual Node& remove(size_type n);
virtual Node& set(const Attributes& o) noexcept;
Node& clear() throw ();
std::string name() const throw();
Node& name(const std::string& n) throw();
Node& min(size_type m) throw();
size_type min() const throw();
Node& max(size_type m) throw();
size_type max() const throw();
bool isChild() const throw();
Node& parent() const throw(no_parent);
bool hasAttr(const std::string& name) const throw();
Node& attr(const std::string& name, bool mandatory) throw();
Node& attr(const std::string& name, const std::string& deflt) throw();
std::string attr(const std::string& name) const throw();
std::string& attr(const std::string& name) throw();
const Attributes::Value attribute(const std::string& name)
const throw(attribute_not_available);
const Attributes& attributes() const throw();
Attributes& attributes() throw();
const Node& first() const throw(out_of_range);
Node& first() throw(out_of_range);
const Node& last() const throw(out_of_range);
Node& last() throw(out_of_range);
Node& limits(size_type min=0, size_type max=0) throw();
List list(const std::string& name) const throw();
bool operator()(const std::string& child) const throw();
Node& operator<<(const Node& o) throw(cannot_have_children);
Node& operator<<(const Attributes& o) throw();
size_type children() const throw();
const Node& operator[](size_type child) const throw(out_of_range);
Node& operator[](size_type child) throw(out_of_range);
const Node& operator[](const std::string& child) const
throw(access_error);
Node& operator[](const std::string& child) throw(access_error);
std::string operator*() const throw();
Node& operator=(const std::string& contents) throw(tag_expected,
type_mismatch);
friend std::ostream& operator<<(std::ostream& o, const Node& t) throw();
std::string name() const noexcept;
Node& name(const std::string& n) noexcept;
Node& min(size_type m) noexcept;
size_type min() const noexcept;
Node& max(size_type m) noexcept;
size_type max() const noexcept;
bool isChild() const noexcept;
Node& parent() const;
bool hasAttr(const std::string& name) const noexcept;
Node& attr(const std::string& name, bool mandatory) noexcept;
Node& attr(const std::string& name, const std::string& deflt) noexcept;
std::string attr(const std::string& name) const noexcept;
std::string& attr(const std::string& name) noexcept;
const Attributes::Value attribute(const std::string& name) const;
const Attributes& attributes() const noexcept;
Attributes& attributes() noexcept;
const Node& first() const;
Node& first();
const Node& last() const;
Node& last();
Node& limits(size_type min=0, size_type max=0) noexcept;
List list(const std::string& name) const noexcept;
bool operator()(const std::string& child) const noexcept;
Node& operator<<(const Node& o);
Node& operator<<(const Attributes& o) noexcept;
size_type children() const noexcept;
const Node& operator[](size_type child) const;
Node& operator[](size_type child);
const Node& operator[](const std::string& child) const;
Node& operator[](const std::string& child);
std::string operator*() const noexcept;
Node& operator=(const std::string& contents);
friend std::ostream& operator<<(std::ostream& o, const Node& t) noexcept;
protected:
Attributes _attributes;
private:
Node* find(const std::string& child) const throw();
virtual std::unique_ptr<Node> clone(Node* p) const throw();
Node* find(const std::string& child) const noexcept;
virtual std::unique_ptr<Node> clone(Node* p) const noexcept;
Node(); // not implemented
Contents _contents;
std::string _name;
@@ -850,31 +847,30 @@ namespace xml {
class String: public Node {
public:
String(std::string name,
Node::size_type min=0, Node::size_type max=0) throw();
Node::size_type min=0, Node::size_type max=0) noexcept;
String(std::string name, const std::string& text,
Node::size_type min=0, Node::size_type max=0) throw();
virtual ~String() throw() {}
virtual std::unique_ptr<Node> clone() const throw();
virtual std::string text() const throw();
virtual String& text(const std::string& txt) throw(tag_expected,
type_mismatch);
Node::size_type min=0, Node::size_type max=0) noexcept;
virtual ~String() noexcept {}
virtual std::unique_ptr<Node> clone() const noexcept;
virtual std::string text() const noexcept;
virtual String& text(const std::string& txt);
virtual std::ostream& out(std::ostream& o, unsigned int level=0) const
throw();
virtual String& append(const Node& o) throw(cannot_have_children);
Node& operator=(const std::string& contents) throw();
operator std::string() const throw();
operator bool() const throw();
operator char() const throw();
operator signed char() const throw();
operator unsigned char() const throw();
operator signed short() const throw();
operator unsigned short() const throw();
operator signed int() const throw();
operator unsigned int() const throw();
operator signed long() const throw();
operator unsigned long() const throw();
operator float() const throw();
operator double() const throw();
noexcept;
virtual String& append(const Node& o);
Node& operator=(const std::string& contents) noexcept;
operator std::string() const noexcept;
operator bool() const noexcept;
operator char() const noexcept;
operator signed char() const noexcept;
operator unsigned char() const noexcept;
operator signed short() const noexcept;
operator unsigned short() const noexcept;
operator signed int() const noexcept;
operator unsigned int() const noexcept;
operator signed long() const noexcept;
operator unsigned long() const noexcept;
operator float() const noexcept;
operator double() const noexcept;
protected:
std::string _text;
};
@@ -884,13 +880,12 @@ namespace xml {
class UnsignedInteger: public String {
public:
UnsignedInteger(std::string name, unsigned long i=0,
size_type min=0, size_type max=0) throw();
virtual std::unique_ptr<Node> clone() const throw();
virtual ~UnsignedInteger() throw() {}
virtual UnsignedInteger& text(const std::string& txt)
throw(tag_expected, type_mismatch);
unsigned long number() const throw();
static unsigned long number(const Node& node) throw();
size_type min=0, size_type max=0) noexcept;
virtual std::unique_ptr<Node> clone() const noexcept;
virtual ~UnsignedInteger() noexcept {}
virtual UnsignedInteger& text(const std::string& txt);
unsigned long number() const noexcept;
static unsigned long number(const Node& node) noexcept;
};
//----------------------------------------------------------------------------
@@ -942,26 +937,19 @@ namespace xml {
@endverbatim */
class Factory {
public:
Factory(const Node& t) throw();
Factory() throw();
Factory& operator=(const Node& t) throw();
Factory& append(const Node& node) throw();
const Node& operator*() const throw(factory_not_valid);
const Node*const operator->() const throw(factory_not_valid);
operator bool() const throw();
Factory(const Node& t) noexcept;
Factory() noexcept;
Factory& operator=(const Node& t) noexcept;
Factory& append(const Node& node) noexcept;
const Node& operator*() const;
const Node* operator->() const;
operator bool() const noexcept;
friend std::ostream& operator<<(std::ostream& os,
const Factory& factory)
throw(factory_not_valid);
const Factory& factory);
static std::ostream& print(std::ostream& os, const Node& node,
unsigned int level=0) throw();
std::unique_ptr<Node> 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,
duplicate_attribute, attributes_in_end_tag,
illegal_attribute, mandatory_attribute_missing,
wrong_node_number, factory_not_valid);
void reset() throw();
unsigned int level=0) noexcept;
std::unique_ptr<Node> read(std::istream& is);
void reset() noexcept;
private:
friend class stream_error;
friend class Serialize;
@@ -969,33 +957,21 @@ namespace xml {
template<class T> friend class Container;
template<class T> friend class AssociativeContainer;
template<class T> friend class AssociativeMap;
Node& operator*() throw(factory_not_valid);
Node*const operator->() throw(factory_not_valid);
bool ws(char c) throw();
std::unique_ptr<Node> 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,
attribute_value_not_quoted, access_error, duplicate_attribute,
attributes_in_end_tag,
illegal_attribute, mandatory_attribute_missing,
wrong_node_number);
Node& operator*();
Node* operator->();
bool ws(char c) noexcept;
std::unique_ptr<Node> read(std::istream& is, const Node& position);
std::unique_ptr<Node> checkChildren(const xml::Node& tpl,
std::unique_ptr<Node> 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,
missing_end_tag, attributes_in_end_tag, tag_expected,
attribute_value_not_quoted, access_error, duplicate_attribute,
illegal_attribute, mandatory_attribute_missing);
std::istream& is) const;
Tag tag(std::istream& is, const Node& position);
Node _template;
unsigned long _line;
long _open;
};
//@}
/*! @defgroup serialization Class Serialization
/*! @defgroup groupserialization Class Serialization
@section serIntro Introduction
@@ -1096,7 +1072,7 @@ namespace xml {
- ... the child does not inherit xml::Serialize, but a child of it
- ... the child must first call xml::Serialize::initXmlMembers of
the parent in it's own xml::Serialize::initXmlMembers */
//! @addtogroup serialization
//! @addtogroup groupserialization
//@{
class Serialize {
@@ -1105,50 +1081,50 @@ namespace xml {
typedef bool(*ToNodeFunc)(const Any, xml::Node&);
typedef bool(*ClearFunc)(Any);
//! You must call Serialize::className() if you use this constructor!
Serialize() throw();
Serialize(const std::string& className) throw();
Serialize(const Serialize& other) throw();
Serialize() noexcept;
Serialize(const std::string& className) noexcept;
Serialize(const Serialize& other) noexcept;
virtual ~Serialize();
Serialize& operator=(const Serialize& other) throw();
virtual Serialize& className(const std::string& name) throw();
Serialize& operator=(const Serialize& other) noexcept;
virtual Serialize& className(const std::string& name) noexcept;
Serialize& persist(Serialize& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(bool& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(char& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(unsigned char& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(signed char& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(unsigned short& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(signed short& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(unsigned int& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(signed int& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(unsigned long& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(signed long& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(float& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(double& member,
const std::string& name) throw();
const std::string& name) noexcept;
Serialize& persist(std::string& member,
const std::string& name) throw();
const std::string& name) noexcept;
virtual std::ostream& saveXml(std::ostream& os,
const std::string& name = std::string())
const throw();
const noexcept;
virtual std::istream& loadXml(std::istream& is,
const std::string& name = std::string());
std::string schema() const throw();
std::string schema() const noexcept;
static void registerFromNode(FromNodeFunc fromNodeFunc);
static void registerToNode(ToNodeFunc toNodeFunc);
static void registerClear(ClearFunc clearFunc);
virtual void clear() throw();
virtual void clear();
protected:
virtual void initXmlMembers();
void checkInit(const Serialize* const ser=0) const {
@@ -1166,13 +1142,13 @@ namespace xml {
const xml::Node& node);
template<typename TYPE> friend bool assigntoNode(Any member,
const xml::Node& node);
virtual bool optional() const throw();
void clear(Any member) throw();
void reset() throw();
void copy(const Serialize& o) throw();
virtual bool optional() const noexcept;
void clear(Any member);
void reset() noexcept;
void copy(const Serialize& o) noexcept;
template<typename TYPE>
Serialize& persistSimpleType(TYPE& member,
const std::string& name) throw() {
const std::string& name) noexcept {
_xmlNames[name] = &member;
xml::Node schema(*_xmlFactory);
schema<<xml::String(name).limits(1,1);
@@ -1191,43 +1167,43 @@ namespace xml {
template <class TYPE> class Optional: public Serialize {
public:
Optional() throw(): _valid(false) {}
Optional(const Optional& o) throw():
Optional() noexcept: _valid(false) {}
Optional(const Optional& o) noexcept:
_member(o._member), _valid(o.valid) {
}
Optional(const TYPE& mem) throw():
Optional(const TYPE& mem) noexcept:
_member(mem), _valid(true) {
}
virtual ~Optional() throw() {}
Optional& operator=(const Optional& o) throw() {
virtual ~Optional() noexcept {}
Optional& operator=(const Optional& o) noexcept {
_member = o._member;
_valid = o._valid;
return *this;
}
Optional& operator=(const TYPE& mem) throw() {
Optional& operator=(const TYPE& mem) noexcept {
_member = mem;
_valid = true;
return *this;
}
operator bool() const throw() {
operator bool() const noexcept {
return _valid;
}
const TYPE& operator*() const throw() {
const TYPE& operator*() const noexcept {
return _member;
}
TYPE& operator*() throw() {
TYPE& operator*() noexcept {
return _member;
}
const TYPE*const operator->() const throw() {
const TYPE* operator->() const noexcept {
return &_member;
}
TYPE*const operator->() throw() {
TYPE* operator->() noexcept {
return &_member;
}
virtual void clear() throw() {
virtual void clear() noexcept {
_valid = false;
}
virtual Optional& className(const std::string& name) throw() {
virtual Optional& className(const std::string& name) noexcept {
if (!_xmlFactory) {
Serialize::className(name);
persist(_member, name);
@@ -1238,7 +1214,7 @@ namespace xml {
return *this;
}
protected:
virtual bool optional() const throw() {
virtual bool optional() const noexcept {
return true;
}
virtual void fromNode(Any member, const xml::Node& node) {
@@ -1258,7 +1234,7 @@ namespace xml {
bool _valid;
};
//! @addtogroup serialization
//! @addtogroup groupserialization
//@{
/*! @defgroup serContainer Serialization of Container
@@ -1295,7 +1271,7 @@ namespace xml {
public:
Container() {}
Container(const Container& o): CONTAINER_TYPE(o), Serialize(o) {}
Container(const std::string& className) throw(): Serialize(className) {}
Container(const std::string& className) noexcept: Serialize(className) {}
virtual ~Container() {}
virtual std::istream& loadXml(std::istream& is,
const std::string& name = std::string()) {
@@ -1313,7 +1289,7 @@ namespace xml {
}
virtual std::ostream& saveXml(std::ostream& os,
const std::string& name = std::string())
const throw() {
const noexcept {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
@@ -1344,7 +1320,7 @@ namespace xml {
persist(tmp, itemName); // add as child of dummyroot
(*_xmlFactory)[0].limits(0, 0); // any number of children possible
}
virtual void clear() throw() {
virtual void clear() noexcept {
CONTAINER_TYPE::clear();
}
};
@@ -1357,7 +1333,7 @@ namespace xml {
AssociativeContainer(const AssociativeContainer& o):
CONTAINER_TYPE(o), Serialize(o) {
}
AssociativeContainer(const std::string& className) throw():
AssociativeContainer(const std::string& className) noexcept:
Serialize(className) {
}
virtual ~AssociativeContainer() {}
@@ -1377,7 +1353,7 @@ namespace xml {
}
virtual std::ostream& saveXml(std::ostream& os,
const std::string& name = std::string())
const throw() {
const noexcept {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
@@ -1411,7 +1387,7 @@ namespace xml {
persist(tmp, itemName); // add as child of dummyroot
(*_xmlFactory)[0].limits(0, 0); // any number of children possible
}
virtual void clear() throw() {
virtual void clear() noexcept {
CONTAINER_TYPE::clear();
}
};
@@ -1424,7 +1400,7 @@ namespace xml {
AssociativeMap(const AssociativeMap& o):
CONTAINER_TYPE(o), Serialize(o) {
}
AssociativeMap(const std::string& className) throw():
AssociativeMap(const std::string& className) noexcept:
Serialize(className) {
}
virtual ~AssociativeMap() {}
@@ -1446,7 +1422,7 @@ namespace xml {
}
virtual std::ostream& saveXml(std::ostream& os,
const std::string& name = std::string())
const throw() {
const noexcept {
checkInit();
xml::Node node(*_xmlFactory);
if (name.size()) node.name(name);
@@ -1492,7 +1468,7 @@ namespace xml {
(*_xmlFactory)[0].limits(0, 0); // any number of children possible
(*_xmlFactory)[1].limits(0, 0); // any number of children possible
}
virtual void clear() throw() {
virtual void clear() noexcept {
CONTAINER_TYPE::clear();
}
};
@@ -1516,18 +1492,18 @@ namespace xml {
CONTAINER(const CONTAINER& o): \
Container<STD_CONTAINER<TYPE, ALLOC> >(o) { \
} \
CONTAINER(const std::string& className) throw(): \
CONTAINER(const std::string& className) noexcept: \
Container<STD_CONTAINER<TYPE, ALLOC> >(className) { \
} \
virtual ~CONTAINER() {} \
}; \
}
# include <list>
__XML_CXX_DECLARE_CONTAINER_CLASS__(List, std::list);
__XML_CXX_DECLARE_CONTAINER_CLASS__(List, std::list)
# include <vector>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Vector, std::vector);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Vector, std::vector)
# include <deque>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Deque, std::deque);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Deque, std::deque)
# undef __XML_CXX_DECLARE_CONTAINER_CLASS__
# define __XML_CXX_DECLARE_CONTAINER_CLASS__(CONTAINER, STD_CONTAINER) \
namespace xml { \
@@ -1541,7 +1517,7 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(Deque, std::deque);
AssociativeContainer \
<STD_CONTAINER<TYPE, CONT> >(o) { \
} \
CONTAINER(const std::string& className) throw(): \
CONTAINER(const std::string& className) noexcept: \
AssociativeContainer \
<STD_CONTAINER<TYPE, CONT> > \
(className) { \
@@ -1550,9 +1526,9 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(Deque, std::deque);
}; \
}
# include <stack>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Stack, std::stack);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Stack, std::stack)
# include <queue>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Queue, std::queue);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Queue, std::queue)
# undef __XML_CXX_DECLARE_CONTAINER_CLASS__
# define __XML_CXX_DECLARE_CONTAINER_CLASS__(CONTAINER, STD_CONTAINER) \
namespace xml { \
@@ -1569,7 +1545,7 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(Queue, std::queue);
AssociativeContainer \
<STD_CONTAINER<TYPE, COMPARE, ALLOC> >(o) { \
} \
CONTAINER(const std::string& className) throw(): \
CONTAINER(const std::string& className) noexcept: \
AssociativeContainer \
<STD_CONTAINER<TYPE, COMPARE, ALLOC> > \
(className) { \
@@ -1577,7 +1553,7 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(Queue, std::queue);
virtual ~CONTAINER() {} \
}; \
}
__XML_CXX_DECLARE_CONTAINER_CLASS__(PriorityQueue, std::priority_queue);
__XML_CXX_DECLARE_CONTAINER_CLASS__(PriorityQueue, std::priority_queue)
# undef __XML_CXX_DECLARE_CONTAINER_CLASS__
# define __XML_CXX_DECLARE_CONTAINER_CLASS__(CONTAINER, STD_CONTAINER) \
namespace xml { \
@@ -1592,7 +1568,7 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(PriorityQueue, std::priority_queue);
AssociativeContainer \
<STD_CONTAINER<TYPE, COMPARE, ALLOC> >(o) { \
} \
CONTAINER(const std::string& className) throw(): \
CONTAINER(const std::string& className) noexcept: \
AssociativeContainer \
<STD_CONTAINER<TYPE, COMPARE, ALLOC> > \
(className) { \
@@ -1601,8 +1577,8 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(PriorityQueue, std::priority_queue);
}; \
}
# include <set>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Set, std::set);
__XML_CXX_DECLARE_CONTAINER_CLASS__(MultiSet, std::multiset);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Set, std::set)
__XML_CXX_DECLARE_CONTAINER_CLASS__(MultiSet, std::multiset)
# undef __XML_CXX_DECLARE_CONTAINER_CLASS__
# define __XML_CXX_DECLARE_CONTAINER_CLASS__(CONTAINER, STD_CONTAINER) \
namespace xml { \
@@ -1616,7 +1592,7 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(MultiSet, std::multiset);
AssociativeMap \
<STD_CONTAINER<KEY, VALUE, COMPARE, ALLOC> >(o) { \
} \
CONTAINER(const std::string& className) throw(): \
CONTAINER(const std::string& className) noexcept: \
AssociativeMap \
<STD_CONTAINER<KEY, VALUE, COMPARE, ALLOC> > \
(className) { \
@@ -1625,8 +1601,8 @@ __XML_CXX_DECLARE_CONTAINER_CLASS__(MultiSet, std::multiset);
}; \
}
# include <map>
__XML_CXX_DECLARE_CONTAINER_CLASS__(Map, std::map);
__XML_CXX_DECLARE_CONTAINER_CLASS__(MultiMap, std::multimap);
__XML_CXX_DECLARE_CONTAINER_CLASS__(Map, std::map)
__XML_CXX_DECLARE_CONTAINER_CLASS__(MultiMap, std::multimap)
# undef __XML_CXX_DECLARE_CONTAINER_CLASS__
//@}
//! @endcond