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 132 of file generate_alias_info.cpp.

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

Referenced by SetHtmlFieldTable().

133  {
134  wxString name = aField.GetName();
135  wxString text = aField.GetFullText( m_unit > 0 ? m_unit : 1 );
136  wxString fieldhtml = FieldFormat;
137 
138  fieldhtml.Replace( "__NAME__", EscapedHTML( name ) );
139 
140  switch( aField.GetId() )
141  {
142  case DATASHEET:
143  {
144  wxString datasheetlink = DatasheetLinkFormat;
145  datasheetlink.Replace( "__VALUE__", EscapedHTML( text ) );
146  fieldhtml.Replace( "__VALUE__", datasheetlink );
147  }
148  break;
149 
150  default:
151  fieldhtml.Replace( "__VALUE__", EscapedHTML( text ) );
152  }
153 
154  return fieldhtml;
155  }
name of datasheet
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
const char * name
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::GetAlias(), LIB_ALIAS::GetDescription(), LIB_PART::GetName(), LIB_ALIAS::GetPart(), and LIB_ALIAS::IsRoot().

Referenced by GenerateHtml().

86  {
87  if( m_part->IsRoot() )
88  {
89  m_html.Replace( "__ALIASOF__", wxEmptyString );
90  }
91  else
92  {
93  wxString root_name = _( "Unknown" );
94  wxString root_desc = "";
95 
96  LIB_PART* root = m_part->GetPart();
97  LIB_ALIAS* root_alias = root ? root->GetAlias( 0 ) : nullptr;
98 
99  if( root )
100  root_name = root->GetName();
101 
102  if( root_alias )
103  root_desc = root_alias->GetDescription();
104 
105  m_html.Replace(
106  "__ALIASOF__", wxString::Format(
107  AliasOfFormat, EscapedHTML( root_name ), EscapedHTML( root_desc ) ) );
108  }
109  }
Part library alias object definition.
LIB_ALIAS * GetAlias(size_t aIndex)
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
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::SetHtmlDesc ( )
inlineprotected

Definition at line 112 of file generate_alias_info.cpp.

References DescFormat, EscapedHTML(), Format(), and LIB_ALIAS::GetDescription().

Referenced by GenerateHtml().

113  {
114  wxString raw_desc = m_part->GetDescription();
115 
116  m_html.Replace( "__DESC__", wxString::Format( DescFormat, EscapedHTML( raw_desc ) ) );
117  }
wxString EscapedHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
Definition: string.cpp:170
static const wxString DescFormat
wxString GetDescription() const
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 158 of file generate_alias_info.cpp.

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

Referenced by GenerateHtml().

159  {
160  wxString fieldtable;
161  LIB_FIELDS fields;
162  m_part->GetPart()->GetFields( fields );
163 
164  for( auto const & field: fields )
165  {
166  fieldtable += GetHtmlFieldRow( field );
167  }
168 
169  m_html.Replace( "__FIELDS__", fieldtable );
170  }
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 120 of file generate_alias_info.cpp.

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

Referenced by GenerateHtml().

121  {
122  wxString keywords = m_part->GetKeyWords();
123 
124  if( keywords.empty() )
125  m_html.Replace( "__KEY__", wxEmptyString );
126  else
127  m_html.Replace( "__KEY__",
128  wxString::Format( KeywordsFormat, EscapedHTML( keywords ) ) );
129  }
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: