KiCad PCB EDA Suite
|
Some useful functions to handle strings. More...
#include <clocale>
#include <cmath>
#include <fmt/core.h>
#include <macros.h>
#include <richio.h>
#include <string_utils.h>
#include <fmt/chrono.h>
Go to the source code of this file.
Functions | |
wxString | ConvertToNewOverbarNotation (const wxString &aOldStr) |
Convert the old ~...~ overbar notation to the new ~{...} one. More... | |
bool | ConvertSmartQuotesAndDashes (wxString *aString) |
Convert curly quotes and em/en dashes to straight quotes and dashes. More... | |
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. More... | |
wxString | UnescapeString (const wxString &aSource) |
wxString | TitleCaps (const wxString &aString) |
Capitalize the first letter in each word. More... | |
int | ReadDelimitedText (wxString *aDest, const char *aSource) |
Copy bytes from aSource delimited string segment to aDest wxString. More... | |
int | ReadDelimitedText (char *aDest, const char *aSource, int aDestSize) |
Copy bytes from aSource delimited string segment to aDest buffer. More... | |
std::string | EscapedUTF8 (const wxString &aString) |
Return an 8 bit UTF8 string given aString in Unicode form. More... | |
wxString | EscapeHTML (const wxString &aString) |
Return a new wxString escaped for embedding in HTML. More... | |
wxString | UnescapeHTML (const wxString &aString) |
Return a new wxString unescaped from HTML format. More... | |
bool | NoPrintableChars (const wxString &aString) |
Return true if the string is empty or contains only whitespace. More... | |
int | PrintableCharCount (const wxString &aString) |
Return the number of printable (ie: non-formatting) chars. More... | |
char * | StrPurge (char *text) |
Remove leading and training spaces, tabs and end of line chars in text. More... | |
char * | GetLine (FILE *File, char *Line, int *LineNum, int SizeLine) |
Read one line line from aFile. More... | |
wxString | GetISO8601CurrentDateTime () |
int | StrNumCmp (const wxString &aString1, const wxString &aString2, bool aIgnoreCase) |
Compare two strings with alphanumerical content. More... | |
bool | WildCompareString (const wxString &pattern, const wxString &string_to_tst, bool case_sensitive) |
Compare a string against wild card (* and ?) pattern using the usual rules. More... | |
bool | ApplyModifier (double &value, const wxString &aString) |
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. More... | |
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. More... | |
int | GetTrailingInt (const wxString &aStr) |
Gets the trailing int, if any, from a string. More... | |
wxString | GetIllegalFileNameWxChars () |
bool | ReplaceIllegalFileNameChars (std::string *aName, int aReplaceChar) |
Checks aName for illegal file name characters. More... | |
bool | ReplaceIllegalFileNameChars (wxString &aName, int aReplaceChar) |
void | wxStringSplit (const wxString &aText, wxArrayString &aStrings, wxChar aSplitter) |
Split aString to a string list separated at aSplitter. More... | |
void | StripTrailingZeros (wxString &aStringValue, unsigned aTrailingZeroAllowed) |
Remove trailing zeros from a string containing a converted float number. More... | |
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. More... | |
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. More... | |
wxString | From_UTF8 (const char *cstring) |
wxString | From_UTF8 (const std::string &aString) |
Convert an expected UTF8 encoded std::string to a wxString. More... | |
Variables | |
static const char | illegalFileNameChars [] = "\\/:\"<>|" |
Illegal file name characters used to ensure file names will be valid on all supported platforms. More... | |
Some useful functions to handle strings.
Definition in file string_utils.cpp.
bool ApplyModifier | ( | double & | value, |
const wxString & | aString | ||
) |
Definition at line 832 of file string_utils.cpp.
Referenced by ValueStringCompare().
bool ConvertSmartQuotesAndDashes | ( | wxString * | aString | ) |
Convert curly quotes and em/en dashes to straight quotes and dashes.
Definition at line 118 of file string_utils.cpp.
Referenced by WX_HTML_REPORT_PANEL::onBtnSaveToFile(), SCINTILLA_TRICKS::onCharHook(), and PANEL_SETUP_RULES::TransferDataToWindow().
wxString ConvertToNewOverbarNotation | ( | const wxString & | aOldStr | ) |
Convert the old ~...~
overbar notation to the new ~{...}
one.
Definition at line 46 of file string_utils.cpp.
Referenced by escapeName(), CADSTAR_ARCHIVE_PARSER::HandleTextOverbar(), SCH_LEGACY_PLUGIN_CACHE::loadField(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), SCH_LEGACY_PLUGIN_CACHE::loadPin(), SCH_LEGACY_PLUGIN::loadSheet(), SCH_LEGACY_PLUGIN::loadText(), SCH_LEGACY_PLUGIN_CACHE::loadText(), NET_SETTINGS::migrateSchema0to1(), SCH_SEXPR_PARSER::parseBusAlias(), PCB_PARSER::parseEDA_TEXT(), SCH_SEXPR_PARSER::parseEDA_TEXT(), PCB_PARSER::parseNETCLASS(), PCB_PARSER::parseNETINFO_ITEM(), PCB_PARSER::parsePAD(), SCH_SEXPR_PARSER::parsePin(), and DRAWING_SHEET_PARSER::parseText().
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().
aString | is the input string to convert. |
Definition at line 470 of file string_utils.cpp.
References TO_UTF8.
Referenced by SCH_LEGACY_PLUGIN::Format(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN::saveField(), SCH_LEGACY_PLUGIN::saveSheet(), and SCH_SEXPR_PLUGIN::saveSheet().
wxString EscapeHTML | ( | const wxString & | aString | ) |
Return a new wxString escaped for embedding in HTML.
Definition at line 511 of file string_utils.cpp.
Referenced by BOARD_INSPECTION_TOOL::DiffFootprint(), EE_INSPECTION_TOOL::DiffSymbol(), DRC_ENGINE::EvalRules(), DRC_ENGINE::EvalZoneConnection(), FOOTPRINT_INFO_GENERATOR::GenerateHtml(), FOOTPRINT_INFO_GENERATOR::GetHtmlFieldRow(), BOARD_INSPECTION_TOOL::InspectClearance(), DRC_ENGINE::ProcessAssertions(), BOARD_INSPECTION_TOOL::reportHeader(), FOOTPRINT_INFO_GENERATOR::SetHtmlAliasOf(), FOOTPRINT_INFO_GENERATOR::SetHtmlDesc(), FOOTPRINT_INFO_GENERATOR::SetHtmlKeywords(), FOOTPRINT_INFO_GENERATOR::SetHtmlName(), and PANEL_PACKAGES_VIEW::setPackageDetails().
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 145 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(), PANEL_SYM_LIB_TABLE::convertLibrary(), CONNECTION_SUBGRAPH::driverName(), EasyEdaToKiCadLibID(), SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), PDF_PLOTTER::EndPlot(), CONNECTION_GRAPH::ercCheckBusToNetConflicts(), TEXT_BUTTON_SYMBOL_CHOOSER::escapeLibId(), PCB_EASYEDAPRO_PARSER::fillFootprintModelInfo(), PCB_EDIT_FRAME::FindItemsFromSyncSelection(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues(), PCB_PLUGIN::format(), CADSTAR_ARCHIVE_PARSER::generateLibName(), SCH_PIN::GetDefaultNetName(), getLibIdValue(), DIALOG_LIB_NEW_SYMBOL::GetName(), DIALOG_LIB_NEW_SYMBOL::GetParentSymbolName(), RENAME_DIALOG::GetSymbolName(), SYMBOL_EDIT_FRAME::ImportSymbol(), SCH_LEGACY_PLUGIN_CACHE::loadField(), SCH_EAGLE_PLUGIN::loadInstance(), CADSTAR_SCH_ARCHIVE_LOADER::loadLibPart(), SCH_EAGLE_PLUGIN::loadLibrary(), CADSTAR_SCH_ARCHIVE_LOADER::loadPartsLibrary(), SCH_EASYEDAPRO_PLUGIN::LoadSchematicFile(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_EAGLE_PLUGIN::loadSegments(), SCH_SEXPR_PLUGIN::LoadSymbol(), netList(), DIALOG_NET_INSPECTOR::onRenameNet(), NET_SETTINGS::ParseBusGroup(), PCB_EASYEDA_PARSER::ParseToBoardItemContainer(), SCH_LABEL_BASE::Replace(), SCH_SEXPR_PLUGIN_CACHE::saveDcmInfoAsFields(), SCH_LABEL_BASE::SCH_LABEL_BASE(), CVPCB_MAINFRAME::SendComponentSelectionToSch(), SCH_EDIT_FRAME::SendSelectItemsToPcb(), FIELDS_GRID_TABLE< T >::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(), and FOOTPRINT_LIST_IMPL::WriteCacheToFile().
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.
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 1128 of file string_utils.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), GBR_TO_PCB_EXPORTER::export_non_copper_item(), GBR_TO_PCB_EXPORTER::export_via(), PCB_PLUGIN::format(), DS_DATA_MODEL_IO::format(), DS_DATA_MODEL_IO::Format(), EDA_TEXT::Format(), STROKE_PARAMS::Format(), BOARD_STACKUP::FormatBoardStackup(), DS_DATA_MODEL_IO::formatCoordinate(), formatFill(), DS_DATA_MODEL_IO::formatRepeatParameters(), PCB_PLUGIN::formatSetup(), PCB_PLUGIN::formatTeardropParameters(), SCH_SEXPR_PLUGIN::saveJunction(), GBR_TO_PCB_EXPORTER::writeCopperLineItem(), GBR_TO_PCB_EXPORTER::writePcbFilledCircle(), GBR_TO_PCB_EXPORTER::writePcbPolygon(), and GBR_TO_PCB_EXPORTER::writePcbZoneItem().
wxString From_UTF8 | ( | const char * | cstring | ) |
Definition at line 1188 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::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_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(), GPCB_PLUGIN::FootprintEnumerate(), LEGACY_PLUGIN::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(), NETLIST_READER::GuessNetlistFileType(), PGM_BASE::HandleException(), EDA_3D_CANVAS::initializeOpenGL(), fontconfig::FONTCONFIG::ListFonts(), CMP_READER::Load(), LEGACY_NETLIST_READER::loadComponent(), LEGACY_PLUGIN::loadDIMENSION(), SCH_LEGACY_PLUGIN_CACHE::loadDocs(), LEGACY_PLUGIN::loadFOOTPRINT(), LEGACY_NETLIST_READER::loadFootprintFilters(), LEGACY_NETLIST_READER::loadNet(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), LEGACY_PLUGIN::loadSETUP(), LEGACY_PLUGIN::loadSHEET(), SCH_LEGACY_PLUGIN::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_PARSER::parseLayer(), KICAD_NETLIST_PARSER::parseLibPartList(), KICAD_NETLIST_PARSER::parseNet(), parseQuotedString(), PCB_CALCULATOR_DATAFILE_PARSER::ParseRegulatorDescr(), PCB_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().
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 1205 of file string_utils.cpp.
wxString GetIllegalFileNameWxChars | ( | ) |
Definition at line 1017 of file string_utils.cpp.
References From_UTF8(), and illegalFileNameChars.
Referenced by ReplaceIllegalFileNameChars().
wxString GetISO8601CurrentDateTime | ( | ) |
Definition at line 678 of file string_utils.cpp.
Referenced by GENDRILL_WRITER_BASE::GenDrillReportFile(), PLACE_FILE_EXPORTER::GenPositionData(), PLACE_FILE_EXPORTER::GenReportData(), NETLIST_EXPORTER_XML::makeDesignHeader(), RecreateCmpFile(), EXCELLON_WRITER::writeEXCELLONHeader(), STEP_PCB_MODEL::WriteGLTF(), PCB_CALCULATOR_DATAFILE::WriteHeader(), ERC_REPORT::WriteJsonReport(), DRC_REPORT::WriteJsonReport(), NETLIST_EXPORTER_ALLEGRO::WriteNetlist(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), ERC_REPORT::WriteTextReport(), and DRC_REPORT::WriteTextReport().
char * GetLine | ( | FILE * | aFile, |
char * | Line, | ||
int * | LineNum = nullptr , |
||
int | SizeLine = 255 |
||
) |
Read one line line from aFile.
Definition at line 662 of file string_utils.cpp.
Referenced by CVPCB_MAINFRAME::buildEquivalenceList().
int GetTrailingInt | ( | const wxString & | aStr | ) |
Gets the trailing int, if any, from a string.
aStr | the string to check. |
Definition at line 993 of file string_utils.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), compareFootprintsbyRef(), FOOTPRINT::GetNextPadNumber(), and FOOTPRINT::IncrementReference().
bool NoPrintableChars | ( | const wxString & | aString | ) |
Return true if the string is empty or contains only whitespace.
Definition at line 551 of file string_utils.cpp.
Referenced by SCH_DRAWING_TOOLS::createNewText(), DRAWING_TOOL::PlaceText(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().
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 563 of file string_utils.cpp.
Referenced by KIGFX::PCB_PAINTER::draw().
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.
aDest | is the destination byte buffer. |
aSource | is the source bytes as a C string. |
aDestSize | is the size of the destination byte buffer. |
Definition at line 421 of file string_utils.cpp.
int ReadDelimitedText | ( | wxString * | aDest, |
const char * | aSource | ||
) |
Copy bytes from aSource delimited string segment to aDest wxString.
aDest | is the destination wxString. |
aSource | is the source C string holding utf8 encoded bytes. |
Definition at line 376 of file string_utils.cpp.
References From_UTF8().
Referenced by LEGACY_PLUGIN::load3D(), LEGACY_PLUGIN::loadDIMENSION(), LEGACY_PLUGIN::loadMODULE_TEXT(), LEGACY_PLUGIN::loadNETCLASS(), LEGACY_PLUGIN::loadNETINFO_ITEM(), LEGACY_PLUGIN::loadPAD(), LEGACY_PLUGIN::loadPCB_TEXT(), LEGACY_PLUGIN::loadSHEET(), and LEGACY_PLUGIN::loadZONE_CONTAINER().
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
aName | is a point to a std::string object containing the footprint name to verify. |
aReplaceChar | (if not 0) is the replacement char. |
Definition at line 1023 of file string_utils.cpp.
References illegalFileNameChars, and StrPrintf().
Referenced by EDEVICE::EDEVICE(), EELEMENT::EELEMENT(), LEGACY_PLUGIN::loadAllSections(), FABMASTER::loadFootprints(), EAGLE_PLUGIN::loadLibrary(), LP_CACHE::LoadModules(), SCH_EAGLE_PLUGIN::loadSheet(), CADSTAR_SCH_ARCHIVE_LOADER::loadSheetAndChildSheets(), and CADSTAR_SCH_ARCHIVE_LOADER::loadSheets().
bool ReplaceIllegalFileNameChars | ( | wxString & | aName, |
int | aReplaceChar | ||
) |
Definition at line 1053 of file string_utils.cpp.
References GetIllegalFileNameWxChars().
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 932 of file string_utils.cpp.
Referenced by ValueStringCompare().
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 1106 of file string_utils.cpp.
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.
aString1 | A wxString reference to the reference string. |
aString2 | A wxString reference to the comparison string. |
aIgnoreCase | Use true to make the comparison case insensitive. |
Definition at line 692 of file string_utils.cpp.
Referenced by REGULATOR_LIST::Add(), BOOST_AUTO_TEST_CASE(), ChangeArrayCompare(), FIELDS_EDITOR_GRID_DATA_MODEL::cmp(), PIN_TABLE_DATA_MODEL::compare(), SCH_PIN_TABLE_DATA_MODEL::compare(), NETLIST_EXPORTER_ALLEGRO::CompareLibPin(), SCH_SHEET::ComparePageNum(), NETLIST_EXPORTER_ALLEGRO::extractComponentsInfo(), FP_TREE_MODEL_ADAPTER::getFootprints(), NETLIST_EXPORTER_XML::makeSymbols(), myCompareFunction(), FOOTPRINT::cmp_pads::operator()(), operator<(), SCH_REFERENCE_LIST::sortByReferenceOnly(), sortFPlist(), and sortPinsByNumber().
char * StrPurge | ( | char * | text | ) |
Remove leading and training spaces, tabs and end of line chars in text.
Definition at line 643 of file string_utils.cpp.
References text.
Referenced by LEGACY_PLUGIN::loadAllSections(), EXCELLON_IMAGE::LoadFile(), LEGACY_PLUGIN::loadFOOTPRINT(), GERBER_FILE_IMAGE::LoadGerberFile(), LP_CACHE::LoadModules(), LEGACY_NETLIST_READER::LoadNetlist(), LEGACY_PLUGIN::loadPAD(), EXCELLON_IMAGE::TestFileIsExcellon(), and GERBER_FILE_IMAGE::TestFileIsRS274().
wxString TitleCaps | ( | const wxString & | aString | ) |
Capitalize the first letter in each word.
Definition at line 355 of file string_utils.cpp.
References wxStringSplit().
Referenced by SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties(), and SCH_EDIT_TOOL::editFieldText().
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 1158 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().
wxString UnescapeHTML | ( | const wxString & | aString | ) |
Return a new wxString unescaped from HTML format.
Definition at line 537 of file string_utils.cpp.
Referenced by SCH_EASYEDAPRO_PARSER::ParseSchematic(), and SCH_EASYEDAPRO_PARSER::ParseSymbol().
wxString UnescapeString | ( | const wxString & | aSource | ) |
Definition at line 271 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_FIELD_PROPERTIES::DIALOG_LIB_FIELD_PROPERTIES(), DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL(), DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS(), KIGFX::SCH_PAINTER::draw(), 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(), SYMBOL_EDIT_FRAME::ExportSymbol(), findItemsFromSyncSelection(), PCB_EDIT_FRAME::FindItemsFromSyncSelection(), DIALOG_NET_INSPECTOR::formatNetName(), NETLIST_EXPORTER_SPICE::GenerateItemPinNetName(), RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::GetActionDescription(), GRID_CELL_ESCAPED_TEXT_RENDERER::GetBestSize(), LIB_FIELD::GetItemDescription(), LIB_PIN::GetItemDescription(), SCH_DIRECTIVE_LABEL::GetItemDescription(), SCH_PIN::GetItemDescription(), LIB_FIELD::GetMsgPanelInfo(), LIB_PIN::GetMsgPanelInfo(), 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(), NETINFO_ITEM::GetMsgPanelInfo(), PAD::GetMsgPanelInfo(), ZONE::GetMsgPanelInfo(), PCB_TRACK::GetMsgPanelInfoBase_Common(), BOARD_CONNECTED_ITEM::GetNetnameMsg(), FOOTPRINT_SEARCH_HANDLER::getResultCell(), ZONE_SEARCH_HANDLER::getResultCell(), TEXT_SEARCH_HANDLER::getResultCell(), NETS_SEARCH_HANDLER::getResultCell(), RATSNEST_SEARCH_HANDLER::getResultCell(), SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetSymbolNames(), DIALOG_CHANGE_SYMBOLS::getSymbolReferences(), DIALOG_COPPER_ZONE::getUnescapedNetName(), FIELDS_GRID_TABLE< T >::GetValue(), LIB_TABLE_GRID::GetValue(), LIB_TREE_MODEL_ADAPTER::GetValue(), SYMBOL_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(), DIALOG_NET_INSPECTOR::LIST_ITEM::LIST_ITEM(), SCH_EAGLE_PLUGIN::loadInstance(), SIMULATOR_FRAME_UI::loadLegacyWorkbook(), SCH_LEGACY_PLUGIN_CACHE::LoadPart(), SCH_FIELD::Matches(), SCH_LABEL_BASE::Matches(), PCB_TEXT::Matches(), PCB_TEXTBOX::Matches(), SCH_CONNECTION::MightBeBusLabel(), DIALOG_NET_INSPECTOR::netFilterMatches(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), DIALOG_EDIT_SYMBOLS_LIBID::onClickOrphansButton(), APPEARANCE_CONTROLS::OnNetGridRightClick(), DIALOG_NET_INSPECTOR::onRenameNet(), SCH_SEXPR_PARSER::parseProperty(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DIALOG_CHANGE_SYMBOLS::processSymbols(), FOOTPRINT_LIST_IMPL::ReadCacheFromFile(), NET_SELECTOR_COMBOPOPUP::rebuildList(), SIMULATOR_FRAME_UI::rebuildSignalsList(), SYMBOL_VIEWER_FRAME::ReCreateLibList(), SYMBOL_VIEWER_FRAME::ReCreateSymbolList(), SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer(), SYMBOL_EDIT_FRAME::SetCurSymbol(), FOOTPRINT_INFO_GENERATOR::SetHtmlAliasOf(), 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(), PCB_EDIT_FRAME::ShowFindDialog(), SCH_EDIT_FRAME::ShowFindReplaceDialog(), SYMBOL_VIEWER_FRAME::ShowModal(), SCH_EDITOR_CONTROL::SimProbe(), ERC_TESTER::TestLibSymbolIssues(), DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::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().
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
Definition at line 880 of file string_utils.cpp.
References ApplyModifier(), SplitString(), and UnescapeString().
Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::cmp().
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.
Definition at line 771 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().
void wxStringSplit | ( | const wxString & | aText, |
wxArrayString & | aStrings, | ||
wxChar | aSplitter | ||
) |
Split aString to a string list separated at aSplitter.
aText | is the text to split. |
aStrings | will contain the split lines. |
aSplitter | is the 'split' character. |
Definition at line 1084 of file string_utils.cpp.
Referenced by KIFONT::FONT::getLinePositions(), EDA_TEXT::GetTextBox(), fontconfig::FONTCONFIG::isLanguageMatch(), KIFONT::FONT::LinebreakText(), HTML_MESSAGE_BOX::ListSet(), CADSTAR_SCH_ARCHIVE_LOADER::loadSymdef(), SIM_MODEL::MigrateSimModel(), PANEL_SETUP_RULES::OnErrorLinkClicked(), pcbnewGetWizardsBackTrace(), CLI::COMMAND::Perform(), SCH_TEXT::Plot(), SCH_TEXTBOX::Plot(), LIB_TEXTBOX::Plot(), BRDITEMS_PLOTTER::PlotText(), EDA_TEXT::Print(), and TitleCaps().
|
static |
Illegal file name characters used to ensure file names will be valid on all supported platforms.
This is the list of illegal file name characters for Windows which includes the illegal file name characters for Linux and OSX.
Definition at line 43 of file string_utils.cpp.
Referenced by GetIllegalFileNameWxChars(), and ReplaceIllegalFileNameChars().