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
 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 object for integers. More...
 
class  PARAM_CFG_INT_WITH_SCALE
 Configuration for integers with unit conversion. More...
 
class  PARAM_CFG_DOUBLE
 Configuration object for double precision floating point numbers. More...
 
class  PARAM_CFG_BOOL
 Configuration object for booleans. More...
 
class  PARAM_CFG_WXSTRING
 Configuration object for wxString objects. More...
 
class  PARAM_CFG_WXSTRING_SET
 Configuration object for a set of wxString objects. More...
 
class  PARAM_CFG_FILENAME
 Configuration object for a file name object. 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)
 A helper function to write doubles in configuration file. More...
 
void wxConfigSaveSetups (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
 Writes aList of PARAM_CFG objects to aCfg. More...
 
void wxConfigSaveParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Write aList of PARAM_CFG objects aCfg. More...
 
void wxConfigLoadSetups (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList)
 Use aList of PARAM_CFG object to load configuration values from aCfg. More...
 
void wxConfigLoadParams (wxConfigBase *aCfg, const std::vector< PARAM_CFG * > &aList, const wxString &aGroup)
 Use aList of PARAM_CFG objects 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 54 of file config_params.h.

Function Documentation

◆ ConfigBaseWriteDouble()

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

A helper function to write doubles in configuration file.

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.

Note
Everything in this file is deprecated, it only remains because advanced_config depends on it for the moment.

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: locale_io.h:40
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

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 
)

Use aList of PARAM_CFG objects 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 }
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:81

◆ wxConfigLoadSetups()

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

Use aList of PARAM_CFG object 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 }
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:81

Referenced by ADVANCED_CFG::loadSettings().

◆ wxConfigSaveParams()

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

Write aList of PARAM_CFG objects 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 }
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:81

References PARAM_COMMAND_ERASE.

◆ wxConfigSaveSetups()

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

Writes aList of PARAM_CFG objects 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 }
A base class which establishes the interface functions ReadParam and SaveParam, which are implemented...
Definition: config_params.h:81

References PARAM_COMMAND_ERASE.