You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.1 KiB

15 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef XNODE_H_
  25. #define XNODE_H_
  26. // quiet the deprecated warnings with 3 lines:
  27. #include <wx/defs.h>
  28. #undef wxDEPRECATED
  29. #define wxDEPRECATED(x) x
  30. #include <wx/xml/xml.h>
  31. class OUTPUTFORMATTER;
  32. /**
  33. * Hold an XML or S-expression element.
  34. *
  35. * It is used for exporting a document tree in either XML or S-expression.
  36. */
  37. class XNODE : public wxXmlNode
  38. {
  39. public:
  40. XNODE() :
  41. wxXmlNode()
  42. {
  43. }
  44. XNODE( wxXmlNodeType aType, const wxString& aName, const wxString& aContent = wxEmptyString ) :
  45. wxXmlNode( nullptr, aType, aName, aContent )
  46. {
  47. }
  48. XNODE( XNODE* aParent, wxXmlNodeType aType, const wxString& aName,
  49. const wxString& aContent = wxEmptyString, wxXmlAttribute* aProperties = nullptr ) :
  50. wxXmlNode( aParent, aType, aName, aContent, aProperties )
  51. {
  52. }
  53. XNODE* GetChildren() const
  54. {
  55. return (XNODE* )wxXmlNode::GetChildren();
  56. }
  57. XNODE* GetNext() const
  58. {
  59. return (XNODE* )wxXmlNode::GetNext();
  60. }
  61. XNODE* GetParent() const
  62. {
  63. return (XNODE* )wxXmlNode::GetParent();
  64. }
  65. /**
  66. * Write this object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
  67. *
  68. * @param out The formatter to write to.
  69. * @param nestLevel A multiple of the number of spaces to precede the output with.
  70. * @throw IO_ERROR if a system error writing the output, such as a full disk.
  71. */
  72. virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
  73. /**
  74. * Write the contents of object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
  75. *
  76. * This is the same as Format() except that the outer wrapper is not included.
  77. *
  78. * @param out The formatter to write to.
  79. * @param nestLevel A multiple of the number of spaces to precede the output with.
  80. * @throw IO_ERROR if a system error writing the output, such as a full disk.
  81. */
  82. virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel );
  83. };
  84. #endif // XNODE_H_