Commit f6440cff authored by Murray Cumming's avatar Murray Cumming

C++11: Use the override keyword.

parent 3784f360
......@@ -44,8 +44,8 @@ class fail_exception : public std::exception
{
public:
fail_exception(const std::string& msg) : msg_(msg) {}
virtual ~fail_exception() throw() {}
virtual const char* what() const throw() { return msg_.c_str(); }
~fail_exception() throw() override {}
const char* what() const throw() override { return msg_.c_str(); }
private:
std::string msg_;
......
......@@ -28,29 +28,29 @@ class MyException: public xmlpp::exception
{
public:
MyException();
virtual ~MyException() throw ();
virtual void Raise() const;
virtual xmlpp::exception * Clone() const;
~MyException() throw() override;
void Raise() const override;
xmlpp::exception * Clone() const override;
};
class MySaxParser : public xmlpp::SaxParser
{
public:
MySaxParser();
virtual ~MySaxParser();
~MySaxParser() override;
protected:
//overrides:
virtual void on_start_document();
virtual void on_end_document();
virtual void on_start_element(const Glib::ustring& name,
const AttributeList &properties);
virtual void on_end_element(const Glib::ustring& name);
virtual void on_characters(const Glib::ustring& characters);
virtual void on_comment(const Glib::ustring& text);
virtual void on_warning(const Glib::ustring& text);
virtual void on_error(const Glib::ustring& text);
virtual void on_fatal_error(const Glib::ustring& text);
void on_start_document() override;
void on_end_document() override;
void on_start_element(const Glib::ustring& name,
const AttributeList &properties) override;
void on_end_element(const Glib::ustring& name) override;
void on_characters(const Glib::ustring& characters) override;
void on_comment(const Glib::ustring& text) override;
void on_warning(const Glib::ustring& text) override;
void on_error(const Glib::ustring& text) override;
void on_fatal_error(const Glib::ustring& text) override;
};
......
......@@ -28,20 +28,20 @@ class MySaxParser : public xmlpp::SaxParser
{
public:
MySaxParser();
virtual ~MySaxParser();
~MySaxParser() override;
protected:
//overrides:
virtual void on_start_document();
virtual void on_end_document();
virtual void on_start_element(const Glib::ustring& name,
const AttributeList& properties);
virtual void on_end_element(const Glib::ustring& name);
virtual void on_characters(const Glib::ustring& characters);
virtual void on_comment(const Glib::ustring& text);
virtual void on_warning(const Glib::ustring& text);
virtual void on_error(const Glib::ustring& text);
virtual void on_fatal_error(const Glib::ustring& text);
void on_start_document() override;
void on_end_document() override;
void on_start_element(const Glib::ustring& name,
const AttributeList& properties) override;
void on_end_element(const Glib::ustring& name) override;
void on_characters(const Glib::ustring& characters) override;
void on_comment(const Glib::ustring& text) override;
void on_warning(const Glib::ustring& text) override;
void on_error(const Glib::ustring& text) override;
void on_fatal_error(const Glib::ustring& text) override;
};
......
......@@ -35,7 +35,7 @@ class Element : public xmlpp::Element
public:
Element(xmlNode* node);
virtual ~Element();
~Element() override;
// example custom methods
void set_style(const Glib::ustring& style);
......
......@@ -34,7 +34,7 @@ class Parser : public xmlpp::SaxParser
{
public:
Parser(xmlpp::Document& document);
virtual ~Parser();
~Parser() override;
protected:
// SAX parser callbacks
......
......@@ -28,23 +28,23 @@ class MySaxParser : public xmlpp::SaxParser
{
public:
MySaxParser();
virtual ~MySaxParser();
~MySaxParser() override;
protected:
//overrides:
virtual void on_start_document();
virtual void on_end_document();
void on_start_document() override;
void on_end_document() override;
virtual void on_start_element(const Glib::ustring& name,
const AttributeList& properties);
virtual void on_end_element(const Glib::ustring& name);
virtual void on_characters(const Glib::ustring& characters);
virtual void on_comment(const Glib::ustring& text);
virtual void on_warning(const Glib::ustring& text);
virtual void on_error(const Glib::ustring& text);
virtual void on_fatal_error(const Glib::ustring& text);
virtual _xmlEntity* on_get_entity(const Glib::ustring& name);
virtual void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content);
void on_end_element(const Glib::ustring& name) override;
void on_characters(const Glib::ustring& characters) override;
void on_comment(const Glib::ustring& text) override;
void on_warning(const Glib::ustring& text) override;
void on_error(const Glib::ustring& text) override;
void on_fatal_error(const Glib::ustring& text) override;
_xmlEntity* on_get_entity(const Glib::ustring& name) override;
void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) override;
};
......
......@@ -28,7 +28,7 @@ class Attribute : public Node
{
public:
explicit Attribute(_xmlNode* node);
virtual ~Attribute();
~Attribute() override;
//TODO: Can we remove this and just use Node::get_name()?
// Yes, when we can break ABI. /Kjell Ahlstedt 2012-02-09
......
......@@ -29,7 +29,7 @@ class AttributeDeclaration : public Attribute
{
public:
explicit AttributeDeclaration(_xmlNode* node);
virtual ~AttributeDeclaration();
~AttributeDeclaration() override;
/** Get the default value of this attribute.
* @returns The attribute's default value.
......
......@@ -24,7 +24,7 @@ class AttributeNode : public Attribute
{
public:
explicit AttributeNode(_xmlNode* node);
virtual ~AttributeNode();
~AttributeNode() override;
};
} // namespace xmlpp
......
......@@ -53,6 +53,8 @@ class Document : NonCopyable
{
public:
Init();
//TODO: Remove the virtual when we can break ABI?
virtual ~Init();
};
......@@ -72,7 +74,7 @@ public:
*/
explicit Document(_xmlDoc* doc);
virtual ~Document();
~Document() override;
/** @return The encoding used in the source from which the document has been loaded.
*/
......@@ -247,6 +249,8 @@ protected:
_xmlEntity* get_entity(const Glib::ustring& name);
private:
//TODO: Remove virtuals when we can break ABI.
virtual void do_write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding, bool format);
virtual Glib::ustring do_write_to_string(const Glib::ustring& encoding, bool format);
virtual void do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format);
......
......@@ -41,9 +41,11 @@ class LIBXMLPP_API exception: public std::exception
{
public:
explicit exception(const Glib::ustring& message);
virtual ~exception() throw();
~exception() throw() override;
virtual const char* what() const throw();
const char* what() const throw() override;
//TODO: Use lower-case names when we can break ABI?
virtual void Raise() const;
virtual exception * Clone() const;
......
......@@ -33,10 +33,10 @@ class internal_error: public exception
{
public:
explicit internal_error(const Glib::ustring& message);
virtual ~internal_error() throw();
~internal_error() throw() override;
virtual void Raise() const;
virtual exception * Clone() const;
void Raise() const override;
exception * Clone() const override;
};
} // namespace xmlpp
......
......@@ -36,10 +36,10 @@ class parse_error: public exception
{
public:
explicit parse_error(const Glib::ustring& message);
virtual ~parse_error() throw();
~parse_error() throw() override;
virtual void Raise() const;
virtual exception* Clone() const;
void Raise() const override;
exception* Clone() const override;
};
} // namespace xmlpp
......
......@@ -33,10 +33,10 @@ class validity_error: public parse_error
{
public:
explicit validity_error(const Glib::ustring& message);
virtual ~validity_error() throw();
~validity_error() throw() override;
virtual void Raise() const;
virtual exception* Clone() const;
void Raise() const override;
exception* Clone() const override;
};
} // namespace xmlpp
......
......@@ -23,11 +23,11 @@ namespace xmlpp
* @param input The istream datas will be read from
*/
IStreamParserInputBuffer(std::istream& input);
virtual ~IStreamParserInputBuffer();
~IStreamParserInputBuffer() override;
private:
virtual int do_read(char * buffer, int len);
virtual bool do_close();
int do_read(char * buffer, int len) override;
bool do_close() override;
std::istream& input_;
};
......
......@@ -27,11 +27,11 @@ namespace xmlpp
* sent to the stream
*/
OStreamOutputBuffer(std::ostream& output, const Glib::ustring& encoding = Glib::ustring());
virtual ~OStreamOutputBuffer();
~OStreamOutputBuffer() override;
private:
virtual bool do_write(const char * buffer, int len);
virtual bool do_close();
bool do_write(const char * buffer, int len) override;
bool do_close() override;
std::ostream& output_;
};
......
......@@ -41,7 +41,7 @@ namespace xmlpp
* have a translator to the target encoding.
*/
OutputBuffer(const Glib::ustring& encoding = Glib::ustring());
virtual ~OutputBuffer();
~OutputBuffer() override;
public:
/** gives an access to the underlying libxml structure to the children
......
......@@ -32,7 +32,7 @@ namespace xmlpp
{
public:
ParserInputBuffer();
virtual ~ParserInputBuffer();
~ParserInputBuffer() override;
public:
/** gives an access to the underlying libxml structure to the children
......
......@@ -19,7 +19,7 @@ class CdataNode : public ContentNode
{
public:
explicit CdataNode(_xmlNode* node);
virtual ~CdataNode();
~CdataNode() override;
};
} // namespace xmlpp
......
......@@ -18,7 +18,7 @@ class CommentNode : public ContentNode
{
public:
explicit CommentNode(_xmlNode* node);
virtual ~CommentNode();
~CommentNode() override;
};
} // namespace xmlpp
......
......@@ -18,7 +18,7 @@ class ContentNode : public Node
{
public:
explicit ContentNode(_xmlNode* node);
virtual ~ContentNode();
~ContentNode() override;
/** Get the text of this content node.
* @returns The text. Note that the 5 predefined entities (&, ", <, >, ')
......
......@@ -24,7 +24,7 @@ class Element : public Node
{
public:
explicit Element(_xmlNode* node);
virtual ~Element();
~Element() override;
typedef std::list<Attribute*> AttributeList;
......
......@@ -27,7 +27,7 @@ class EntityDeclaration : public ContentNode
{
public:
explicit EntityDeclaration(_xmlNode* node);
virtual ~EntityDeclaration();
~EntityDeclaration() override;
/** Get the text with character references (like "&#xdf;") resolved.
* If the entity declaration does not contain any reference to another entity,
......
......@@ -18,7 +18,7 @@ class EntityReference : public Node
{
public:
explicit EntityReference(_xmlNode* node);
virtual ~EntityReference();
~EntityReference() override;
/** Get the text with character references (like "&#xdf;") resolved.
* If the corresponding entity declaration does not contain any reference to
......
......@@ -58,7 +58,7 @@ public:
/** @throws xmlpp::internal_error If @a node is <tt>0</tt>.
*/
explicit Node(_xmlNode* node);
virtual ~Node();
~Node() override;
/** Get the name of this node.
* @returns The node's name.
......
......@@ -16,7 +16,7 @@ class ProcessingInstructionNode : public ContentNode
{
public:
explicit ProcessingInstructionNode(_xmlNode* node);
virtual ~ProcessingInstructionNode();
~ProcessingInstructionNode() override;
};
} // namespace xmlpp
......
......@@ -18,7 +18,7 @@ class TextNode : public ContentNode
{
public:
explicit TextNode(_xmlNode* node);
virtual ~TextNode();
~TextNode() override;
};
} // namespace xmlpp
......
......@@ -33,7 +33,7 @@ class XIncludeEnd : public Node
{
public:
explicit XIncludeEnd(_xmlNode* node);
virtual ~XIncludeEnd();
~XIncludeEnd() override;
};
} // namespace xmlpp
......
......@@ -33,7 +33,7 @@ class XIncludeStart : public Node
{
public:
explicit XIncludeStart(_xmlNode* node);
virtual ~XIncludeStart();
~XIncludeStart() override;
};
} // namespace xmlpp
......
......@@ -32,7 +32,7 @@ public:
* @throws xmlpp::validity_error
*/
explicit DomParser(const Glib::ustring& filename, bool validate = false);
virtual ~DomParser();
~DomParser() override;
/** Parse an XML document from a file.
* If the parser already contains a document, that document and all its nodes
......@@ -42,7 +42,7 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_file(const Glib::ustring& filename);
void parse_file(const Glib::ustring& filename) override;
/** Parse an XML document from a string.
* If the parser already contains a document, that document and all its nodes
......@@ -52,7 +52,7 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_memory(const Glib::ustring& contents);
void parse_memory(const Glib::ustring& contents) override;
/** Parse an XML document from raw memory.
* If the parser already contains a document, that document and all its nodes
......@@ -73,7 +73,7 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_stream(std::istream& in);
void parse_stream(std::istream& in) override;
/** Test whether a document has been parsed.
*/
......@@ -90,9 +90,10 @@ public:
const Document* get_document() const;
protected:
//TODO: Remove the virtual when we can break ABI?
virtual void parse_context();
virtual void release_underlying();
void release_underlying() override;
Document* doc_;
};
......
......@@ -33,10 +33,12 @@ class Parser : NonCopyable
{
public:
Parser();
virtual ~Parser();
~Parser() override;
typedef unsigned int size_type;
//TODO: Remove virtuals when we can break ABI.
/** By default, the parser will not validate the XML file.
* @param val Whether the document should be validated.
*/
......@@ -162,6 +164,7 @@ protected:
virtual void handleException(const exception& e);
virtual void check_for_exception();
//TODO: In a future API/ABI-break, change the name of this function to
// something more appropriate, such as check_for_error_and_warning_messages.
virtual void check_for_validity_messages();
......
......@@ -78,7 +78,7 @@ public:
* behaviour of libxml, so the libxml implementation is the default here.
*/
SaxParser(bool use_get_entity = false);
virtual ~SaxParser();
~SaxParser() override;
/** Parse an XML document from a file.
* @param filename The path to the file.
......@@ -86,7 +86,7 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_file(const Glib::ustring& filename);
void parse_file(const Glib::ustring& filename) override;
/** Parse an XML document from a string.
* @param contents The XML document as a string.
......@@ -94,7 +94,7 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_memory(const Glib::ustring& contents);
void parse_memory(const Glib::ustring& contents) override;
/** Parse an XML document from raw memory.
* @param contents The XML document as an array of bytes.
......@@ -111,8 +111,9 @@ public:
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
virtual void parse_stream(std::istream& in);
void parse_stream(std::istream& in) override;
//TODO: Remove virtual when we can break ABI?
/** Parse a chunk of data.
*
* This lets you pass a document in small chunks, e.g. from a network
......@@ -148,6 +149,7 @@ public:
*/
void parse_chunk_raw(const unsigned char* contents, size_type bytes_count);
//TODO: Remove virtual when we can break ABI?
/** Finish a chunk-wise parse.
*
* Call this after the last call to parse_chunk(). Don't use this function with
......@@ -168,6 +170,7 @@ protected:
virtual void on_comment(const Glib::ustring& text);
virtual void on_warning(const Glib::ustring& text);
virtual void on_error(const Glib::ustring& text);
/** @throws xmlpp::parse_error
*/
virtual void on_fatal_error(const Glib::ustring& text);
......@@ -207,9 +210,10 @@ protected:
*/
virtual void on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content);
virtual void release_underlying();
void release_underlying() override;
private:
//TODO: Remove the virtual when we can break ABI?
virtual void parse();
std::auto_ptr<_xmlSAXHandler> sax_handler_;
......
......@@ -65,7 +65,7 @@ public:
*/
explicit RelaxNGSchema(const Document* document);
virtual ~RelaxNGSchema();
~RelaxNGSchema() override;
/** Parse a schema definition file.
* The schema must be defined with XML syntax (.rng file). The compact syntax
......@@ -75,7 +75,7 @@ public:
* @param filename The URL of the schema.
* @throws xmlpp::parse_error
*/
virtual void parse_file(const Glib::ustring& filename);
void parse_file(const Glib::ustring& filename) override;
/** Parse a schema definition from a string.
* The schema must be defined with XML syntax. The compact syntax is not supported.
......@@ -84,14 +84,14 @@ public:
* @param contents The schema definition as a string.
* @throws xmlpp::parse_error
*/
virtual void parse_memory(const Glib::ustring& contents);
void parse_memory(const Glib::ustring& contents) override;
/** Parse a schema definition from a document.
* If another schema has been parsed before, that schema is replaced by the new one.
* @param document A preparsed document tree, containing the schema definition.
* @throws xmlpp::parse_error
*/
virtual void parse_document(const Document* document);
void parse_document(const Document* document) override;
/** Access the underlying libxml implementation. */
_xmlRelaxNG* cobj();
......
......@@ -48,6 +48,8 @@ public:
explicit Schema(Document* document = 0, bool embed = false);
~Schema();
//TODO: Remove virtual when we can break ABI?
/** Set a new document to the schema.
* If the old schema document is owned by the schema (embed == true), the old
* schema document and all its nodes are deleted.
......@@ -62,9 +64,11 @@ public:
/** @deprecated There is no replacement.
*/
Glib::ustring get_name() const;
/** @deprecated There is no replacement.
*/
Glib::ustring get_target_namespace() const;
/** @deprecated There is no replacement.
*/
Glib::ustring get_version() const;
......
......@@ -38,7 +38,7 @@ class SchemaBase : NonCopyable
{
public:
SchemaBase();
virtual ~SchemaBase();
~SchemaBase() override;
/** Parse a schema definition file.
* If another schema has been parsed before, that schema is replaced by the new one.
......
......@@ -34,7 +34,10 @@ public:
*/
explicit DtdValidator(const Glib::ustring& external,const Glib::ustring& system);
virtual ~DtdValidator();
~DtdValidator() override;
//TODO: Remove virtuals when we can break ABI,
//or really put these in the base class.
/** Parse an external subset (DTD file).
* If the validator already contains a DTD, that DTD is deleted.
......@@ -90,7 +93,7 @@ public:
bool validate(const Document* doc);
protected:
virtual void release_underlying();
void release_underlying() override;
Dtd* dtd_;
};
......
......@@ -69,7 +69,10 @@ public:
*/
explicit RelaxNGValidator(RelaxNGSchema* schema, bool take_ownership);
virtual ~RelaxNGValidator();
~RelaxNGValidator() override;
//TODO: Remove virtuals when we can break ABI,
//or really put these in the base class.
/** Parse a schema definition file.
* The schema must be defined with XML syntax (.rng file). The compact syntax
......@@ -148,8 +151,8 @@ public:
virtual void validate(const Glib::ustring& filename);
protected:
virtual void initialize_valid();
virtual void release_underlying();
void initialize_valid() override;
void release_underlying() override;
private:
struct Impl;
......
......@@ -59,7 +59,10 @@ public:
*/
explicit SchemaValidator(Schema* schema);
virtual ~SchemaValidator();
~SchemaValidator() override;
//TODO: Remove virtuals when we can break ABI,
//or really put these in the base class.
/** Parse a schema definition file.
* If the validator already contains a schema, that schema is released
......@@ -137,9 +140,9 @@ public:
bool validate(const Glib::ustring& file);
protected:
virtual void initialize_valid();
void initialize_valid() override;
void parse_context(_xmlSchemaParserCtxt* context);
virtual void release_underlying();
void release_underlying() override;
Schema* schema_;
bool embbeded_shema_; //TODO Correct mis-spelling at the next API/ABI break.
......
......@@ -39,7 +39,10 @@ class SchemaValidatorBase : public Validator
{
public:
SchemaValidatorBase();
virtual ~SchemaValidatorBase();
~SchemaValidatorBase() override;
//TODO: Remove virtuals when we can break ABI,
//or really put these in the base class.