KiCad PCB EDA Suite
PARAM_CFG_FIELDNAMES Class Reference

#include <eeschema_config.h>

Inheritance diagram for PARAM_CFG_FIELDNAMES:
PARAM_CFG

Public Member Functions

 PARAM_CFG_FIELDNAMES (TEMPLATES *ptparam, const wxChar *group=nullptr)
 
void ReadParam (wxConfigBase *aConfig) const override
 Function ReadParam reads the value of the parameter stored in aConfig. More...
 
void SaveParam (wxConfigBase *aConfig) const override
 Function SaveParam saves the value of the parameter stored in aConfig. More...
 

Public Attributes

wxString m_Ident
 Keyword in config data. More...
 
paramcfg_id m_Type
 Type of parameter. More...
 
wxString m_Group
 Group name (this is like a path in the config data) More...
 
bool m_Setup
 Install or Project based parameter, true == install. More...
 
wxString m_Ident_legacy
 

Protected Attributes

TEMPLATESm_Pt_param
 Pointer to the parameter value. More...
 

Detailed Description

Definition at line 35 of file eeschema_config.h.

Constructor & Destructor Documentation

◆ PARAM_CFG_FIELDNAMES()

PARAM_CFG_FIELDNAMES::PARAM_CFG_FIELDNAMES ( TEMPLATES ptparam,
const wxChar *  group = nullptr 
)

Definition at line 56 of file eeschema_config.cpp.

56  :
57  PARAM_CFG( wxEmptyString, PARAM_SEVERITIES, group )
58 {
59  m_Pt_param = ptparam;
60 }
PARAM_CFG(const wxString &ident, const paramcfg_id type, const wxChar *group=NULL, const wxString &legacy_ident=wxEmptyString)
TEMPLATES * m_Pt_param
Pointer to the parameter value.

References m_Pt_param.

Member Function Documentation

◆ ReadParam()

void PARAM_CFG_FIELDNAMES::ReadParam ( wxConfigBase *  aConfig) const
overridevirtual

Function ReadParam reads the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that holds the parameter

Reimplemented from PARAM_CFG.

Definition at line 62 of file eeschema_config.cpp.

63 {
64  if( !m_Pt_param || !aConfig )
65  return;
66 
67  wxString templateFieldNames = aConfig->Read( FieldNameTemplatesKey, wxEmptyString );
68 
69  if( !templateFieldNames.IsEmpty() )
70  {
71  TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
72 
73  try
74  {
75  m_Pt_param->Parse( &lexer, false );
76  }
77  catch( const IO_ERROR& )
78  {
79  // @todo show error msg
80  }
81  }
82 }
void Parse(TEMPLATE_FIELDNAMES_LEXER *in, bool aGlobal)
Function Parse fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_...
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:95
#define FieldNameTemplatesKey
TEMPLATES * m_Pt_param
Pointer to the parameter value.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References FieldNameTemplatesKey, m_Pt_param, TEMPLATES::Parse(), and TO_UTF8.

◆ SaveParam()

void PARAM_CFG_FIELDNAMES::SaveParam ( wxConfigBase *  aConfig) const
overridevirtual

Function SaveParam saves the value of the parameter stored in aConfig.

Parameters
aConfig= the wxConfigBase that can store the parameter

Reimplemented from PARAM_CFG.

Definition at line 84 of file eeschema_config.cpp.

85 {
86  if( !m_Pt_param || !aConfig )
87  return;
88 
90  m_Pt_param->Format( &sf, 0, false );
91 
92  wxString record = FROM_UTF8( sf.GetString().c_str() );
93  record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
94  record.Replace( wxT(" "), wxT(" "), true ); // double space to single
95 
96  aConfig->Write( FieldNameTemplatesKey, record );
97 }
void Format(OUTPUTFORMATTER *out, int nestLevel, bool aGlobal) const
Function Format serializes this object out as text into the given OUTPUTFORMATTER.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:109
#define FieldNameTemplatesKey
const std::string & GetString()
Definition: richio.h:476
TEMPLATES * m_Pt_param
Pointer to the parameter value.
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:446

References FieldNameTemplatesKey, TEMPLATES::Format(), FROM_UTF8(), STRING_FORMATTER::GetString(), and m_Pt_param.

Member Data Documentation

◆ m_Group

wxString PARAM_CFG::m_Group
inherited

Group name (this is like a path in the config data)

Definition at line 90 of file config_params.h.

Referenced by PARAM_CFG::PARAM_CFG().

◆ m_Ident

◆ m_Ident_legacy

wxString PARAM_CFG::m_Ident_legacy
inherited

◆ m_Pt_param

TEMPLATES* PARAM_CFG_FIELDNAMES::m_Pt_param
protected

Pointer to the parameter value.

Definition at line 38 of file eeschema_config.h.

Referenced by PARAM_CFG_FIELDNAMES(), ReadParam(), and SaveParam().

◆ m_Setup

◆ m_Type

paramcfg_id PARAM_CFG::m_Type
inherited

Type of parameter.

Definition at line 89 of file config_params.h.

Referenced by dumpParamCfg(), PARAM_CFG::PARAM_CFG(), and PARAM_CFG_INT_WITH_SCALE::PARAM_CFG_INT_WITH_SCALE().


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