KiCad PCB EDA Suite
Loading...
Searching...
No Matches
string_utils.h File Reference
#include <string>
#include <vector>
#include <wx/string.h>
#include <wx/filename.h>
#include <kicommon.h>

Go to the source code of this file.

Classes

struct  rsort_wxString
 A helper for sorting strings from the rear. More...
 

Macros

#define TO_UTF8(wxstring)   ( (const char*) ( wxstring ).utf8_str() )
 Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
 

Enumerations

enum  ESCAPE_CONTEXT {
  CTX_NETNAME , CTX_LIBID , CTX_LEGACY_LIBID , CTX_IPC ,
  CTX_QUOTED_STR , CTX_JS_STR , CTX_LINE , CTX_CSV ,
  CTX_FILENAME , CTX_NO_SPACE
}
 Escape/Unescape routines to safely encode reserved-characters in various contexts. More...
 

Functions

void ConvertMarkdown2Html (const wxString &aMarkdownInput, wxString &aHtmlOutput)
 
KICOMMON_API wxString ConvertToNewOverbarNotation (const wxString &aOldStr)
 Convert the old ~...~ overbar notation to the new ~{...} one.
 
KICOMMON_API bool ConvertSmartQuotesAndDashes (wxString *aString)
 Convert curly quotes and em/en dashes to straight quotes and dashes.
 
KICOMMON_API wxString EscapeString (const wxString &aSource, ESCAPE_CONTEXT aContext)
 The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are: (a) not legal in filenames (b) used as control characters in LIB_IDs (c) used to delineate hierarchical paths.
 
KICOMMON_API wxString UnescapeString (const wxString &aSource)
 
KICOMMON_API wxString PrettyPrintForMenu (const wxString &aString)
 Remove markup (such as overbar or subscript) that we can't render to menu items.
 
KICOMMON_API wxString TitleCaps (const wxString &aString)
 Capitalize the first letter in each word.
 
KICOMMON_API int ReadDelimitedText (char *aDest, const char *aSource, int aDestSize)
 Copy bytes from aSource delimited string segment to aDest buffer.
 
KICOMMON_API int ReadDelimitedText (wxString *aDest, const char *aSource)
 Copy bytes from aSource delimited string segment to aDest wxString.
 
KICOMMON_API std::string EscapedUTF8 (const wxString &aString)
 Return an 8 bit UTF8 string given aString in Unicode form.
 
KICOMMON_API wxString EscapeHTML (const wxString &aString)
 Return a new wxString escaped for embedding in HTML.
 
KICOMMON_API wxString UnescapeHTML (const wxString &aString)
 Return a new wxString unescaped from HTML format.
 
KICOMMON_API wxString RemoveHTMLTags (const wxString &aInput)
 Removes HTML tags from a string.
 
KICOMMON_API wxString LinkifyHTML (wxString aStr)
 Wraps links in HTML tags.
 
KICOMMON_API char * GetLine (FILE *aFile, char *Line, int *LineNum=nullptr, int SizeLine=255)
 Read one line line from aFile.
 
KICOMMON_API bool NoPrintableChars (const wxString &aString)
 Return true if the string is empty or contains only whitespace.
 
KICOMMON_API int PrintableCharCount (const wxString &aString)
 Return the number of printable (ie: non-formatting) chars.
 
KICOMMON_API char * StrPurge (char *text)
 Remove leading and training spaces, tabs and end of line chars in text.
 
KICOMMON_API wxString GetISO8601CurrentDateTime ()
 
KICOMMON_API int StrNumCmp (const wxString &aString1, const wxString &aString2, bool aIgnoreCase=false)
 Compare two strings with alphanumerical content.
 
KICOMMON_API bool WildCompareString (const wxString &pattern, const wxString &string_to_tst, bool case_sensitive=true)
 Compare a string against wild card (* and ?) pattern using the usual rules.
 
KICOMMON_API int ValueStringCompare (const wxString &strFWord, const wxString &strSWord)
 Compare strings like the strcmp function but handle numbers and modifiers within the string text correctly for sorting.
 
KICOMMON_API int SplitString (const wxString &strToSplit, wxString *strBeginning, wxString *strDigits, wxString *strEnd)
 Break a string into three parts: he alphabetic preamble, the numeric part, and any alphabetic ending.
 
KICOMMON_API int GetTrailingInt (const wxString &aStr)
 Gets the trailing int, if any, from a string.
 
KICOMMON_API wxString GetIllegalFileNameWxChars ()
 
KICOMMON_API bool ReplaceIllegalFileNameChars (std::string *aName, int aReplaceChar=0)
 Checks aName for illegal file name characters.
 
KICOMMON_API bool ReplaceIllegalFileNameChars (wxString &aName, int aReplaceChar=0)
 
static std::vector< std::string > split (const std::string &aStr, const std::string &aDelim)
 Split the input string into a vector of output strings.
 
void AccumulateDescription (wxString &aDesc, const wxString &aItem)
 Utility to build comma separated lists in messages.
 
KICOMMON_API void wxStringSplit (const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
 Split aString to a string list separated at aSplitter.
 
KICOMMON_API void StripTrailingZeros (wxString &aStringValue, unsigned aTrailingZeroAllowed=1)
 Remove trailing zeros from a string containing a converted float number.
 
KICOMMON_API std::string UIDouble2Str (double aValue)
 Print a float number without using scientific notation and no trailing 0 We want to avoid scientific notation in S-expr files (not easy to read) for floating numbers.
 
KICOMMON_API std::string FormatDouble2Str (double aValue)
 Print a float number without using scientific notation and no trailing 0 This function is intended in uses to write to file, it ignores locale.
 
KICOMMON_API wxString From_UTF8 (const std::string &aString)
 Convert an expected UTF8 encoded std::string to a wxString.
 
KICOMMON_API wxString From_UTF8 (const char *cstring)
 

Macro Definition Documentation

◆ 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 391 of file string_utils.h.

Enumeration Type Documentation

◆ ESCAPE_CONTEXT

Escape/Unescape routines to safely encode reserved-characters in various contexts.

Enumerator
CTX_NETNAME 
CTX_LIBID 
CTX_LEGACY_LIBID 
CTX_IPC 
CTX_QUOTED_STR 
CTX_JS_STR 
CTX_LINE 
CTX_CSV 
CTX_FILENAME 
CTX_NO_SPACE 

Definition at line 51 of file string_utils.h.

Function Documentation

◆ AccumulateDescription()

void AccumulateDescription ( wxString &  aDesc,
const wxString &  aItem 
)
inline

Utility to build comma separated lists in messages.

Definition at line 336 of file string_utils.h.

Referenced by ZONE::GetMsgPanelInfo().

◆ ConvertMarkdown2Html()

◆ ConvertSmartQuotesAndDashes()

KICOMMON_API bool ConvertSmartQuotesAndDashes ( wxString *  aString)

Convert curly quotes and em/en dashes to straight quotes and dashes.

Returns
true if any characters required conversion.

Definition at line 120 of file string_utils.cpp.

Referenced by PANEL_SETUP_RULES::ImportSettingsFrom(), WX_HTML_REPORT_PANEL::onBtnSaveToFile(), SCINTILLA_TRICKS::onCharHook(), and PANEL_SETUP_RULES::TransferDataToWindow().

◆ ConvertToNewOverbarNotation()

◆ EscapedUTF8()

KICOMMON_API std::string EscapedUTF8 ( const wxString &  aString)

Return an 8 bit UTF8 string given aString in Unicode form.

Any double quoted or back slashes are prefixed with a '\' byte and the form of this UTF8 byte string is compatible with function ReadDelimitedText().

Parameters
aStringis the input string to convert.
Returns
the escaped input text, without the wrapping double quotes.

Definition at line 472 of file string_utils.cpp.

References TO_UTF8.

Referenced by SCH_IO_KICAD_LEGACY::Format(), SCH_IO_KICAD_LEGACY_LIB_CACHE::saveField(), SCH_IO_KICAD_LEGACY::saveField(), SCH_IO_KICAD_LEGACY::saveSheet(), and SCH_IO_KICAD_SEXPR::saveSheet().

◆ EscapeHTML()

◆ EscapeString()

KICOMMON_API wxString EscapeString ( const wxString &  aSource,
ESCAPE_CONTEXT  aContext 
)

The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are: (a) not legal in filenames (b) used as control characters in LIB_IDs (c) used to delineate hierarchical paths.

Definition at line 147 of file string_utils.cpp.

References CTX_CSV, CTX_FILENAME, CTX_IPC, CTX_JS_STR, CTX_LEGACY_LIBID, CTX_LIBID, CTX_LINE, CTX_NETNAME, CTX_NO_SPACE, and CTX_QUOTED_STR.

Referenced by AltiumToKiCadLibID(), SCH_LABEL_BASE::cacheShownText(), SCH_EDIT_TOOL::ChangeTextType(), SYMBOL_VIEWER_FRAME::ClickOnLibList(), SYMBOL_VIEWER_FRAME::ClickOnSymbolList(), collectItemsForSyncParts(), SCH_CONNECTION::ConfigureFromLabel(), SCH_IO_MGR::ConvertLibrary(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), CONNECTION_SUBGRAPH::driverName(), EasyEdaToKiCadLibID(), SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), PDF_PLOTTER::EndPlot(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), CONNECTION_GRAPH::ercCheckSingleGlobalLabel(), TEXT_BUTTON_SYMBOL_CHOOSER::escapeLibId(), PCB_IO_EASYEDAPRO_PARSER::fillFootprintModelInfo(), PCB_EDIT_FRAME::FindItemsFromSyncSelection(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), PCB_IO_KICAD_SEXPR::format(), CADSTAR_ARCHIVE_PARSER::generateLibName(), SCH_PIN::GetDefaultNetName(), getLibIdValue(), DIALOG_LIB_NEW_SYMBOL::GetName(), DIALOG_LIB_NEW_SYMBOL::GetParentSymbolName(), FIELDS_GRID_TABLE::GetValue(), SYMBOL_EDIT_FRAME::ImportSymbol(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadField(), SCH_IO_EAGLE::loadInstance(), CADSTAR_SCH_ARCHIVE_LOADER::loadLibPart(), SCH_IO_EAGLE::loadLibrary(), CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary(), LoadSchematic(), SCH_IO_EASYEDAPRO::LoadSchematicFile(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_IO_EAGLE::loadSegments(), SCH_IO_KICAD_SEXPR::LoadSymbol(), netList(), PCB_NET_INSPECTOR_PANEL::onRenameSelectedNet(), NET_SETTINGS::ParseBusGroup(), PCB_IO_EASYEDA_PARSER::ParseToBoardItemContainer(), SYMBOL_EDITOR_CONTROL::RenameSymbol(), SCH_LABEL_BASE::Replace(), SCH_IO_KICAD_SEXPR_LIB_CACHE::saveDcmInfoAsFields(), SCH_LABEL_BASE::SCH_LABEL_BASE(), CVPCB_MAINFRAME::SendComponentSelectionToSch(), SCH_EDIT_FRAME::SendSelectItemsToPcb(), FIELDS_GRID_TABLE::SetValue(), LIB_TABLE_GRID::SetValue(), PGPROPERTY_STRING::StringToValue(), EASYEDAPRO::ToKiCadLibID(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_FIELD_PROPERTIES::TransferDataToWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataToWindow(), DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint(), and FOOTPRINT_LIST_IMPL::WriteCacheToFile().

◆ FormatDouble2Str()

KICOMMON_API std::string FormatDouble2Str ( double  aValue)

◆ From_UTF8() [1/2]

KICOMMON_API wxString From_UTF8 ( const char *  cstring)

Definition at line 1374 of file string_utils.cpp.

Referenced by DXF_IMPORT_PLUGIN::addLinetype(), SCH_REFERENCE::Annotate(), SCH_EDITOR_CONTROL::AssignFootprints(), MARKUP::NODE::asWxString(), CVPCB_MAINFRAME::buildEquivalenceList(), PLACEFILE_GERBER_WRITER::CreatePlaceFile(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS(), CLI::FP_EXPORT_SVG_COMMAND::doPerform(), CLI::JOBSET_RUN_COMMAND::doPerform(), CLI::PCB_DRC_COMMAND::doPerform(), CLI::PCB_EXPORT_3D_COMMAND::doPerform(), CLI::PCB_EXPORT_BASE_COMMAND::doPerform(), CLI::PCB_EXPORT_DRILL_COMMAND::doPerform(), CLI::PCB_EXPORT_DXF_COMMAND::doPerform(), CLI::PCB_EXPORT_GERBERS_COMMAND::doPerform(), CLI::PCB_EXPORT_IPC2581_COMMAND::doPerform(), CLI::PCB_EXPORT_PDF_COMMAND::doPerform(), CLI::PCB_EXPORT_POS_COMMAND::doPerform(), CLI::PCB_EXPORT_SVG_COMMAND::doPerform(), CLI::SCH_ERC_COMMAND::doPerform(), CLI::SCH_EXPORT_BOM_COMMAND::doPerform(), CLI::SCH_EXPORT_NETLIST_COMMAND::doPerform(), CLI::SCH_EXPORT_PLOT_COMMAND::doPerform(), CLI::SYM_EXPORT_SVG_COMMAND::doPerform(), CLI::VERSION_COMMAND::doPerform(), EXCELLON_IMAGE::Execute_EXCELLON_G_Command(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::ExecuteRemoteCommand(), PCB_EDIT_FRAME::Export_IDF3(), EXPORTER_PCB_VRML::ExportVRML_File(), PCB_IO_GEDA::FootprintEnumerate(), PCB_IO_KICAD_LEGACY::FootprintEnumerate(), GERBER_JOBFILE_READER::formatStringFromJSON(), DSN::SPECCTRA_DB::FromSESSION(), GENDRILL_WRITER_BASE::genDrillMapFile(), fontconfig::FONTCONFIG::getFamilyStringByLang(), SEXPR::PARSER::GetFileContents(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), GetIllegalFileNameWxChars(), BACK_ANNOTATE::getPcbModulesFromString(), getToVector3(), NETLIST_READER::GuessNetlistFileType(), PGM_BASE::HandleException(), SCH_EDITOR_CONTROL::IncrementAnnotations(), EDA_3D_CANVAS::initializeOpenGL(), fontconfig::FONTCONFIG::ListFonts(), CMP_READER::Load(), LEGACY_NETLIST_READER::loadComponent(), PCB_IO_KICAD_LEGACY::loadDIMENSION(), SCH_IO_KICAD_LEGACY_LIB_CACHE::loadDocs(), PCB_IO_KICAD_LEGACY::loadFOOTPRINT(), LEGACY_NETLIST_READER::loadFootprintFilters(), LEGACY_NETLIST_READER::loadNet(), PCB_IO_KICAD_LEGACY::loadNETCLASS(), PCB_IO_KICAD_LEGACY::loadNETINFO_ITEM(), PCB_IO_KICAD_LEGACY::loadPAD(), PCB_IO_KICAD_LEGACY::loadPCB_TEXT(), PCB_IO_KICAD_LEGACY::loadSETUP(), PCB_IO_KICAD_LEGACY::loadSHEET(), SCH_IO_KICAD_LEGACY::loadText(), main(), DSN::SPECCTRA_DB::makeTRACK(), DSN::SPECCTRA_DB::makeVIA(), EDA_3D_MODEL_VIEWER::ogl_initialize(), APP_TEST::OnInit(), APP_TEST::OnRun(), PCB_PLOT_PARAMS_PARSER::Parse(), TEMPLATE_FIELDNAME::Parse(), X2_ATTRIBUTE::ParseAttribCmd(), KICAD_NETLIST_PARSER::parseComponent(), PCB_IO_KICAD_SEXPR_PARSER::parseFOOTPRINT_unchecked(), PCB_IO_KICAD_SEXPR_PARSER::parseLayer(), KICAD_NETLIST_PARSER::parseLibPartList(), KICAD_NETLIST_PARSER::parseNet(), parseQuotedString(), PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr(), PCB_IO_KICAD_SEXPR_PARSER::parseRenderCache(), parseUnquotedString(), pcbnewRunPythonMethodWithReturnedString(), CLI::COMMAND::Perform(), CLI::COMMAND::PrintHelp(), printHelp(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), Py2wxString(), GERBER_FILE_IMAGE::ReadApertureMacro(), ReadDelimitedText(), CVPCB_MAINFRAME::readNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateBOMFileFromBoard(), CVPCB_MAINFRAME::refreshAfterSymbolSearch(), REPORTER::Report(), PANEL_TEMPLATE_FIELDNAMES::TransferDataFromWindow(), DIALOG_PLUGIN_OPTIONS::TransferDataToWindow(), FOOTPRINT_EDIT_FRAME::UpdateTitle(), and DS_DATA_MODEL_STRINGIO::~DS_DATA_MODEL_STRINGIO().

◆ From_UTF8() [2/2]

KICOMMON_API wxString From_UTF8 ( const std::string &  aString)

Convert an expected UTF8 encoded std::string to a wxString.

If fails, tray to convert using current locale If still fails, return the initial string (can be already a converted string)

Definition at line 1391 of file string_utils.cpp.

◆ GetIllegalFileNameWxChars()

KICOMMON_API wxString GetIllegalFileNameWxChars ( )
Returns
a wxString object containing the illegal file name characters for all platforms.

Definition at line 1203 of file string_utils.cpp.

References From_UTF8(), and illegalFileNameChars.

Referenced by ReplaceIllegalFileNameChars().

◆ GetISO8601CurrentDateTime()

◆ GetLine()

KICOMMON_API char * GetLine ( FILE *  aFile,
char *  Line,
int *  LineNum = nullptr,
int  SizeLine = 255 
)

Read one line line from aFile.

Returns
a pointer the first useful line read by eliminating blank lines and comments.

Definition at line 714 of file string_utils.cpp.

Referenced by CVPCB_MAINFRAME::buildEquivalenceList().

◆ GetTrailingInt()

KICOMMON_API int GetTrailingInt ( const wxString &  aStr)

Gets the trailing int, if any, from a string.

Parameters
aStrthe string to check.
Returns
the trailing int or 0 if none found.

Definition at line 1179 of file string_utils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), compareFootprintsbyRef(), FOOTPRINT::GetNextPadNumber(), and FOOTPRINT::IncrementReference().

◆ LinkifyHTML()

KICOMMON_API wxString LinkifyHTML ( wxString  aStr)

◆ NoPrintableChars()

KICOMMON_API bool NoPrintableChars ( const wxString &  aString)

Return true if the string is empty or contains only whitespace.

Definition at line 603 of file string_utils.cpp.

Referenced by SCH_DRAWING_TOOLS::createNewText(), DRAWING_TOOL::PlaceText(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ PrettyPrintForMenu()

KICOMMON_API wxString PrettyPrintForMenu ( const wxString &  aString)

Remove markup (such as overbar or subscript) that we can't render to menu items.

◆ PrintableCharCount()

KICOMMON_API int PrintableCharCount ( const wxString &  aString)

Return the number of printable (ie: non-formatting) chars.

Used to approximate rendered text size when speed is more important than accuracy.

Definition at line 615 of file string_utils.cpp.

Referenced by KIGFX::PCB_PAINTER::draw(), and BRDITEMS_PLOTTER::PlotPadNumber().

◆ ReadDelimitedText() [1/2]

KICOMMON_API int ReadDelimitedText ( char *  aDest,
const char *  aSource,
int  aDestSize 
)

Copy bytes from aSource delimited string segment to aDest buffer.

The extracted string will be null terminated even if truncation is necessary because aDestSize was not large enough.

Parameters
aDestis the destination byte buffer.
aSourceis the source bytes as a C string.
aDestSizeis the size of the destination byte buffer.
Returns
the number of bytes read from source, which may be more than the number copied, due to escaping of double quotes and the escape byte itself.
Deprecated:
should use the one which fetches a wxString, below.

Definition at line 423 of file string_utils.cpp.

◆ ReadDelimitedText() [2/2]

KICOMMON_API int ReadDelimitedText ( wxString *  aDest,
const char *  aSource 
)

Copy bytes from aSource delimited string segment to aDest wxString.

Parameters
aDestis the destination wxString.
aSourceis the source C string holding utf8 encoded bytes.
Returns
the number of bytes read from source, which may be more than the number copied, due to escaping of double quotes and the escape byte itself.

Definition at line 378 of file string_utils.cpp.

References From_UTF8().

Referenced by PCB_IO_KICAD_LEGACY::load3D(), PCB_IO_KICAD_LEGACY::loadDIMENSION(), PCB_IO_KICAD_LEGACY::loadMODULE_TEXT(), PCB_IO_KICAD_LEGACY::loadNETCLASS(), PCB_IO_KICAD_LEGACY::loadNETINFO_ITEM(), PCB_IO_KICAD_LEGACY::loadPAD(), PCB_IO_KICAD_LEGACY::loadPCB_TEXT(), PCB_IO_KICAD_LEGACY::loadSHEET(), and PCB_IO_KICAD_LEGACY::loadZONE_CONTAINER().

◆ RemoveHTMLTags()

KICOMMON_API wxString RemoveHTMLTags ( const wxString &  aInput)

Removes HTML tags from a string.

Do not use for filtering potentially malicious inputs and rendering as HTML without escaping.

Definition at line 583 of file string_utils.cpp.

Referenced by convertDescription().

◆ ReplaceIllegalFileNameChars() [1/2]

KICOMMON_API bool ReplaceIllegalFileNameChars ( std::string *  aName,
int  aReplaceChar = 0 
)

Checks aName for illegal file name characters.

The Windows (DOS) file system forbidden characters already include the forbidden file name characters for both Posix and OSX systems. The characters \/?*|"<> are illegal and are replaced with xx where xx the hexadecimal equivalent of the replaced character. This replacement may not be as elegant as using an underscore ('_') or hyphen ('-') but it guarantees that there will be no naming conflicts when fixing footprint library names. however, if aReplaceChar is given, it will replace the illegal chars

Parameters
aNameis a point to a std::string object containing the footprint name to verify.
aReplaceChar(if not 0) is the replacement char.
Returns
true if any characters have been replaced in aName.

Definition at line 1209 of file string_utils.cpp.

References illegalFileNameChars, and StrPrintf().

Referenced by EDEVICE::EDEVICE(), EELEMENT::EELEMENT(), PCB_IO_KICAD_SEXPR::FootprintSave(), PCB_IO_KICAD_LEGACY::loadAllSections(), FABMASTER::loadFootprints(), PCB_IO_EAGLE::loadLibrary(), LP_CACHE::LoadModules(), SCH_IO_EAGLE::loadSheet(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(), and CADSTAR_SCH_ARCHIVE_LOADER::loadSheets().

◆ ReplaceIllegalFileNameChars() [2/2]

KICOMMON_API bool ReplaceIllegalFileNameChars ( wxString &  aName,
int  aReplaceChar = 0 
)

Definition at line 1239 of file string_utils.cpp.

References GetIllegalFileNameWxChars().

◆ split()

static std::vector< std::string > split ( const std::string &  aStr,
const std::string &  aDelim 
)
inlinestatic

Split the input string into a vector of output strings.

Note
Multiple delimiters are considered to be separate records with empty strings
Parameters
aStrInput string with 0 or more delimiters.
aDelimThe string of delimiter. Multiple characters here denote alternate delimiters.
Returns
a vector of strings

Definition at line 310 of file string_utils.h.

Referenced by CompareToBucket::CompareToBucket(), HLBVH_SAH_Evaluator::HLBVH_SAH_Evaluator(), FOOTPRINT_CHOOSER_FRAME::KiwayMailIn(), SCH_IO_ALTIUM::ParseLibFile(), FABMASTER::processText(), and PNS::NODE::rebuildJoint().

◆ SplitString()

KICOMMON_API int SplitString ( const wxString &  strToSplit,
wxString *  strBeginning,
wxString *  strDigits,
wxString *  strEnd 
)

Break a string into three parts: he alphabetic preamble, the numeric part, and any alphabetic ending.

For example C10A is split to C 10 A

Definition at line 1118 of file string_utils.cpp.

Referenced by ValueStringCompare().

◆ StripTrailingZeros()

KICOMMON_API void StripTrailingZeros ( wxString &  aStringValue,
unsigned  aTrailingZeroAllowed = 1 
)

Remove trailing zeros from a string containing a converted float number.

The trailing zeros are removed if the mantissa has more than aTrailingZeroAllowed digits and some trailing zeros.

Definition at line 1292 of file string_utils.cpp.

◆ StrNumCmp()

KICOMMON_API int StrNumCmp ( const wxString &  aString1,
const wxString &  aString2,
bool  aIgnoreCase = false 
)

Compare two strings with alphanumerical content.

This function is equivalent to strncmp() or strncasecmp() if aIgnoreCase is true except that strings containing numbers are compared by their integer value not by their ASCII code. In other words U10 would be greater than U2.

Parameters
aString1A wxString reference to the reference string.
aString2A wxString reference to the comparison string.
aIgnoreCaseUse true to make the comparison case insensitive.
Returns
An integer value of -1 if aString1 is less than aString2, 0 if aString1 is equal to aString2, or 1 if aString1 is greater than aString2.

Definition at line 744 of file string_utils.cpp.

Referenced by REGULATOR_LIST::Add(), BOOST_AUTO_TEST_CASE(), CVPCB_MAINFRAME::BuildLibrariesList(), ChangeArrayCompare(), FIELDS_EDITOR_GRID_DATA_MODEL::cmp(), SCH_PIN_TABLE_DATA_MODEL::compare(), PIN_TABLE_DATA_MODEL::compare(), NETLIST_EXPORTER_ALLEGRO::CompareLibPin(), SCH_SHEET::ComparePageNum(), NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo(), DESIGN_BLOCK_TREE_MODEL_ADAPTER::getDesignBlocks(), FP_TREE_MODEL_ADAPTER::getFootprints(), NETLIST_EXPORTER_XML::makeSymbols(), myCompareFunction(), DIALOG_SIM_MODEL< T >::newParamProperty(), FOOTPRINT::cmp_pads::operator()(), operator<(), SCH_REFERENCE_LIST::sortByReferenceOnly(), sortFPlist(), and sortPinsByNumber().

◆ StrPurge()

KICOMMON_API char * StrPurge ( char *  text)

◆ TitleCaps()

KICOMMON_API wxString TitleCaps ( const wxString &  aString)

Capitalize the first letter in each word.

Definition at line 357 of file string_utils.cpp.

References wxStringSplit().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), and SCH_EDIT_TOOL::editFieldText().

◆ UIDouble2Str()

KICOMMON_API std::string UIDouble2Str ( double  aValue)

Print a float number without using scientific notation and no trailing 0 We want to avoid scientific notation in S-expr files (not easy to read) for floating numbers.

We cannot always just use the g or the f format to print a fp number this helper function uses the f format when needed, or g when f is not well working and then removes trailing 0

Definition at line 1344 of file string_utils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), DIELECTRIC_SUBSTRATE::FormatEpsilonR(), BOARD_STACKUP_ITEM::FormatEpsilonR(), DIELECTRIC_SUBSTRATE::FormatLossTangent(), BOARD_STACKUP_ITEM::FormatLossTangent(), PANEL_SETUP_BOARD_STACKUP::lazyBuildRowUI(), NUMERIC_EVALUATOR::parseSetResult(), and PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard().

◆ UnescapeHTML()

◆ UnescapeString()

KICOMMON_API wxString UnescapeString ( const wxString &  aSource)

Definition at line 273 of file string_utils.cpp.

References UnescapeString().

Referenced by NET_SELECTOR_COMBOPOPUP::Accept(), DIALOG_EDIT_SYMBOLS_LIBID::AddRowToGrid(), NETLIST_EXPORTER_XML::addSymbolFields(), SCH_CONNECTION::AppendInfoToMsgPanel(), APPEARANCE_CONTROLS::buildNetClassMenu(), EDA_TEXT::cacheShownText(), SCH_EDIT_TOOL::ChangeTextType(), SCH_CONNECTION::ConfigureFromLabel(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL(), DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS(), KIGFX::PCB_PAINTER::draw(), GRID_CELL_ESCAPED_TEXT_RENDERER::Draw(), EDA_TEXT::EDA_TEXT(), KIUI::EllipsizeMenuText(), KIUI::EllipsizeStatusText(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckHierSheets(), SCH_EDIT_FRAME::ExecuteRemoteCommand(), findItemsFromSyncSelection(), PCB_EDIT_FRAME::FindItemsFromSyncSelection(), PCB_NET_INSPECTOR_PANEL::formatNetName(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), DESIGN_BLOCK_TREE_MODEL_ADAPTER::GenerateInfo(), NETLIST_EXPORTER_SPICE::GenerateItemPinNetName(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription(), GRID_CELL_ESCAPED_TEXT_RENDERER::GetBestSize(), SCH_PIN::getItemDescription(), SCH_FIELD::GetItemDescription(), SCH_DIRECTIVE_LABEL::GetItemDescription(), SCH_PIN::GetItemDescription(), SCH_FIELD::GetMsgPanelInfo(), SCH_JUNCTION::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), SCH_SYMBOL::GetMsgPanelInfo(), GERBER_DRAW_ITEM::GetMsgPanelInfo(), FOOTPRINT::GetMsgPanelInfo(), PCB_TUNING_PATTERN::GetMsgPanelInfo(), NETINFO_ITEM::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), GetNetNavigatorItemText(), FOOTPRINT_SEARCH_HANDLER::getResultCell(), ZONE_SEARCH_HANDLER::getResultCell(), TEXT_SEARCH_HANDLER::getResultCell(), NETS_SEARCH_HANDLER::getResultCell(), RATSNEST_SEARCH_HANDLER::getResultCell(), LIB_BUFFER::GetSymbolNames(), DIALOG_CHANGE_SYMBOLS::getSymbolReferences(), DIALOG_COPPER_ZONE::getUnescapedNetName(), FIELDS_GRID_TABLE::GetValue(), LIB_TABLE_GRID::GetValue(), LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue(), FP_TREE_SYNCHRONIZING_ADAPTER::GetValue(), GERBVIEW_CONTROL::HighlightControl(), SCH_CONNECTION::IsBusLabel(), DIALOG_CHANGE_SYMBOLS::isMatch(), SYMBOL_EDIT_FRAME::KiwayMailIn(), DIALOG_CHANGE_SYMBOLS::launchMatchIdSymbolBrowser(), DIALOG_CHANGE_SYMBOLS::launchNewIdSymbolBrowser(), PCB_NET_INSPECTOR_PANEL::LIST_ITEM::LIST_ITEM(), SCH_IO_EAGLE::loadInstance(), SIMULATOR_FRAME_UI::loadLegacyWorkbook(), SCH_IO_KICAD_LEGACY_LIB_CACHE::LoadPart(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_FIELD::Matches(), SCH_LABEL_BASE::Matches(), PCB_TEXT::Matches(), PCB_TEXTBOX::Matches(), SCH_CONNECTION::MightBeBusLabel(), PCB_NET_INSPECTOR_PANEL::netFilterMatches(), PCB_NET_INSPECTOR_PANEL::onAddGroup(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), DIALOG_EDIT_SYMBOLS_LIBID::onClickOrphansButton(), APPEARANCE_CONTROLS::OnNetGridRightClick(), PCB_NET_INSPECTOR_PANEL::onRenameSelectedNet(), SCH_IO_KICAD_SEXPR_PARSER::parseProperty(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BRDITEMS_PLOTTER::PlotPadNumber(), DIALOG_CHANGE_SYMBOLS::processSymbols(), FOOTPRINT_LIST_IMPL::ReadCacheFromFile(), NETINFO_LIST::RebuildDisplayNetnames(), NET_SELECTOR_COMBOPOPUP::rebuildList(), SIMULATOR_FRAME_UI::rebuildSignalsList(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), SYMBOL_VIEWER_FRAME::ReCreateSymbolList(), SCH_EDIT_FRAME::RefreshNetNavigator(), LIB_BUFFER::SaveBuffer(), SYMBOL_EDIT_FRAME::SetCurSymbol(), FOOTPRINT_INFO_GENERATOR::SetHtmlAliasOf(), FOOTPRINT_INFO_GENERATOR::SetHtmlDesc(), FOOTPRINT_INFO_GENERATOR::SetHtmlName(), DIALOG_EDIT_SYMBOLS_LIBID::setLibIdByBrowser(), DIALOG_LIB_NEW_SYMBOL::SetName(), NETINFO_ITEM::SetNetname(), SYMBOL_VIEWER_FRAME::SetSelectedLibrary(), NET_SELECTOR::SetSelectedNet(), NET_SELECTOR::SetSelectedNetcode(), SYMBOL_VIEWER_FRAME::SetSelectedSymbol(), FIELDS_GRID_TABLE::SetValue(), PCB_EDIT_FRAME::ShowFindDialog(), SCH_EDIT_FRAME::ShowFindReplaceDialog(), SCH_EDITOR_CONTROL::SimProbe(), ERC_TESTER::TestLibSymbolIssues(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_FIELD_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow(), UnescapeString(), HIGHLIGHT_MENU::update(), SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties(), BOARD_NETLIST_UPDATER::updateComponentPadConnections(), BOARD_NETLIST_UPDATER::updateCopperZoneNets(), SCH_SYMBOL::UpdateFields(), PCB_PROPERTIES_PANEL::updateLists(), ROUTER_TOOL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), SCH_EDIT_FRAME::UpdateNetHighlightStatus(), GERBVIEW_FRAME::updateNetnameListSelectBox(), SCH_EDITOR_CONTROL::updatePastedSymbol(), SYMBOL_VIEWER_FRAME::updatePreviewSymbol(), SCH_SCREEN::UpdateSymbolLinks(), SYMBOL_EDIT_FRAME::UpdateSymbolMsgPanelInfo(), SYMBOL_EDIT_FRAME::UpdateTitle(), ValueStringCompare(), PGPROPERTY_STRING::ValueToString(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ ValueStringCompare()

KICOMMON_API int ValueStringCompare ( const wxString &  strFWord,
const wxString &  strSWord 
)

Compare strings like the strcmp function but handle numbers and modifiers within the string text correctly for sorting.

eg. 1mF > 55uF

Returns
-1 if first string is less than the second, 0 if the strings are equal, or 1 if the first string is greater than the second.

Definition at line 1061 of file string_utils.cpp.

References ApplyModifier(), convertSeparators(), SplitString(), and UnescapeString().

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::cmp(), and PCB_NET_INSPECTOR_PANEL::DATA_MODEL::Compare().

◆ WildCompareString()

KICOMMON_API bool WildCompareString ( const wxString &  pattern,
const wxString &  string_to_tst,
bool  case_sensitive = true 
)

Compare a string against wild card (* and ?) pattern using the usual rules.

Returns
true if pattern matched otherwise false.

Definition at line 826 of file string_utils.cpp.

Referenced by FROM_TO_CACHE::cacheFromToPaths(), LIBEVAL::VALUE::EqualTo(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), FIELDS_EDITOR_GRID_DATA_MODEL::RebuildRows(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ wxStringSplit()

KICOMMON_API void wxStringSplit ( const wxString &  aText,
wxArrayString &  aStrings,
wxChar  aSplitter 
)