Style Fixes
(1) A few classes should be made non-copyable (2) C++11 semantics should be preferred to mark classes non-copyable (3) Added explicit to several contructors in oder to prevent implicit conversions
This commit is contained in:
parent
d62b2541d7
commit
baf4f6657a
@ -240,7 +240,7 @@ namespace pugi
|
||||
typedef It const_iterator;
|
||||
typedef It iterator;
|
||||
|
||||
xml_object_range(It b, It e): _begin(b), _end(e)
|
||||
explicit xml_object_range(It b, It e): _begin(b), _end(e)
|
||||
{
|
||||
}
|
||||
|
||||
@ -264,9 +264,18 @@ namespace pugi
|
||||
// xml_writer implementation for FILE*
|
||||
class PUGIXML_CLASS xml_writer_file: public xml_writer
|
||||
{
|
||||
// Non-copyable semantics
|
||||
#if __cplusplus >= 201103
|
||||
xml_writer_file(const xml_writer_file&) = delete;
|
||||
xml_writer_file& operator=(const xml_writer_file) = delete;
|
||||
#else
|
||||
xml_writer_file(const xml_writer_file&);
|
||||
xml_writer_file& operator=(const xml_writer_file);
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Construct writer from a FILE* object; void* is used to avoid header dependencies on stdio
|
||||
xml_writer_file(void* file);
|
||||
explicit xml_writer_file(void* file);
|
||||
|
||||
virtual void write(const void* data, size_t size);
|
||||
|
||||
@ -278,10 +287,19 @@ namespace pugi
|
||||
// xml_writer implementation for streams
|
||||
class PUGIXML_CLASS xml_writer_stream: public xml_writer
|
||||
{
|
||||
// Non-copyable semantics
|
||||
#if __cplusplus >= 201103
|
||||
xml_writer_stream(const xml_writer_stream&) = delete;
|
||||
xml_writer_stream& operator=(const xml_writer_stream) = delete;
|
||||
#else
|
||||
xml_writer_stream(const xml_writer_stream&);
|
||||
xml_writer_stream& operator=(const xml_writer_stream);
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Construct writer from an output stream object
|
||||
xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
|
||||
xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
|
||||
explicit xml_writer_stream(std::basic_ostream<char, std::char_traits<char> >& stream);
|
||||
explicit xml_writer_stream(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& stream);
|
||||
|
||||
virtual void write(const void* data, size_t size);
|
||||
|
||||
@ -759,7 +777,7 @@ namespace pugi
|
||||
xml_node_iterator();
|
||||
|
||||
// Construct an iterator which points to the specified node
|
||||
xml_node_iterator(const xml_node& node);
|
||||
explicit xml_node_iterator(const xml_node& node);
|
||||
|
||||
// Iterator operators
|
||||
bool operator==(const xml_node_iterator& rhs) const;
|
||||
@ -784,7 +802,7 @@ namespace pugi
|
||||
mutable xml_attribute _wrap;
|
||||
xml_node _parent;
|
||||
|
||||
xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
|
||||
explicit xml_attribute_iterator(xml_attribute_struct* ref, xml_node_struct* parent);
|
||||
|
||||
public:
|
||||
// Iterator traits
|
||||
@ -801,7 +819,7 @@ namespace pugi
|
||||
xml_attribute_iterator();
|
||||
|
||||
// Construct an iterator which points to the specified attribute
|
||||
xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
|
||||
explicit xml_attribute_iterator(const xml_attribute& attr, const xml_node& parent);
|
||||
|
||||
// Iterator operators
|
||||
bool operator==(const xml_attribute_iterator& rhs) const;
|
||||
@ -837,7 +855,7 @@ namespace pugi
|
||||
xml_named_node_iterator();
|
||||
|
||||
// Construct an iterator which points to the specified node
|
||||
xml_named_node_iterator(const xml_node& node, const char_t* name);
|
||||
explicit xml_named_node_iterator(const xml_node& node, const char_t* name);
|
||||
|
||||
// Iterator operators
|
||||
bool operator==(const xml_named_node_iterator& rhs) const;
|
||||
@ -938,14 +956,18 @@ namespace pugi
|
||||
// Document class (DOM tree root)
|
||||
class PUGIXML_CLASS xml_document: public xml_node
|
||||
{
|
||||
private:
|
||||
char_t* _buffer;
|
||||
|
||||
char _memory[192];
|
||||
|
||||
// Non-copyable semantics
|
||||
#if __cplusplus >= 201103
|
||||
xml_document(const xml_document&) = delete;
|
||||
const xml_document& operator=(const xml_document&) = delete;
|
||||
#else
|
||||
xml_document(const xml_document&);
|
||||
const xml_document& operator=(const xml_document&);
|
||||
#endif
|
||||
|
||||
private:
|
||||
char_t* _buffer;
|
||||
char _memory[192];
|
||||
|
||||
void create();
|
||||
void destroy();
|
||||
@ -1040,17 +1062,21 @@ namespace pugi
|
||||
// A single XPath variable
|
||||
class PUGIXML_CLASS xpath_variable
|
||||
{
|
||||
// Non-copyable semantics
|
||||
#if __cplusplus >= 201103
|
||||
xpath_variable(const xpath_variable&) = delete;
|
||||
xpath_variable& operator=(const xpath_variable&) = delete;
|
||||
#else
|
||||
xpath_variable(const xpath_variable&);
|
||||
xpath_variable& operator=(const xpath_variable&);
|
||||
#endif
|
||||
friend class xpath_variable_set;
|
||||
|
||||
protected:
|
||||
xpath_value_type _type;
|
||||
xpath_variable* _next;
|
||||
|
||||
xpath_variable(xpath_value_type type);
|
||||
|
||||
// Non-copyable semantics
|
||||
xpath_variable(const xpath_variable&);
|
||||
xpath_variable& operator=(const xpath_variable&);
|
||||
explicit xpath_variable(xpath_value_type type);
|
||||
|
||||
public:
|
||||
// Get variable name
|
||||
@ -1118,16 +1144,21 @@ namespace pugi
|
||||
// A compiled XPath query object
|
||||
class PUGIXML_CLASS xpath_query
|
||||
{
|
||||
// Non-copyable semantics
|
||||
#if __cplusplus >= 201103
|
||||
xpath_query(const xpath_query&) = delete;
|
||||
xpath_query& operator=(const xpath_query&) = delete;
|
||||
#else
|
||||
xpath_query(const xpath_query&);
|
||||
xpath_query& operator=(const xpath_query&);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void* _impl;
|
||||
xpath_parse_result _result;
|
||||
|
||||
typedef void (*unspecified_bool_type)(xpath_query***);
|
||||
|
||||
// Non-copyable semantics
|
||||
xpath_query(const xpath_query&);
|
||||
xpath_query& operator=(const xpath_query&);
|
||||
|
||||
public:
|
||||
// Construct a compiled object from XPath expression.
|
||||
// If PUGIXML_NO_EXCEPTIONS is not defined, throws xpath_exception on compilation errors.
|
||||
@ -1223,7 +1254,7 @@ namespace pugi
|
||||
|
||||
// Construct XPath node from XML node/attribute
|
||||
xpath_node(const xml_node& node);
|
||||
xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
||||
explicit xpath_node(const xml_attribute& attribute, const xml_node& parent);
|
||||
|
||||
// Get node/attribute, if any
|
||||
xml_node node() const;
|
||||
@ -1271,7 +1302,7 @@ namespace pugi
|
||||
xpath_node_set();
|
||||
|
||||
// Constructs a set from iterator range; data is not checked for duplicates and is not sorted according to provided type, so be careful
|
||||
xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
|
||||
explicit xpath_node_set(const_iterator begin, const_iterator end, type_t type = type_unsorted);
|
||||
|
||||
// Destructor
|
||||
~xpath_node_set();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user