38#include <fmt/chrono.h>
41#include <wx/tokenzr.h>
65 wxString filtered_fullpath = aFullFilename;
70 filtered_fullpath.Replace(
"/",
"_" );
71 filtered_fullpath.Replace(
"\\",
"_" );
74 if( filtered_fullpath.Length() > 1 && filtered_fullpath[1] ==
':' )
75 filtered_fullpath[1] =
' ';
78 if( wxString::npos != filtered_fullpath.find_first_of( wxFileName::GetForbiddenChars() ) )
88 bool inOverbar =
false;
91 if( aOldStr == wxT(
"~" ) )
94 newStr.reserve( aOldStr.length() );
96 for( wxString::const_iterator chIt = aOldStr.begin(); chIt != aOldStr.end(); ++chIt )
100 wxString::const_iterator lookahead = chIt + 1;
102 if( lookahead != aOldStr.end() && *lookahead ==
'~' )
104 if( ++lookahead != aOldStr.end() && *lookahead ==
'{' )
108 newStr << wxT(
"~~{}" );
113 newStr << wxT(
"~" );
117 else if( lookahead != aOldStr.end() && *lookahead ==
'{' )
127 newStr << wxT(
"}" );
132 newStr << wxT(
"~{" );
139 else if( ( *chIt ==
' ' || *chIt ==
'}' || *chIt ==
')' ) && inOverbar )
142 newStr << wxT(
"}" );
151 newStr << wxT(
"}" );
161 for( wxString::iterator ii = aString->begin(); ii != aString->end(); ++ii )
163 if( *ii ==
L'\u2018' || *ii ==
L'\u2019' )
168 if( *ii ==
L'\u201C' || *ii ==
L'\u201D' )
173 if( *ii ==
L'\u2013' || *ii ==
L'\u2014' )
187 std::vector<bool> braceStack;
189 converted.reserve( aSource.length() );
191 for( wxUniChar c: aSource )
196 converted += wxT(
"{slash}" );
197 else if( c ==
'\n' || c ==
'\r' )
198 converted += wxEmptyString;
206 converted += wxT(
"{slash}" );
208 converted += wxT(
"{backslash}" );
210 converted += wxT(
"{lt}" );
212 converted += wxT(
"{gt}" );
214 converted += wxT(
"{colon}" );
216 converted += wxT(
"{dblquote}" );
217 else if( c ==
'\n' || c ==
'\r' )
218 converted += wxEmptyString;
225 converted += wxT(
"{slash}" );
227 converted += wxT(
"{comma}" );
229 converted += wxT(
"{dblquote}" );
236 converted += wxT(
"{dblquote}" );
242 if( c >= 0x7F || c ==
'\'' || c ==
'"' || c ==
'\\' || c ==
'(' || c ==
')' )
244 unsigned int code = c;
246 snprintf( buffer,
sizeof(buffer),
"\\u%4.4X", code );
256 if( c ==
'\n' || c ==
'\r' )
257 converted += wxT(
"{return}" );
264 converted += wxT(
"{slash}" );
266 converted += wxT(
"{backslash}" );
268 converted += wxT(
"{dblquote}" );
270 converted += wxT(
"{lt}" );
272 converted += wxT(
"{gt}" );
274 converted += wxT(
"{bar}" );
276 converted += wxT(
"{colon}" );
278 converted += wxT(
"{tab}" );
279 else if( c ==
'\n' || c ==
'\r' )
280 converted += wxT(
"{return}" );
287 converted += wxT(
"{space}" );
294 converted += wxT(
"{comma}" );
295 else if( c ==
'\n' || c ==
'\r' )
296 converted += wxT(
"{return}" );
312 size_t sourceLen = aSource.length();
321 newbuf.reserve( sourceLen );
326 for(
size_t i = 0; i < sourceLen; ++i )
335 bool terminated =
false;
337 for( i = i + 1; i < sourceLen; ++i )
361 else if( prev ==
'$' || prev ==
'~' || prev ==
'^' || prev ==
'_' )
365 else if( token == wxT(
"dblquote" ) ) newbuf << wxT(
"\"" );
366 else if( token == wxT(
"quote" ) ) newbuf << wxT(
"'" );
367 else if( token == wxT(
"lt" ) ) newbuf << wxT(
"<" );
368 else if( token == wxT(
"gt" ) ) newbuf << wxT(
">" );
369 else if( token == wxT(
"backslash" ) ) newbuf << wxT(
"\\" );
370 else if( token == wxT(
"slash" ) ) newbuf << wxT(
"/" );
371 else if( token == wxT(
"bar" ) ) newbuf << wxT(
"|" );
372 else if( token == wxT(
"comma" ) ) newbuf << wxT(
"," );
373 else if( token == wxT(
"colon" ) ) newbuf << wxT(
":" );
374 else if( token == wxT(
"space" ) ) newbuf << wxT(
" " );
375 else if( token == wxT(
"dollar" ) ) newbuf << wxT(
"$" );
376 else if( token == wxT(
"tab" ) ) newbuf << wxT(
"\t" );
377 else if( token == wxT(
"return" ) ) newbuf << wxT(
"\n" );
378 else if( token == wxT(
"brace" ) ) newbuf << wxT(
"{" );
401 result.reserve( aString.length() );
403 for(
const wxString& word : words )
408 result += word.Capitalize();
422 result.reserve( aString.length() );
424 for(
const wxString& word : words )
427 result += word.Capitalize();
429 result += wxT(
" " ) + word.Lower();
440 const char* start = aSource;
443 while( (cc = *aSource++) != 0 )
463 if( cc !=
'"' && cc !=
'\\' )
477 return aSource - start;
487 const char* start = aSource;
488 char* limit = aDest + aDestSize - 1;
491 while( ( cc = *aSource++ ) != 0 && aDest < limit )
510 if( cc !=
'"' && cc !=
'\\' )
525 return aSource - start;
531 wxString str = aString;
534 str.Replace( wxT(
"\r\n" ), wxT(
"\r" ) );
535 str.Replace( wxT(
"\n" ), wxT(
"\r" ) );
537 std::string utf8 =
TO_UTF8( aString );
541 ret.reserve( utf8.length() + 2 );
545 for( std::string::const_iterator it = utf8.begin(); it!=utf8.end(); ++it )
553 else if( *it ==
'\\' )
574 converted.reserve( aString.length() );
576 for( wxUniChar c : aString )
579 converted += wxT(
""" );
581 converted += wxT(
"'" );
583 converted += wxT(
"&" );
585 converted += wxT(
"<" );
587 converted += wxT(
">" );
599 static const std::map<wxString, wxString> c_replacements = {
600 { wxS(
"quot" ), wxS(
"\"" ) },
601 { wxS(
"apos" ), wxS(
"'" ) },
602 { wxS(
"amp" ), wxS(
"&" ) },
603 { wxS(
"lt" ), wxS(
"<" ) },
604 { wxS(
"gt" ), wxS(
">" ) }
609 wxString regexStr =
"&(#(\\d*)|#x([a-zA-Z0-9]{4})";
611 for(
auto& [key, value] : c_replacements )
612 regexStr <<
'|' << key;
616 wxRegEx regex( regexStr );
623 wxString str = aString;
625 while( regex.Matches( str ) )
627 std::vector<wxString> matches;
628 regex.GetMatch( &start, &len );
630 result << str.Left( start );
632 wxString code = regex.GetMatch( str, 1 );
633 wxString codeDec = regex.GetMatch( str, 2 );
634 wxString codeHex = regex.GetMatch( str, 3 );
636 if( !codeDec.IsEmpty() || !codeHex.IsEmpty() )
638 unsigned long codeVal = 0;
640 if( !codeDec.IsEmpty() )
641 codeDec.ToCULong( &codeVal );
642 else if( !codeHex.IsEmpty() )
643 codeHex.ToCULong( &codeVal, 16 );
646 result << wxUniChar( codeVal );
648 else if(
auto val =
get_opt( c_replacements, code ) )
653 str = str.Mid( start + len );
664 wxString str = aInput;
665 wxRegEx( wxS(
"<[^>]*>" ) ).ReplaceAll( &str, wxEmptyString );
673 static wxRegEx regex( wxS(
"\\b(https?|ftp|file)://([-\\w+&@#/%?=~|!:,.;]*[^.,:;<>\\(\\)\\s\u00b6])" ),
676 regex.ReplaceAll( &aStr,
"<a href=\"\\0\">\\0</a>" );
684 static wxRegEx regex( wxS(
"(https?|ftp|file)://([-\\w+&@#/%?=~|!:,.;]*[^.,:;<>\\s\u00b6])" ),
687 regex.ReplaceAll( &aStr,
"<a href=\"\\0\">\\0</a>" );
689 return regex.Matches( aStr );
695 wxString tmp = aString;
697 return tmp.Trim(
true ).Trim(
false ).IsEmpty();
704 int overbarDepth = -1;
705 int superSubDepth = -1;
706 int braceNesting = 0;
708 for(
auto chIt = aString.begin(),
end = aString.end(); chIt <
end; ++chIt )
716 else if( *chIt ==
'^' && superSubDepth == -1 )
718 auto lookahead = chIt;
720 if( ++lookahead !=
end && *lookahead ==
'{' )
723 superSubDepth = braceNesting;
728 else if( *chIt ==
'_' && superSubDepth == -1 )
730 auto lookahead = chIt;
732 if( ++lookahead !=
end && *lookahead ==
'{' )
735 superSubDepth = braceNesting;
740 else if( *chIt ==
'~' && overbarDepth == -1 )
742 auto lookahead = chIt;
744 if( ++lookahead !=
end && *lookahead ==
'{' )
747 overbarDepth = braceNesting;
752 else if( *chIt ==
'{' )
756 else if( *chIt ==
'}' )
758 if( braceNesting > 0 )
761 if( braceNesting == superSubDepth )
767 if( braceNesting == overbarDepth )
783 static const char whitespace[] =
" \t\n\r\f\v";
787 while( *
text && strchr( whitespace, *
text ) )
790 char* cp =
text + strlen(
text ) - 1;
792 while( cp >=
text && strchr( whitespace, *cp ) )
800char*
GetLine( FILE* File,
char* Line,
int* LineNum,
int SizeLine )
803 if( fgets( Line, SizeLine, File ) ==
nullptr )
809 }
while( Line[0] ==
'#' || Line[0] ==
'\n' || Line[0] ==
'\r' || Line[0] == 0 );
811 strtok( Line,
"\n\r" );
818 return wxDateTime::Now().FormatISOCombined(
'T' );
822int StrNumCmp(
const wxString& aString1,
const wxString& aString2,
bool aIgnoreCase )
824 int nb1 = 0, nb2 = 0;
826 auto str1 = aString1.begin();
827 auto str2 = aString2.begin();
829 const auto str1End = aString1.end();
830 const auto str2End = aString2.end();
832 while( str1 != str1End && str2 != str2End )
834 wxUniChar c1 = *str1;
835 wxUniChar c2 = *str2;
837 if( wxIsdigit( c1 ) && wxIsdigit( c2 ) )
845 nb1 = nb1 * 10 + (int) c1 -
'0';
847 }
while( str1 != str1End && wxIsdigit( *str1 ) );
852 nb2 = nb2 * 10 + (int) c2 -
'0';
854 }
while( str2 != str2End && wxIsdigit( *str2 ) );
862 c1 = ( str1 != str1End ) ? *str1 : wxUniChar( 0 );
863 c2 = ( str2 != str2End ) ? *str2 : wxUniChar( 0 );
871 wxUniChar uc1 = wxToupper( c1 );
872 wxUniChar uc2 = wxToupper( c2 );
875 return uc1 < uc2 ? -1 : 1;
887 if( str1 != str1End )
890 if( str2 != str2End )
894 if( str1 == str1End && str2 != str2End )
898 else if( str1 != str1End && str2 == str2End )
908 bool case_sensitive )
910 const wxChar* cp =
nullptr;
911 const wxChar* mp =
nullptr;
912 const wxChar* wild =
nullptr;
913 const wxChar* str =
nullptr;
914 wxString _pattern, _string_to_tst;
918 wild = pattern.GetData();
919 str = string_to_tst.GetData();
924 _pattern.MakeUpper();
925 _string_to_tst = string_to_tst;
926 _string_to_tst.MakeUpper();
927 wild = _pattern.GetData();
928 str = _string_to_tst.GetData();
931 while( ( *str ) && ( *wild !=
'*' ) )
933 if( ( *wild != *str ) && ( *wild !=
'?' ) )
950 else if( ( *wild == *str ) || ( *wild ==
'?' ) )
962 while( *wild ==
'*' )
974 static const wxString modifiers( wxT(
"afpnuµμmLRFkKMGTPE" ) );
976 if( !aString.length() )
982 if( modifiers.Find( aString[ 0 ] ) >= 0 )
984 modifier = aString[ 0 ];
985 units = aString.Mid( 1 ).Trim();
990 units = aString.Mid( 0 ).Trim();
994 && !units.IsSameAs( wxT(
"F" ),
false )
995 && !units.IsSameAs( wxT(
"hz" ),
false )
996 && !units.IsSameAs( wxT(
"W" ),
false )
997 && !units.IsSameAs( wxT(
"V" ),
false )
998 && !units.IsSameAs( wxT(
"A" ),
false )
999 && !units.IsSameAs( wxT(
"H" ),
false ) )
1005 if( modifier ==
'a' )
1007 else if( modifier ==
'f' )
1009 if( modifier ==
'p' )
1011 if( modifier ==
'n' )
1013 else if( modifier ==
'u' || modifier == wxS(
"µ" )[0] || modifier == wxS(
"μ" )[0] )
1015 else if( modifier ==
'm' || modifier ==
'L' )
1017 else if( modifier ==
'R' || modifier ==
'F' )
1019 else if( modifier ==
'k' || modifier ==
'K' )
1021 else if( modifier ==
'M' )
1023 else if( modifier ==
'G' )
1025 else if( modifier ==
'T' )
1027 else if( modifier ==
'P' )
1029 else if( modifier ==
'E' )
1049 value->Replace( wxS(
" " ), wxEmptyString );
1051 wxChar ambiguousSeparator =
'?';
1052 wxChar thousandsSeparator =
'?';
1053 bool thousandsSeparatorFound =
false;
1054 wxChar decimalSeparator =
'?';
1055 bool decimalSeparatorFound =
false;
1058 for(
int ii = (
int) value->length() - 1; ii >= 0; --ii )
1060 wxChar c = value->GetChar( ii );
1062 if( c >=
'0' && c <=
'9' )
1066 else if( c ==
'.' || c ==
',' )
1068 if( decimalSeparator !=
'?' || thousandsSeparator !=
'?' )
1072 if( c == decimalSeparator )
1074 if( thousandsSeparatorFound )
1076 else if( decimalSeparatorFound )
1079 decimalSeparatorFound =
true;
1081 else if( c == thousandsSeparator )
1086 thousandsSeparatorFound =
true;
1089 else if( ambiguousSeparator !=
'?' )
1093 if( c == ambiguousSeparator )
1096 thousandsSeparator = ambiguousSeparator;
1097 thousandsSeparatorFound =
true;
1098 decimalSeparator = c ==
'.' ?
',' :
'.';
1103 decimalSeparator = ambiguousSeparator;
1104 decimalSeparatorFound =
true;
1105 thousandsSeparator = c;
1106 thousandsSeparatorFound =
true;
1118 if( ( ii == 1 && value->GetChar( 0 ) ==
'0' ) || digits != 3 )
1120 decimalSeparator = c;
1121 decimalSeparatorFound =
true;
1122 thousandsSeparator = c ==
'.' ?
',' :
'.';
1126 ambiguousSeparator = c;
1139 if( decimalSeparator ==
'?' && thousandsSeparator ==
'?' )
1141 const struct lconv* lc = localeconv();
1143 decimalSeparator = lc->decimal_point[0];
1144 thousandsSeparator = decimalSeparator ==
'.' ?
',' :
'.';
1148 value->Replace( thousandsSeparator, wxEmptyString );
1149 value->Replace( decimalSeparator,
'.' );
1162 wxString strFWordBeg, strFWordMid, strFWordEnd;
1163 wxString strSWordBeg, strSWordMid, strSWordEnd;
1166 SplitString( fWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
1167 SplitString( sWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
1170 int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
1176 else if( isEqual < 0 )
1183 double lFirstNumber = 0;
1184 double lSecondNumber = 0;
1185 bool endingIsModifier =
false;
1190 strFWordMid.ToCDouble( &lFirstNumber );
1191 strSWordMid.ToCDouble( &lSecondNumber );
1193 endingIsModifier |=
ApplyModifier( lFirstNumber, strFWordEnd );
1194 endingIsModifier |=
ApplyModifier( lSecondNumber, strSWordEnd );
1196 if( lFirstNumber > lSecondNumber )
1198 else if( lFirstNumber < lSecondNumber )
1201 else if( !endingIsModifier )
1202 return strFWordEnd.CmpNoCase( strSWordEnd );
1211 wxString* strBeginning,
1212 wxString* strDigits,
1215 static const wxString separators( wxT(
".," ) );
1216 wxUniChar infix = 0;
1219 strBeginning->Empty();
1224 if( strToSplit.length() == 0 )
1230 for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
1232 if( wxIsdigit( strToSplit[ii] ) )
1239 *strBeginning = strToSplit;
1244 *strEnd = strToSplit.substr( ii + 1 );
1247 int position = ii + 1;
1249 for( ; ii >= 0; ii-- )
1252 wxUniChar c = strToSplit[ii];
1254 if( wxIsdigit( c ) )
1263 else if( separators.Find( strToSplit[ii] ) >= 0 )
1276 *strDigits = strToSplit.substr( 0, position );
1281 *strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
1282 *strBeginning = strToSplit.substr( 0, ii + 1 );
1287 strDigits->Replace( infix,
'.' );
1288 *strEnd = infix + *strEnd;
1302 int index = aStr.Len() - 1;
1306 const char chr = aStr.GetChar(
index );
1308 if( chr <
'0' || chr >
'9' )
1311 number += ( chr -
'0' ) * base;
1330 if( first_illegal_pos == std::string::npos )
1337 result.reserve( aName.length() + 16 );
1339 result.append( aName, 0, first_illegal_pos );
1341 for(
size_t i = first_illegal_pos; i < aName.length(); ++i )
1350 result.push_back( aReplaceChar );
1354 fmt::format_to( std::back_inserter(
result ),
"%{:02x}",
static_cast<unsigned char>( c ) );
1363 aName = std::move(
result );
1370 bool changed =
false;
1372 result.reserve( aName.Length() );
1375 for( wxString::iterator it = aName.begin(); it != aName.end(); ++it )
1377 if( illWChars.Find( *it ) != wxNOT_FOUND )
1382 result += wxString::Format(
"%%%02x", *it );
1393 aName = std::move(
result );
1399void wxStringSplit(
const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
1403 for(
unsigned ii = 0; ii < aText.Length(); ii++ )
1405 if( aText[ii] == aSplitter )
1407 aStrings.Add( tmp );
1416 if( !tmp.IsEmpty() )
1417 aStrings.Add( tmp );
1423 struct lconv* lc = localeconv();
1424 char sep = lc->decimal_point[0];
1425 unsigned sep_pos = aStringValue.Find( sep );
1430 unsigned min_len = sep_pos + aTrailingZeroAllowed + 1;
1432 while( aStringValue.Len() > min_len )
1434 if( aStringValue.Last() ==
'0' )
1435 aStringValue.RemoveLast();
1447 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1449 buf = fmt::format(
"{:.16f}", aValue );
1452 while( !buf.empty() && buf[buf.size() - 1] ==
'0' )
1459 if( buf[buf.size() - 1] ==
'.' )
1466 buf = fmt::format(
"{:.10g}", aValue );
1478 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1482 len = snprintf( buf,
sizeof( buf ),
"%.16f", aValue );
1484 while( --len > 0 && buf[len] ==
'0' )
1487 if( buf[len] ==
'.' || buf[len] ==
',' )
1496 len = snprintf( buf,
sizeof( buf ),
"%.10g", aValue );
1499 return std::string( buf, len );
1506 wxString line = wxString::FromUTF8( cstring );
1508 if( line.IsEmpty() )
1510 line = wxConvCurrent->cMB2WC( cstring );
1512 if( line.IsEmpty() )
1513 line = wxString::From8BitData( cstring );
1523 wxString line = wxString::FromUTF8( aString );
1525 if( line.IsEmpty() )
1527 line = wxConvCurrent->cMB2WC( aString.c_str() );
1529 if( line.IsEmpty() )
1530 line = wxString::From8BitData( aString.c_str() );
1539 wxString uriPathAndFileName;
1541 wxCHECK( aFileUri.StartsWith( wxS(
"file://" ), &uriPathAndFileName ), aFileUri );
1543 wxString tmp = uriPathAndFileName;
1544 wxString retv = wxS(
"file://" );
1546 tmp.Replace( wxS(
"\\" ), wxS(
"/" ) );
1547 tmp.Replace( wxS(
":" ), wxS(
"" ) );
1549 if( !tmp.IsEmpty() && tmp[0] !=
'/' )
1550 tmp = wxS(
"/" ) + tmp;
1561 std::pair<wxString, long> ParseAlphaNumericPin(
const wxString& pinNum )
1566 size_t numStart = pinNum.length();
1567 for(
int i =
static_cast<int>( pinNum.length() ) - 1; i >= 0; --i )
1569 if( !wxIsdigit( pinNum[i] ) )
1578 if( numStart < pinNum.length() )
1580 prefix = pinNum.Left( numStart );
1581 wxString numericPart = pinNum.Mid( numStart );
1582 numericPart.ToLong( &numValue );
1585 return { prefix, numValue };
1594 std::vector<wxString> expanded;
1596 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1597 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1599 if( hasOpenBracket || hasCloseBracket )
1601 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1605 expanded.push_back( aPinName );
1610 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1612 expanded.push_back( aPinName );
1616 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1619 while( start < inner.length() )
1621 size_t comma = inner.find(
',', start );
1622 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1623 part.Trim(
true ).Trim(
false );
1626 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1630 int dashPos = part.Find(
'-' );
1631 if( dashPos != wxNOT_FOUND )
1633 wxString startTxt = part.Left( dashPos );
1634 wxString endTxt = part.Mid( dashPos + 1 );
1635 startTxt.Trim(
true ).Trim(
false );
1636 endTxt.Trim(
true ).Trim(
false );
1638 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1639 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1641 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1646 expanded.push_back( aPinName );
1650 for(
long ii = startVal; ii <= endVal; ++ii )
1652 if( startPrefix.IsEmpty() )
1653 expanded.emplace_back( wxString::Format( wxT(
"%ld" ), ii ) );
1655 expanded.emplace_back( wxString::Format( wxT(
"%s%ld" ), startPrefix, ii ) );
1660 expanded.push_back( part );
1663 if( comma == wxString::npos )
1668 if( expanded.empty() )
1670 expanded.push_back( aPinName );
1681 size_t len = aPinName.length();
1694 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1695 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1697 if( hasOpenBracket || hasCloseBracket )
1699 if( aPinName[0] !=
'[' || aPinName[len - 1] !=
']' )
1707 if( aPinName[0] !=
'[' || aPinName[len - 1] !=
']' )
1710 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1715 while( start < inner.length() )
1717 size_t comma = inner.find(
',', start );
1718 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1719 part.Trim(
true ).Trim(
false );
1723 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1727 int dashPos = part.Find(
'-' );
1728 if( dashPos != wxNOT_FOUND )
1730 wxString startTxt = part.Left( dashPos );
1731 wxString endTxt = part.Mid( dashPos + 1 );
1732 startTxt.Trim(
true ).Trim(
false );
1733 endTxt.Trim(
true ).Trim(
false );
1735 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1736 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1738 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1747 count +=
static_cast<int>( endVal - startVal + 1 );
1755 if( comma == wxString::npos )
1793 std::vector<LOAD_MESSAGE> messages;
1795 if( aErrorString.IsEmpty() )
1803 wxStringTokenizer tokenizer( aErrorString, wxS(
"\n" ), wxTOKEN_STRTOK );
1805 while( tokenizer.HasMoreTokens() )
1807 wxString line = tokenizer.GetNextToken();
1810 if( line.StartsWith( wxS(
"from " ) ) )
1813 if( line.StartsWith( wxS(
"Library '" ) ) || line.Contains( wxS(
"Expecting" ) ) )
1814 messages.push_back( { line,
static_cast<SEVERITY>( aSeverity ) } );
static bool IsOldSchoolDecimalSeparator(wxUniChar ch, double *siScaler)
This file contains miscellaneous commonly used macros and functions.
std::optional< V > get_opt(const std::map< wxString, V > &aMap, const wxString &aKey)
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString RemoveHTMLTags(const wxString &aInput)
Removes HTML tags from a string.
wxString EscapeHTML(const wxString &aString)
Return a new wxString escaped for embedding in HTML.
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.
wxString GetDefaultVariantName()
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
int GetTrailingInt(const wxString &aStr)
Gets the trailing int, if any, from a string.
wxString UnescapeString(const wxString &aSource)
wxString LinkifyHTML(wxString aStr)
Wraps links in HTML tags.
bool convertSeparators(wxString *value)
wxString GetIllegalFileNameWxChars()
wxString From_UTF8(const char *cstring)
std::vector< LOAD_MESSAGE > ExtractLibraryLoadErrors(const wxString &aErrorString, int aSeverity)
Parse library load error messages, extracting user-facing information while stripping internal code l...
int SortVariantNames(const wxString &aLhs, const wxString &aRhs)
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.
static const wxChar defaultVariantName[]
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
int ReadDelimitedText(wxString *aDest, const char *aSource)
Copy bytes from aSource delimited string segment to aDest wxString.
wxString TitleCaps(const wxString &aString)
Capitalize the first letter in each word.
std::string UIDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 We want to avoid scientific ...
static constexpr std::string_view illegalFileNameChars
Illegal file name characters used to ensure file names will be valid on all supported platforms.
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
bool ReplaceIllegalFileNameChars(std::string &aName, int aReplaceChar)
Checks aName for illegal file name characters.
int PrintableCharCount(const wxString &aString)
Return the number of printable (ie: non-formatting) chars.
std::string EscapedUTF8(const wxString &aString)
Return an 8 bit UTF8 string given aString in Unicode form.
char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine)
Read one line line from aFile.
bool ApplyModifier(double &value, const wxString &aString)
wxString InitialCaps(const wxString &aString)
Capitalize only the first word.
wxString NormalizeFileUri(const wxString &aFileUri)
Normalize file path aFileUri to URI convention.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
wxString GetISO8601CurrentDateTime()
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
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.
bool IsFullFileNameValid(const wxString &aFullFilename)
Checks if a full filename is valid, i.e.
void StripTrailingZeros(wxString &aStringValue, unsigned aTrailingZeroAllowed)
Remove trailing zeros from a string containing a converted float number.
int CountStackedPinNotation(const wxString &aPinName, bool *aValid)
Count the number of pins represented by stacked pin notation without allocating strings.
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
wxString UnescapeHTML(const wxString &aString)
Return a new wxString unescaped from HTML format.
bool IsURL(wxString aStr)
Performs a URL sniff-test on a string.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
ESCAPE_CONTEXT
Escape/Unescape routines to safely encode reserved-characters in various contexts.
wxString result
Test unit parsing edge cases and error handling.