KiCad PCB EDA Suite
config_params.h File Reference
#include <set>
#include <limits>
#include <wx/confbase.h>
#include <wx/fileconf.h>
#include <boost/ptr_container/ptr_vector.hpp>
#include <gal/color4d.h>

Go to the source code of this file.

Classes

class  PARAM_CFG
 PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam, which are implemented by a number of derived classes, and these function's doxygen comments are inherited also. More...
 
class  PARAM_CFG_INT
 Configuration parameter - Integer Class. More...
 
class  PARAM_CFG_INT_WITH_SCALE
 Configuration parameter - Integer Class with unit conversion. More...
 
class  PARAM_CFG_DOUBLE
 Configuration parameter - Double Precision Class. More...
 
class  PARAM_CFG_BOOL
 Configuration parameter - Boolean Class. More...
 
class  PARAM_CFG_WXSTRING
 Configuration parameter - wxString Class. More...
 
class  PARAM_CFG_WXSTRING_SET
 Configuration parameter - std::set<wxString> More...
 
class  PARAM_CFG_FILENAME
 Configuration parameter - PARAM_CFG_FILENAME Class Same as PARAM_CFG_WXSTRING, but stores "\" as "/". More...
 
class  PARAM_CFG_LIBNAME_LIST
 

Enumerations

enum  paramcfg_id {
  PARAM_INT, PARAM_INT_WITH_SCALE, PARAM_DOUBLE, PARAM_BOOL,
  PARAM_LIBNAME_LIST, PARAM_WXSTRING, PARAM_WXSTRING_SET, PARAM_FILENAME,
  PARAM_COMMAND_ERASE, PARAM_LAYERS, PARAM_TRACKWIDTHS, PARAM_VIADIMENSIONS,
  PARAM_DIFFPAIRDIMENSIONS, PARAM_NETCLASSES, PARAM_SEVERITIES
}
 Type of parameter in the configuration file. More...
 

Functions

void ConfigBaseWriteDouble (wxConfigBase *aConfig, const wxString &aKey, double aValue)
 Function ConfigBaseWriteDouble This is a helper function to write doubles in config We cannot use wxConfigBase->Write for a double, because this function uses a format with very few digits in mantissa, and truncation issues are frequent. More...
 
void wxConfigSaveSetups (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
 Function wxConfigSaveSetups writes aList of PARAM_CFG to save configuration values to aCfg. More...
 
void wxConfigSaveParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Function wxConfigSaveParams writes aList of PARAM_CFG to save configuration values to aCfg. More...
 
void wxConfigLoadSetups (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
 Function wxConfigLoadSetups uses aList of PARAM_CFG to load configuration values from aCfg. More...
 
void wxConfigLoadParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Function wxConfigLoadParams uses aList of PARAM_CFG to load configuration values from aCfg. More...
 

Enumeration Type Documentation

◆ paramcfg_id

Type of parameter in the configuration file.

Enumerator
PARAM_INT 
PARAM_INT_WITH_SCALE 
PARAM_DOUBLE 
PARAM_BOOL 
PARAM_LIBNAME_LIST 
PARAM_WXSTRING 
PARAM_WXSTRING_SET 
PARAM_FILENAME 
PARAM_COMMAND_ERASE 
PARAM_LAYERS 
PARAM_TRACKWIDTHS 
PARAM_VIADIMENSIONS 
PARAM_DIFFPAIRDIMENSIONS 
PARAM_NETCLASSES 
PARAM_SEVERITIES 

Definition at line 53 of file config_params.h.

Function Documentation

◆ ConfigBaseWriteDouble()

void ConfigBaseWriteDouble ( wxConfigBase *  aConfig,
const wxString &  aKey,
double  aValue 
)

Function ConfigBaseWriteDouble This is a helper function to write doubles in config We cannot use wxConfigBase->Write for a double, because this function uses a format with very few digits in mantissa, and truncation issues are frequent.

We use here a better floating format.

Definition at line 119 of file config_params.cpp.

120 {
121  // Use a single strategy, regardless of wx version.
122  // Want C locale float string.
123 
124  LOCALE_IO toggle;
125  wxString tnumber = wxString::Format( wxT( "%.16g" ), aValue );
126 
127  aConfig->Write( aKey, tnumber );
128 }
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
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:201

References Format().

Referenced by PARAM_CFG_INT_WITH_SCALE::SaveParam(), and PARAM_CFG_DOUBLE::SaveParam().

◆ wxConfigLoadParams()

void wxConfigLoadParams ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList,
const wxString &  aGroup 
)

Function wxConfigLoadParams uses aList of PARAM_CFG to load configuration values from aCfg.

Only elements whose m_Setup field is false will be loaded.

Parameters
aCfgwhere to load from.
aListholds some configuration parameters, not all of which will necessarily be loaded.
aGroupindicates in which group the value should be saved, unless the PARAM_CFG provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 35 of file config_params.cpp.

37 {
38  wxASSERT( aCfg );
39 
40  for( PARAM_CFG* param : aList )
41  {
42  if( !!param->m_Group )
43  aCfg->SetPath( param->m_Group );
44  else
45  aCfg->SetPath( aGroup );
46 
47  if( param->m_Setup )
48  continue;
49 
50  param->ReadParam( aCfg );
51  }
52 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:81

◆ wxConfigLoadSetups()

void wxConfigLoadSetups ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList 
)

Function wxConfigLoadSetups uses aList of PARAM_CFG to load configuration values from aCfg.

Only elements whose m_Setup field is true will be loaded.

Parameters
aCfgwhere to load from.
aListholds some configuration parameters, not all of which will necessarily be loaded.

Definition at line 55 of file config_params.cpp.

56 {
57  wxASSERT( aCfg );
58 
59  for( PARAM_CFG* param : aList )
60  {
61  if( !param->m_Setup )
62  continue;
63 
64  param->ReadParam( aCfg );
65  }
66 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:81

Referenced by ADVANCED_CFG::loadSettings().

◆ wxConfigSaveParams()

void wxConfigSaveParams ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList,
const wxString &  aGroup 
)

Function wxConfigSaveParams writes aList of PARAM_CFG to save configuration values to aCfg.

Only elements with m_Setup set false will be saved, hence the function name.

Parameters
aCfgwhere to save
aListholds some configuration parameters, not all of which will necessarily be saved.
aGroupindicates in which group the value should be saved, unless the PARAM_CFG provides its own group, in which case it will take precedence. aGroup may be empty.

Definition at line 69 of file config_params.cpp.

71 {
72  wxASSERT( aCfg );
73 
74  for( PARAM_CFG* param : aList )
75  {
76  if( !!param->m_Group )
77  aCfg->SetPath( param->m_Group );
78  else
79  aCfg->SetPath( aGroup );
80 
81  if( param->m_Setup )
82  continue;
83 
84  if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
85  {
86  if( !!param->m_Ident )
87  aCfg->DeleteGroup( param->m_Ident );
88  }
89  else
90  {
91  param->SaveParam( aCfg );
92  }
93  }
94 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:81

References PARAM_COMMAND_ERASE.

◆ wxConfigSaveSetups()

void wxConfigSaveSetups ( wxConfigBase *  aCfg,
const std::vector< PARAM_CFG * > &  aList 
)

Function wxConfigSaveSetups writes aList of PARAM_CFG to save configuration values to aCfg.

Only elements with m_Setup set true will be saved, hence the function name.

Parameters
aCfgwhere to save
aListholds some configuration parameters, not all of which will necessarily be saved.

Definition at line 97 of file config_params.cpp.

98 {
99  wxASSERT( aCfg );
100 
101  for( PARAM_CFG* param : aList )
102  {
103  if( !param->m_Setup )
104  continue;
105 
106  if( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
107  {
108  if( !!param->m_Ident )
109  aCfg->DeleteGroup( param->m_Ident );
110  }
111  else
112  {
113  param->SaveParam( aCfg );
114  }
115  }
116 }
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:81

References PARAM_COMMAND_ERASE.