KiCad PCB EDA Suite
XNODE Class Reference

Class XNODE holds an XML or S-expression element. More...

#include <xnode.h>

Inheritance diagram for XNODE:

Public Member Functions

 XNODE ()
 
 XNODE (wxXmlNodeType aType, const wxString &aName, const wxString &aContent=wxEmptyString)
 
 XNODE (XNODE *aParent, wxXmlNodeType aType, const wxString &aName, const wxString &aContent=wxEmptyString, wxXmlAttribute *aProperties=NULL)
 
XNODEGetChildren () const
 
XNODEGetNext () const
 
XNODEGetParent () const
 
virtual void Format (OUTPUTFORMATTER *out, int nestLevel)
 Function Format writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression. More...
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel)
 Function FormatContents writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression. More...
 

Detailed Description

Class XNODE holds an XML or S-expression element.

It is used for eXporting a document tree in EITHER XML or S-expression.

Definition at line 43 of file xnode.h.

Constructor & Destructor Documentation

◆ XNODE() [1/3]

XNODE::XNODE ( )
inline

Definition at line 47 of file xnode.h.

47  :
48  wxXmlNode()
49  {
50  }

◆ XNODE() [2/3]

XNODE::XNODE ( wxXmlNodeType  aType,
const wxString &  aName,
const wxString &  aContent = wxEmptyString 
)
inline

Definition at line 52 of file xnode.h.

52  :
53  wxXmlNode( NULL, aType, aName, aContent )
54  {
55  }

◆ XNODE() [3/3]

XNODE::XNODE ( XNODE aParent,
wxXmlNodeType  aType,
const wxString &  aName,
const wxString &  aContent = wxEmptyString,
wxXmlAttribute *  aProperties = NULL 
)
inline

Definition at line 57 of file xnode.h.

58  :
59  wxXmlNode( aParent, aType, aName, aContent, aProperties )
60  {
61  }

Member Function Documentation

◆ Format()

void XNODE::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
virtual

Function Format writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to preceed the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Definition at line 32 of file xnode.cpp.

33 {
34  switch( GetType() )
35  {
36  case wxXML_ELEMENT_NODE:
37  out->Print( nestLevel, "(%s", TO_UTF8( GetName() ) );
38  FormatContents( out, nestLevel );
39  if( GetNext() )
40  out->Print( 0, ")\n" );
41  else
42  out->Print( 0, ")" );
43  break;
44 
45  default:
46  FormatContents( out, nestLevel );
47  }
48 }
virtual void FormatContents(OUTPUTFORMATTER *out, int nestLevel)
Function FormatContents writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expre...
Definition: xnode.cpp:51
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:47
XNODE * GetNext() const
Definition: xnode.h:68
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

References FormatContents(), GetNext(), OUTPUTFORMATTER::Print(), and TO_UTF8.

◆ FormatContents()

void XNODE::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
virtual

Function FormatContents writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression.

This is the same as Format() except that the outer wrapper is not included.

Parameters
outThe formatter to write to.
nestLevelA multiple of the number of spaces to preceed the output with.
Exceptions
IO_ERRORif a system error writing the output, such as a full disk.

Definition at line 51 of file xnode.cpp.

52 {
53  // output attributes first if they exist
54  for( XATTR* attr = (XATTR*) GetAttributes(); attr; attr = (XATTR*) attr->GetNext() )
55  {
56  out->Print( 0, " (%s %s)",
57  TO_UTF8( attr->GetName() ),
58  out->Quotew( attr->GetValue() ).c_str() );
59  }
60 
61  // we only expect to have used one of two types here:
62  switch( GetType() )
63  {
64  case wxXML_ELEMENT_NODE:
65 
66  // output children if they exist.
67  for( XNODE* kid = (XNODE*) GetChildren(); kid; kid = (XNODE*) kid->GetNext() )
68  {
69  if( kid->GetType() != wxXML_TEXT_NODE )
70  {
71  if( kid == GetChildren() )
72  out->Print( 0, "\n" );
73  kid->Format( out, nestLevel+1 );
74  }
75  else
76  {
77  kid->Format( out, 0 );
78  }
79  }
80  break;
81 
82  case wxXML_TEXT_NODE:
83  out->Print( 0, " %s", out->Quotew( GetContent() ).c_str() );
84  break;
85 
86  default:
87  ; // not supported
88  }
89 }
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:47
XNODE * GetChildren() const
Definition: xnode.h:63
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
wxXmlAttribute XATTR
Definition: xnode.cpp:29
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

References GetChildren(), OUTPUTFORMATTER::Print(), OUTPUTFORMATTER::Quotew(), and TO_UTF8.

Referenced by Format().

◆ GetChildren()

XNODE* XNODE::GetChildren ( ) const
inline

Definition at line 63 of file xnode.h.

64  {
65  return (XNODE* )wxXmlNode::GetChildren();
66  }
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43

Referenced by PCAD2KICAD::PCB_MODULE::DoLayerContentsObjects(), PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::FindNode(), FormatContents(), PCAD2KICAD::PCB::GetBoardOutline(), PCAD2KICAD::PCB_MODULE::Parse(), and PCAD2KICAD::PCB::ParseBoard().

◆ GetNext()

◆ GetParent()

XNODE* XNODE::GetParent ( void  ) const
inline

Definition at line 73 of file xnode.h.

74  {
75  return (XNODE* )wxXmlNode::GetParent();
76  }
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB_MODULE::FindPatternMultilayerSection(), PCAD2KICAD::LoadInputFile(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_MODULE::Parse(), and PCAD2KICAD::SetFontProperty().


The documentation for this class was generated from the following files: