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'\u00B4' || *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 ==
')' )
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 while( str1 != aString1.end() && str2 != aString2.end() )
831 wxUniChar c1 = *str1;
832 wxUniChar c2 = *str2;
834 if( wxIsdigit( c1 ) && wxIsdigit( c2 ) )
842 nb1 = nb1 * 10 + (int) c1 -
'0';
844 }
while( str1 != aString1.end() && wxIsdigit( *str1 ) );
849 nb2 = nb2 * 10 + (int) c2 -
'0';
851 }
while( str2 != aString2.end() && wxIsdigit( *str2 ) );
859 c1 = ( str1 != aString1.end() ) ? *str1 : wxUniChar( 0 );
860 c2 = ( str2 != aString2.end() ) ? *str2 : wxUniChar( 0 );
868 wxUniChar uc1 = wxToupper( c1 );
869 wxUniChar uc2 = wxToupper( c2 );
872 return uc1 < uc2 ? -1 : 1;
884 if( str1 != aString1.end() )
887 if( str2 != aString2.end() )
891 if( str1 == aString1.end() && str2 != aString2.end() )
895 else if( str1 != aString1.end() && str2 == aString2.end() )
905 bool case_sensitive )
907 const wxChar* cp =
nullptr;
908 const wxChar* mp =
nullptr;
909 const wxChar* wild =
nullptr;
910 const wxChar* str =
nullptr;
911 wxString _pattern, _string_to_tst;
915 wild = pattern.GetData();
916 str = string_to_tst.GetData();
921 _pattern.MakeUpper();
922 _string_to_tst = string_to_tst;
923 _string_to_tst.MakeUpper();
924 wild = _pattern.GetData();
925 str = _string_to_tst.GetData();
928 while( ( *str ) && ( *wild !=
'*' ) )
930 if( ( *wild != *str ) && ( *wild !=
'?' ) )
947 else if( ( *wild == *str ) || ( *wild ==
'?' ) )
959 while( *wild ==
'*' )
971 static const wxString modifiers( wxT(
"afpnuµμmLRFkKMGTPE" ) );
973 if( !aString.length() )
979 if( modifiers.Find( aString[ 0 ] ) >= 0 )
981 modifier = aString[ 0 ];
982 units = aString.Mid( 1 ).Trim();
987 units = aString.Mid( 0 ).Trim();
991 && !units.IsSameAs( wxT(
"F" ),
false )
992 && !units.IsSameAs( wxT(
"hz" ),
false )
993 && !units.IsSameAs( wxT(
"W" ),
false )
994 && !units.IsSameAs( wxT(
"V" ),
false )
995 && !units.IsSameAs( wxT(
"A" ),
false )
996 && !units.IsSameAs( wxT(
"H" ),
false ) )
1002 if( modifier ==
'a' )
1004 else if( modifier ==
'f' )
1006 if( modifier ==
'p' )
1008 if( modifier ==
'n' )
1010 else if( modifier ==
'u' || modifier == wxS(
"µ" )[0] || modifier == wxS(
"μ" )[0] )
1012 else if( modifier ==
'm' || modifier ==
'L' )
1014 else if( modifier ==
'R' || modifier ==
'F' )
1016 else if( modifier ==
'k' || modifier ==
'K' )
1018 else if( modifier ==
'M' )
1020 else if( modifier ==
'G' )
1022 else if( modifier ==
'T' )
1024 else if( modifier ==
'P' )
1026 else if( modifier ==
'E' )
1046 value->Replace( wxS(
" " ), wxEmptyString );
1048 wxChar ambiguousSeparator =
'?';
1049 wxChar thousandsSeparator =
'?';
1050 bool thousandsSeparatorFound =
false;
1051 wxChar decimalSeparator =
'?';
1052 bool decimalSeparatorFound =
false;
1055 for(
int ii = (
int) value->length() - 1; ii >= 0; --ii )
1057 wxChar c = value->GetChar( ii );
1059 if( c >=
'0' && c <=
'9' )
1063 else if( c ==
'.' || c ==
',' )
1065 if( decimalSeparator !=
'?' || thousandsSeparator !=
'?' )
1069 if( c == decimalSeparator )
1071 if( thousandsSeparatorFound )
1073 else if( decimalSeparatorFound )
1076 decimalSeparatorFound =
true;
1078 else if( c == thousandsSeparator )
1083 thousandsSeparatorFound =
true;
1086 else if( ambiguousSeparator !=
'?' )
1090 if( c == ambiguousSeparator )
1093 thousandsSeparator = ambiguousSeparator;
1094 thousandsSeparatorFound =
true;
1095 decimalSeparator = c ==
'.' ?
',' :
'.';
1100 decimalSeparator = ambiguousSeparator;
1101 decimalSeparatorFound =
true;
1102 thousandsSeparator = c;
1103 thousandsSeparatorFound =
true;
1115 if( ( ii == 1 && value->GetChar( 0 ) ==
'0' ) || digits != 3 )
1117 decimalSeparator = c;
1118 decimalSeparatorFound =
true;
1119 thousandsSeparator = c ==
'.' ?
',' :
'.';
1123 ambiguousSeparator = c;
1136 if( decimalSeparator ==
'?' && thousandsSeparator ==
'?' )
1138 const struct lconv* lc = localeconv();
1140 decimalSeparator = lc->decimal_point[0];
1141 thousandsSeparator = decimalSeparator ==
'.' ?
',' :
'.';
1145 value->Replace( thousandsSeparator, wxEmptyString );
1146 value->Replace( decimalSeparator,
'.' );
1159 wxString strFWordBeg, strFWordMid, strFWordEnd;
1160 wxString strSWordBeg, strSWordMid, strSWordEnd;
1163 SplitString( fWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
1164 SplitString( sWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
1167 int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
1173 else if( isEqual < 0 )
1180 double lFirstNumber = 0;
1181 double lSecondNumber = 0;
1182 bool endingIsModifier =
false;
1187 strFWordMid.ToCDouble( &lFirstNumber );
1188 strSWordMid.ToCDouble( &lSecondNumber );
1190 endingIsModifier |=
ApplyModifier( lFirstNumber, strFWordEnd );
1191 endingIsModifier |=
ApplyModifier( lSecondNumber, strSWordEnd );
1193 if( lFirstNumber > lSecondNumber )
1195 else if( lFirstNumber < lSecondNumber )
1198 else if( !endingIsModifier )
1199 return strFWordEnd.CmpNoCase( strSWordEnd );
1208 wxString* strBeginning,
1209 wxString* strDigits,
1212 static const wxString separators( wxT(
".," ) );
1213 wxUniChar infix = 0;
1216 strBeginning->Empty();
1221 if( strToSplit.length() == 0 )
1227 for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
1229 if( wxIsdigit( strToSplit[ii] ) )
1236 *strBeginning = strToSplit;
1241 *strEnd = strToSplit.substr( ii + 1 );
1244 int position = ii + 1;
1246 for( ; ii >= 0; ii-- )
1249 wxUniChar c = strToSplit[ii];
1251 if( wxIsdigit( c ) )
1260 else if( separators.Find( strToSplit[ii] ) >= 0 )
1273 *strDigits = strToSplit.substr( 0, position );
1278 *strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
1279 *strBeginning = strToSplit.substr( 0, ii + 1 );
1284 strDigits->Replace( infix,
'.' );
1285 *strEnd = infix + *strEnd;
1299 int index = aStr.Len() - 1;
1303 const char chr = aStr.GetChar(
index );
1305 if( chr <
'0' || chr >
'9' )
1308 number += ( chr -
'0' ) * base;
1327 if( first_illegal_pos == std::string::npos )
1334 result.reserve( aName.length() + 16 );
1336 result.append( aName, 0, first_illegal_pos );
1338 for(
size_t i = first_illegal_pos; i < aName.length(); ++i )
1347 result.push_back( aReplaceChar );
1351 fmt::format_to( std::back_inserter(
result ),
"%{:02x}",
static_cast<unsigned char>( c ) );
1360 aName = std::move(
result );
1367 bool changed =
false;
1369 result.reserve( aName.Length() );
1372 for( wxString::iterator it = aName.begin(); it != aName.end(); ++it )
1374 if( illWChars.Find( *it ) != wxNOT_FOUND )
1379 result += wxString::Format(
"%%%02x", *it );
1390 aName = std::move(
result );
1396void wxStringSplit(
const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
1400 for(
unsigned ii = 0; ii < aText.Length(); ii++ )
1402 if( aText[ii] == aSplitter )
1404 aStrings.Add( tmp );
1413 if( !tmp.IsEmpty() )
1414 aStrings.Add( tmp );
1420 struct lconv* lc = localeconv();
1421 char sep = lc->decimal_point[0];
1422 unsigned sep_pos = aStringValue.Find( sep );
1427 unsigned min_len = sep_pos + aTrailingZeroAllowed + 1;
1429 while( aStringValue.Len() > min_len )
1431 if( aStringValue.Last() ==
'0' )
1432 aStringValue.RemoveLast();
1444 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1446 buf = fmt::format(
"{:.16f}", aValue );
1449 while( !buf.empty() && buf[buf.size() - 1] ==
'0' )
1456 if( buf[buf.size() - 1] ==
'.' )
1463 buf = fmt::format(
"{:.10g}", aValue );
1475 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1479 len = snprintf( buf,
sizeof( buf ),
"%.16f", aValue );
1481 while( --len > 0 && buf[len] ==
'0' )
1484 if( buf[len] ==
'.' || buf[len] ==
',' )
1493 len = snprintf( buf,
sizeof( buf ),
"%.10g", aValue );
1496 return std::string( buf, len );
1503 wxString line = wxString::FromUTF8( cstring );
1505 if( line.IsEmpty() )
1507 line = wxConvCurrent->cMB2WC( cstring );
1509 if( line.IsEmpty() )
1510 line = wxString::From8BitData( cstring );
1520 wxString line = wxString::FromUTF8( aString );
1522 if( line.IsEmpty() )
1524 line = wxConvCurrent->cMB2WC( aString.c_str() );
1526 if( line.IsEmpty() )
1527 line = wxString::From8BitData( aString.c_str() );
1536 wxString uriPathAndFileName;
1538 wxCHECK( aFileUri.StartsWith( wxS(
"file://" ), &uriPathAndFileName ), aFileUri );
1540 wxString tmp = uriPathAndFileName;
1541 wxString retv = wxS(
"file://" );
1543 tmp.Replace( wxS(
"\\" ), wxS(
"/" ) );
1544 tmp.Replace( wxS(
":" ), wxS(
"" ) );
1546 if( !tmp.IsEmpty() && tmp[0] !=
'/' )
1547 tmp = wxS(
"/" ) + tmp;
1558 std::pair<wxString, long> ParseAlphaNumericPin(
const wxString& pinNum )
1563 size_t numStart = pinNum.length();
1564 for(
int i =
static_cast<int>( pinNum.length() ) - 1; i >= 0; --i )
1566 if( !wxIsdigit( pinNum[i] ) )
1575 if( numStart < pinNum.length() )
1577 prefix = pinNum.Left( numStart );
1578 wxString numericPart = pinNum.Mid( numStart );
1579 numericPart.ToLong( &numValue );
1582 return { prefix, numValue };
1591 std::vector<wxString> expanded;
1593 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1594 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1596 if( hasOpenBracket || hasCloseBracket )
1598 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1602 expanded.push_back( aPinName );
1607 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1609 expanded.push_back( aPinName );
1613 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1616 while( start < inner.length() )
1618 size_t comma = inner.find(
',', start );
1619 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1620 part.Trim(
true ).Trim(
false );
1623 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1627 int dashPos = part.Find(
'-' );
1628 if( dashPos != wxNOT_FOUND )
1630 wxString startTxt = part.Left( dashPos );
1631 wxString endTxt = part.Mid( dashPos + 1 );
1632 startTxt.Trim(
true ).Trim(
false );
1633 endTxt.Trim(
true ).Trim(
false );
1635 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1636 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1638 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1643 expanded.push_back( aPinName );
1647 for(
long ii = startVal; ii <= endVal; ++ii )
1649 if( startPrefix.IsEmpty() )
1650 expanded.emplace_back( wxString::Format( wxT(
"%ld" ), ii ) );
1652 expanded.emplace_back( wxString::Format( wxT(
"%s%ld" ), startPrefix, ii ) );
1657 expanded.push_back( part );
1660 if( comma == wxString::npos )
1665 if( expanded.empty() )
1667 expanded.push_back( aPinName );
1678 size_t len = aPinName.length();
1691 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1692 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1694 if( hasOpenBracket || hasCloseBracket )
1696 if( aPinName[0] !=
'[' || aPinName[len - 1] !=
']' )
1704 if( aPinName[0] !=
'[' || aPinName[len - 1] !=
']' )
1707 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1712 while( start < inner.length() )
1714 size_t comma = inner.find(
',', start );
1715 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1716 part.Trim(
true ).Trim(
false );
1720 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1724 int dashPos = part.Find(
'-' );
1725 if( dashPos != wxNOT_FOUND )
1727 wxString startTxt = part.Left( dashPos );
1728 wxString endTxt = part.Mid( dashPos + 1 );
1729 startTxt.Trim(
true ).Trim(
false );
1730 endTxt.Trim(
true ).Trim(
false );
1732 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1733 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1735 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1744 count +=
static_cast<int>( endVal - startVal + 1 );
1752 if( comma == wxString::npos )
1790 std::vector<LOAD_MESSAGE> messages;
1792 if( aErrorString.IsEmpty() )
1800 wxStringTokenizer tokenizer( aErrorString, wxS(
"\n" ), wxTOKEN_STRTOK );
1802 while( tokenizer.HasMoreTokens() )
1804 wxString line = tokenizer.GetNextToken();
1807 if( line.StartsWith( wxS(
"from " ) ) )
1810 if( line.StartsWith( wxS(
"Library '" ) ) || line.Contains( wxS(
"Expecting" ) ) )
1811 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.