KiCad PCB EDA Suite
macros.h File Reference

This file contains miscellaneous commonly used macros and functions. More...

#include <wx/string.h>

Go to the source code of this file.

Macros

#define KI_HAS_ATTRIBUTE(x)   0
 
#define KI_HAS_CPP_ATTRIBUTE(x)   0
 
#define KI_FALLTHROUGH   ( ( void ) 0 )
 The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from one to the next. More...
 
#define TO_UTF8(wxstring)   ( (const char*) (wxstring).utf8_str() )
 Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes. More...
 
#define TO_STR2(x)   #x
 Stringifies the given parameter by placing in quotes. More...
 
#define TO_STR(x)   TO_STR2(x)
 

Functions

static wxString FROM_UTF8 (const char *cstring)
 Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes. More...
 

Detailed Description

This file contains miscellaneous commonly used macros and functions.

Definition in file macros.h.

Macro Definition Documentation

◆ KI_FALLTHROUGH

#define KI_FALLTHROUGH   ( ( void ) 0 )

The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from one to the next.

It must be followed by a ";".

Sample code: switch( a ) { case 1: // Some code KI_FALLTHROUGH;

case 2: // More code break; }

Definition at line 83 of file macros.h.

◆ KI_HAS_ATTRIBUTE

#define KI_HAS_ATTRIBUTE (   x)    0

Definition at line 39 of file macros.h.

◆ KI_HAS_CPP_ATTRIBUTE

#define KI_HAS_CPP_ATTRIBUTE (   x)    0

Definition at line 46 of file macros.h.

◆ TO_STR

#define TO_STR (   x)    TO_STR2(x)

Definition at line 105 of file macros.h.

◆ TO_STR2

#define TO_STR2 (   x)    #x

Stringifies the given parameter by placing in quotes.

Parameters
cstringSTRING (no spaces)
Returns
"STRING"

Definition at line 104 of file macros.h.

◆ TO_UTF8

#define TO_UTF8 (   wxstring)    ( (const char*) (wxstring).utf8_str() )

Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.

wxstring is a wxString, not a wxT() or _(). The scope of the return value is very limited and volatile, but can be used with printf() style functions well.

Note
Trying to convert it to a function is tricky because of the type of the parameter!

Definition at line 96 of file macros.h.

Function Documentation

◆ FROM_UTF8()

static wxString FROM_UTF8 ( const char *  cstring)
inlinestatic

Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.

Definition at line 110 of file macros.h.

111 {
112  wxString line = wxString::FromUTF8( cstring );
113 
114  if( line.IsEmpty() ) // happens when cstring is not a valid UTF8 sequence
115  line = wxConvCurrent->cMB2WC( cstring ); // try to use locale conversion
116 
117  return line;
118 }

Referenced by DXF_IMPORT_PLUGIN::addLinetype(), SCH_REFERENCE::Annotate(), SCH_EDITOR_CONTROL::AssignFootprints(), CVPCB_MAINFRAME::buildEquivalenceList(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), detect_file_type(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportVRML_File(), GPCB_PLUGIN::FootprintEnumerate(), LEGACY_PLUGIN::FootprintEnumerate(), EAGLE_PLUGIN::FootprintEnumerate(), GERBER_JOBFILE_READER::formatStringFromJSON(), DSN::SPECCTRA_DB::FromSESSION(), GENDRILL_WRITER_BASE::genDrillMapFile(), SEXPR::PARSER::GetFileContents(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), GetIllegalFileNameWxChars(), BACK_ANNOTATE::getPcbModulesFromString(), NETLIST_READER::GuessNetlistFileType(), EDA_3D_CANVAS::initializeOpenGL(), CMP_READER::Load(), LEGACY_NETLIST_READER::loadComponent(), LEGACY_PLUGIN::loadDIMENSION(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), EAGLE_PLUGIN::loadElements(), LEGACY_PLUGIN::loadFOOTPRINT(), LEGACY_NETLIST_READER::loadFootprintFilters(), EAGLE_PLUGIN::loadLayerDefs(), LEGACY_NETLIST_READER::loadNet(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), EAGLE_PLUGIN::loadPlain(), LEGACY_PLUGIN::loadSETUP(), LEGACY_PLUGIN::loadSHEET(), SCH_LEGACY_PLUGIN::loadText(), main(), EAGLE_PLUGIN::makeFootprint(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), APP_SINGLE_TOP::OnInit(), APP_TEST::OnInit(), APP_TEST::OnRun(), APP_SINGLE_TOP::OnRun(), APP_KICAD::OnRun(), EAGLE_PLUGIN::orientFPText(), EAGLE_PLUGIN::packageText(), PCB_PLOT_PARAMS_PARSER::Parse(), TEMPLATE_FIELDNAME::Parse(), X2_ATTRIBUTE::ParseAttribCmd(), KICAD_NETLIST_PARSER::parseComponent(), PCB_PARSER::parseLayer(), KICAD_NETLIST_PARSER::parseLibPartList(), KICAD_NETLIST_PARSER::parseNet(), parseQuotedString(), PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr(), parseUnquotedString(), pcbnewRunPythonMethodWithReturnedString(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), PyArrayStringToWx(), PyStringToWx(), GERBER_FILE_IMAGE::ReadApertureMacro(), ReadDelimitedText(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), REPORTER::Report(), PANEL_EESCHEMA_TEMPLATE_FIELDNAMES::TransferDataFromWindow(), DIALOG_FP_PLUGIN_OPTIONS::TransferDataToWindow(), EAGLE_PLUGIN::transferPad(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), and DS_DATA_MODEL_STRINGIO::~DS_DATA_MODEL_STRINGIO().