Commit 566df2b620a6498544015e5171e8e45df22c28ed
1 parent
a803ba6b
make clone() method public
Showing
5 changed files
with
54 additions
and
48 deletions
include/GXmlComment.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GXmlComment.hpp - XML comment node class definition * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2010-2011 by Jurgen Knodlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software; you can redistribute it and/or modify * |
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | #define GXMLCOMMENT_HPP |
| 21 | 21 | |
| 22 | 22 | /* __ Includes ___________________________________________________________ */ |
| 23 | +#include <cstdio> // FILE*, std::fprintf | |
| 23 | 24 | #include <string> |
| 24 | 25 | #include <iostream> |
| 25 | 26 | #include "GXmlNode.hpp" |
| ... | ... | @@ -46,20 +47,22 @@ public: |
| 46 | 47 | GXmlComment& operator= (const GXmlComment& node); |
| 47 | 48 | |
| 48 | 49 | // Implemented virtual methods |
| 49 | - void clear(void); | |
| 50 | - void write(FILE* fptr, int indent = 0) const; | |
| 51 | - void print(std::ostream& os, int indent = 0) const; | |
| 52 | - NodeType type(void) const { return NT_COMMENT; } | |
| 50 | + void clear(void); | |
| 51 | + GXmlComment* clone(void) const; | |
| 52 | + void write(FILE* fptr, int indent = 0) const; | |
| 53 | + void print(std::ostream& os, int indent = 0) const; | |
| 54 | + NodeType type(void) const { return NT_COMMENT; } | |
| 55 | + | |
| 56 | + // Other methods | |
| 57 | + const std::string& comment(void) const { return m_comment; } | |
| 58 | + void comment(const std::string& comment) { m_comment=comment; } | |
| 53 | 59 | |
| 54 | 60 | protected: |
| 55 | 61 | // Protected methods |
| 56 | 62 | void init_members(void); |
| 57 | 63 | void copy_members(const GXmlComment& node); |
| 58 | 64 | void free_members(void); |
| 59 | - GXmlComment* clone(void) const; | |
| 60 | 65 | void parse(const std::string& segment); |
| 61 | - std::string comment(void) const { return m_comment; } | |
| 62 | - void comment(const std::string& comment) { m_comment=comment; } | |
| 63 | 66 | |
| 64 | 67 | // Protected data members |
| 65 | 68 | std::string m_comment; //!< Comment (excluding brackets) | ... | ... |
pyext/GXmlComment.i
| 1 | 1 | /*************************************************************************** |
| 2 | - * GXmlComment.i - XML comment node class definition * | |
| 2 | + * GXmlComment.i - XML comment node class * | |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | 4 | * copyright (C) 2010-2011 by Jurgen Knodlseder * |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | ***************************************************************************/ |
| 13 | 13 | /** |
| 14 | 14 | * @file GXmlComment.i |
| 15 | - * @brief GXmlComment class python bindings | |
| 15 | + * @brief XML comment class Python interface definition | |
| 16 | 16 | * @author J. Knodlseder |
| 17 | 17 | */ |
| 18 | 18 | %{ |
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | /***********************************************************************//** |
| 26 | 26 | * @class GXmlComment |
| 27 | 27 | * |
| 28 | - * @brief XML comment node class interface defintion. | |
| 28 | + * @brief XML comment node class | |
| 29 | 29 | * |
| 30 | 30 | * This class implements a XML comment. The comment text is stored without |
| 31 | 31 | * the <!-- --> brackets. |
| ... | ... | @@ -40,10 +40,15 @@ public: |
| 40 | 40 | ~GXmlComment(void); |
| 41 | 41 | |
| 42 | 42 | // Implemented virtual methods |
| 43 | - void clear(void); | |
| 44 | - void write(FILE* fptr, int indent = 0) const; | |
| 45 | - //void print(std::ostream& os, int indent = 0) const; | |
| 46 | - NodeType type(void) const { return NT_COMMENT; } | |
| 43 | + void clear(void); | |
| 44 | + GXmlComment* clone(void) const; | |
| 45 | + void write(FILE* fptr, int indent = 0) const; | |
| 46 | + //void print(std::ostream& os, int indent = 0) const; | |
| 47 | + NodeType type(void) const { return NT_COMMENT; } | |
| 48 | + | |
| 49 | + // Other methods | |
| 50 | + const std::string& comment(void) const; | |
| 51 | + void comment(const std::string& comment); | |
| 47 | 52 | }; |
| 48 | 53 | |
| 49 | 54 | ... | ... |
pyext/GXmlDocument.i
| ... | ... | @@ -46,12 +46,12 @@ public: |
| 46 | 46 | NodeType type(void) const; |
| 47 | 47 | |
| 48 | 48 | // Methods |
| 49 | - const std::string& version(void) const; | |
| 50 | - const std::string& encoding(void) const; | |
| 51 | - const std::string& standalone(void) const; | |
| 52 | - void version(const std::string& version); | |
| 53 | - void encoding(const std::string& encoding); | |
| 54 | - void standalone(const std::string& standalone); | |
| 49 | + std::string version(void) const; | |
| 50 | + std::string encoding(void) const; | |
| 51 | + std::string standalone(void) const; | |
| 52 | + void version(const std::string& version); | |
| 53 | + void encoding(const std::string& encoding); | |
| 54 | + void standalone(const std::string& standalone); | |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | 57 | ... | ... |
src/xml/GXmlComment.cpp
| ... | ... | @@ -20,8 +20,6 @@ |
| 20 | 20 | #ifdef HAVE_CONFIG_H |
| 21 | 21 | #include <config.h> |
| 22 | 22 | #endif |
| 23 | -#include <cstdio> // std::fprintf | |
| 24 | -#include <iostream> | |
| 25 | 23 | #include "GException.hpp" |
| 26 | 24 | #include "GXmlComment.hpp" |
| 27 | 25 | |
| ... | ... | @@ -46,7 +44,7 @@ |
| 46 | 44 | ***************************************************************************/ |
| 47 | 45 | GXmlComment::GXmlComment(void) : GXmlNode() |
| 48 | 46 | { |
| 49 | - // Initialise private members for clean destruction | |
| 47 | + // Initialise members | |
| 50 | 48 | init_members(); |
| 51 | 49 | |
| 52 | 50 | // Return |
| ... | ... | @@ -57,11 +55,11 @@ GXmlComment::GXmlComment(void) : GXmlNode() |
| 57 | 55 | /***********************************************************************//** |
| 58 | 56 | * @brief Copy constructor |
| 59 | 57 | * |
| 60 | - * @param[in] node Object from which the instance should be built. | |
| 58 | + * @param[in] node XML comment. | |
| 61 | 59 | ***************************************************************************/ |
| 62 | 60 | GXmlComment::GXmlComment(const GXmlComment& node) : GXmlNode(node) |
| 63 | 61 | { |
| 64 | - // Initialise private members for clean destruction | |
| 62 | + // Initialise members | |
| 65 | 63 | init_members(); |
| 66 | 64 | |
| 67 | 65 | // Copy members |
| ... | ... | @@ -79,7 +77,7 @@ GXmlComment::GXmlComment(const GXmlComment& node) : GXmlNode(node) |
| 79 | 77 | ***************************************************************************/ |
| 80 | 78 | GXmlComment::GXmlComment(const std::string& segment) : GXmlNode() |
| 81 | 79 | { |
| 82 | - // Initialise private members for clean destruction | |
| 80 | + // Initialise members | |
| 83 | 81 | init_members(); |
| 84 | 82 | |
| 85 | 83 | // Parse segment |
| ... | ... | @@ -112,7 +110,7 @@ GXmlComment::~GXmlComment(void) |
| 112 | 110 | /***********************************************************************//** |
| 113 | 111 | * @brief Assignment operator |
| 114 | 112 | * |
| 115 | - * @param[in] node Object which should be assigned. | |
| 113 | + * @param[in] node XML comment. | |
| 116 | 114 | ***************************************************************************/ |
| 117 | 115 | GXmlComment& GXmlComment::operator= (const GXmlComment& node) |
| 118 | 116 | { |
| ... | ... | @@ -165,6 +163,15 @@ void GXmlComment::clear(void) |
| 165 | 163 | |
| 166 | 164 | |
| 167 | 165 | /***********************************************************************//** |
| 166 | + * @brief Clone class | |
| 167 | +***************************************************************************/ | |
| 168 | +GXmlComment* GXmlComment::clone(void) const | |
| 169 | +{ | |
| 170 | + return new GXmlComment(*this); | |
| 171 | +} | |
| 172 | + | |
| 173 | + | |
| 174 | +/***********************************************************************//** | |
| 168 | 175 | * @brief Write comment into file |
| 169 | 176 | * |
| 170 | 177 | * @param[in] fptr File pointer. |
| ... | ... | @@ -222,7 +229,7 @@ void GXmlComment::init_members(void) |
| 222 | 229 | /***********************************************************************//** |
| 223 | 230 | * @brief Copy class members |
| 224 | 231 | * |
| 225 | - * @param[in] node Object from which members which should be copied. | |
| 232 | + * @param[in] node XML comment. | |
| 226 | 233 | ***************************************************************************/ |
| 227 | 234 | void GXmlComment::copy_members(const GXmlComment& node) |
| 228 | 235 | { |
| ... | ... | @@ -245,15 +252,6 @@ void GXmlComment::free_members(void) |
| 245 | 252 | |
| 246 | 253 | |
| 247 | 254 | /***********************************************************************//** |
| 248 | - * @brief Clone class | |
| 249 | -***************************************************************************/ | |
| 250 | -GXmlComment* GXmlComment::clone(void) const | |
| 251 | -{ | |
| 252 | - return new GXmlComment(*this); | |
| 253 | -} | |
| 254 | - | |
| 255 | - | |
| 256 | -/***********************************************************************//** | |
| 257 | 255 | * @brief Parse comment segment string |
| 258 | 256 | * |
| 259 | 257 | * @param[in] segment Segment string. |
| ... | ... | @@ -289,7 +287,7 @@ void GXmlComment::parse(const std::string& segment) |
| 289 | 287 | else |
| 290 | 288 | m_comment = segment; |
| 291 | 289 | |
| 292 | - //TODO Check validity of characters comment string | |
| 290 | + //@todo Check validity of characters comment string | |
| 293 | 291 | |
| 294 | 292 | } // endif: string is not empty |
| 295 | 293 | ... | ... |
src/xml/GXmlDocument.cpp
| ... | ... | @@ -145,6 +145,15 @@ void GXmlDocument::clear(void) |
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | /***********************************************************************//** |
| 148 | + * @brief Clone class | |
| 149 | +***************************************************************************/ | |
| 150 | +GXmlDocument* GXmlDocument::clone(void) const | |
| 151 | +{ | |
| 152 | + return new GXmlDocument(*this); | |
| 153 | +} | |
| 154 | + | |
| 155 | + | |
| 156 | +/***********************************************************************//** | |
| 148 | 157 | * @brief Write node into file |
| 149 | 158 | * |
| 150 | 159 | * @param[in] fptr File pointer. |
| ... | ... | @@ -248,15 +257,6 @@ void GXmlDocument::free_members(void) |
| 248 | 257 | } |
| 249 | 258 | |
| 250 | 259 | |
| 251 | -/***********************************************************************//** | |
| 252 | - * @brief Clone class | |
| 253 | -***************************************************************************/ | |
| 254 | -GXmlDocument* GXmlDocument::clone(void) const | |
| 255 | -{ | |
| 256 | - return new GXmlDocument(*this); | |
| 257 | -} | |
| 258 | - | |
| 259 | - | |
| 260 | 260 | /*========================================================================== |
| 261 | 261 | = = |
| 262 | 262 | = Friends = | ... | ... |