KiCad PCB EDA Suite
ALIAS_INFO_GENERATOR Class Reference

Public Member Functions

 ALIAS_INFO_GENERATOR (LIB_ALIAS const *aAlias, int aUnit)
 
void GenerateHtml ()
 Generate the HTML internally. More...
 
wxString GetHtml ()
 Return the generated HTML. More...
 

Protected Member Functions

void SetHtmlName ()
 
void SetHtmlAliasOf ()
 
void SetHtmlDesc ()
 
void SetHtmlKeywords ()
 
wxString GetHtmlFieldRow (LIB_FIELD const &aField)
 
void SetHtmlFieldTable ()
 

Private Attributes

wxString m_html
 
LIB_ALIAS const * m_part
 
int m_unit
 

Detailed Description

Definition at line 45 of file generate_alias_info.cpp.

Constructor & Destructor Documentation

ALIAS_INFO_GENERATOR::ALIAS_INFO_GENERATOR ( LIB_ALIAS const *  aAlias,
int  aUnit 
)
inline

Definition at line 52 of file generate_alias_info.cpp.

54  m_part( aAlias ),
55  m_unit( aUnit )
56  { }
static const wxString DescriptionFormat
LIB_ALIAS const * m_part

Member Function Documentation

void ALIAS_INFO_GENERATOR::GenerateHtml ( )
inline
wxString ALIAS_INFO_GENERATOR::GetHtml ( )
inline

Return the generated HTML.

Definition at line 73 of file generate_alias_info.cpp.

References m_html.

Referenced by GenerateAliasInfo().

74  {
75  return m_html;
76  }
wxString ALIAS_INFO_GENERATOR::GetHtmlFieldRow ( LIB_FIELD const &  aField)
inlineprotected

Definition at line 141 of file generate_alias_info.cpp.

References DATASHEET, DatasheetLinkFormat, EscapedHTML(), FieldFormat, LIB_FIELD::GetFullText(), LIB_FIELD::GetId(), and LIB_FIELD::GetName().

Referenced by SetHtmlFieldTable().

142  {
143  wxString name = aField.GetName();
144  wxString text = aField.GetFullText( m_unit > 0 ? m_unit : 1 );
145  wxString fieldhtml = FieldFormat;
146 
147  fieldhtml.Replace( "__NAME__", EscapedHTML( name ) );
148 
149  switch( aField.GetId() )
150  {
151  case DATASHEET:
152  {
153  wxString datasheetlink = DatasheetLinkFormat;
154  datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) );
155  fieldhtml.Replace( "__VALUE__", datasheetlink );
156  }
157  break;
158 
159  default:
160  fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) );
161  }
162 
163  return fieldhtml;
164  }
name of datasheet
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
static const wxString FieldFormat
static const wxString DatasheetLinkFormat
void ALIAS_INFO_GENERATOR::SetHtmlAliasOf ( )
inlineprotected

Definition at line 85 of file generate_alias_info.cpp.

References AliasOfFormat, EscapedHTML(), Format(), LIB_PART::GetName(), LIB_ALIAS::GetPart(), LIB_ALIAS::IsRoot(), and EDA_ITEM::Replace().

Referenced by GenerateHtml().

86  {
87  if( m_part->IsRoot() )
88  {
89  m_html.Replace( "__ALIASOF__", wxEmptyString );
90  }
91  else
92  {
93  LIB_PART* root = m_part->GetPart();
94  const wxString root_name = ( root ? root->GetName() : _( "Unknown" ) );
95  m_html.Replace(
96  "__ALIASOF__", wxString::Format( AliasOfFormat, EscapedHTML( root_name ) ) );
97  }
98  }
static const wxString AliasOfFormat
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
bool IsRoot() const
const wxString & GetName() const
Class LIB_PART defines a library part object.
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
LIB_ALIAS const * m_part
void ALIAS_INFO_GENERATOR::SetHtmlDesc ( )
inlineprotected

Definition at line 101 of file generate_alias_info.cpp.

References DescFormat, EscapedHTML(), Format(), LIB_PART::GetAlias(), LIB_PART::GetAliasCount(), LIB_ALIAS::GetDescription(), LIB_ALIAS::GetPart(), and LIB_ALIAS::IsRoot().

Referenced by GenerateHtml().

102  {
103  wxString raw_desc;
104 
105  if( m_part->IsRoot() )
106  {
107  raw_desc = m_part->GetDescription();
108  }
109  else
110  {
111  LIB_PART* root = m_part->GetPart();
112 
113  for( size_t i = 0; i < root->GetAliasCount(); ++i )
114  {
115  LIB_ALIAS* alias = root->GetAlias( i );
116 
117  if( alias && !alias->GetDescription().empty() )
118  {
119  raw_desc = alias->GetDescription();
120  break;
121  }
122  }
123  }
124 
125  m_html.Replace( "__DESC__", wxString::Format( DescFormat, EscapedHTML( raw_desc ) ) );
126  }
Part library alias object definition.
LIB_ALIAS * GetAlias(size_t aIndex)
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
size_t GetAliasCount() const
bool IsRoot() const
static const wxString DescFormat
wxString GetDescription() const
Class LIB_PART defines a library part object.
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
LIB_ALIAS const * m_part
void ALIAS_INFO_GENERATOR::SetHtmlFieldTable ( )
inlineprotected

Definition at line 167 of file generate_alias_info.cpp.

References LIB_PART::GetFields(), GetHtmlFieldRow(), and LIB_ALIAS::GetPart().

Referenced by GenerateHtml().

168  {
169  wxString fieldtable;
170  LIB_FIELDS fields;
171  m_part->GetPart()->GetFields( fields );
172 
173  for( auto const & field: fields )
174  {
175  fieldtable += GetHtmlFieldRow( field );
176  }
177 
178  m_html.Replace( "__FIELDS__", fieldtable );
179  }
wxString GetHtmlFieldRow(LIB_FIELD const &aField)
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:261
LIB_ALIAS const * m_part
void GetFields(LIB_FIELDS &aList)
Function GetFields returns a list of fields withing this part.
void ALIAS_INFO_GENERATOR::SetHtmlKeywords ( )
inlineprotected

Definition at line 129 of file generate_alias_info.cpp.

References EscapedHTML(), Format(), LIB_ALIAS::GetKeyWords(), and KeywordsFormat.

Referenced by GenerateHtml().

130  {
131  wxString keywords = m_part->GetKeyWords();
132 
133  if( keywords.empty() )
134  m_html.Replace( "__KEY__", wxEmptyString );
135  else
136  m_html.Replace( "__KEY__",
137  wxString::Format( KeywordsFormat, EscapedHTML( keywords ) ) );
138  }
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
static const wxString KeywordsFormat
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString GetKeyWords() const
LIB_ALIAS const * m_part
void ALIAS_INFO_GENERATOR::SetHtmlName ( )
inlineprotected

Definition at line 79 of file generate_alias_info.cpp.

References EscapedHTML(), and LIB_ALIAS::GetName().

Referenced by GenerateHtml().

80  {
81  m_html.Replace( "__NAME__", EscapedHTML( m_part->GetName() ) );
82  }
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
const wxString & GetName() const
LIB_ALIAS const * m_part

Member Data Documentation

wxString ALIAS_INFO_GENERATOR::m_html
private

Definition at line 47 of file generate_alias_info.cpp.

Referenced by GetHtml().

LIB_ALIAS const* ALIAS_INFO_GENERATOR::m_part
private

Definition at line 48 of file generate_alias_info.cpp.

int ALIAS_INFO_GENERATOR::m_unit
private

Definition at line 49 of file generate_alias_info.cpp.


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