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) throw ( IO_ERROR )
 Function Format writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression. More...
 
virtual void FormatContents (OUTPUTFORMATTER *out, int nestLevel) throw ( IO_ERROR )
 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::XNODE ( )
inline

Definition at line 47 of file xnode.h.

47  :
48  wxXmlNode()
49  {
50  }
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::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

void XNODE::Format ( OUTPUTFORMATTER out,
int  nestLevel 
)
throw (IO_ERROR
)
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", out->Quotew( GetName() ).c_str() );
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
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:486
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:408
XNODE * GetNext() const
Definition: xnode.h:68
void XNODE::FormatContents ( OUTPUTFORMATTER out,
int  nestLevel 
)
throw (IO_ERROR
)
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  // attr names should never need quoting, no spaces, we designed the file.
58  out->Quotew( attr->GetName() ).c_str(),
59  out->Quotew( attr->GetValue() ).c_str()
60  );
61  }
62 
63  // we only expect to have used one of two types here:
64  switch( GetType() )
65  {
66  case wxXML_ELEMENT_NODE:
67 
68  // output children if they exist.
69  for( XNODE* kid = (XNODE*) GetChildren(); kid; kid = (XNODE*) kid->GetNext() )
70  {
71  if( kid->GetType() != wxXML_TEXT_NODE )
72  {
73  if( kid == GetChildren() )
74  out->Print( 0, "\n" );
75  kid->Format( out, nestLevel+1 );
76  }
77  else
78  {
79  kid->Format( out, 0 );
80  }
81  }
82  break;
83 
84  case wxXML_TEXT_NODE:
85  out->Print( 0, " %s", out->Quotew( GetContent() ).c_str() );
86  break;
87 
88  default:
89  ; // not supported
90  }
91 }
XNODE * GetChildren() const
Definition: xnode.h:63
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:486
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:408
XNODE* XNODE::GetChildren ( ) const
inline

Definition at line 63 of file xnode.h.

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

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

Definition at line 73 of file xnode.h.

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().

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

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