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" );
822#if defined(__MINGW32__) && !defined(_UCRT)
823 return fmt::format(
"{:%FT%T}", fmt::localtime( std::time(
nullptr ) ) );
825 return fmt::format(
"{:%FT%T%z}", fmt::localtime( std::time(
nullptr ) ) );
830int StrNumCmp(
const wxString& aString1,
const wxString& aString2,
bool aIgnoreCase )
832 int nb1 = 0, nb2 = 0;
834 auto str1 = aString1.begin();
835 auto str2 = aString2.begin();
837 while( str1 != aString1.end() && str2 != aString2.end() )
839 wxUniChar c1 = *str1;
840 wxUniChar c2 = *str2;
842 if( wxIsdigit( c1 ) && wxIsdigit( c2 ) )
850 nb1 = nb1 * 10 + (int) c1 -
'0';
852 }
while( str1 != aString1.end() && wxIsdigit( *str1 ) );
857 nb2 = nb2 * 10 + (int) c2 -
'0';
859 }
while( str2 != aString2.end() && wxIsdigit( *str2 ) );
867 c1 = ( str1 != aString1.end() ) ? *str1 : wxUniChar( 0 );
868 c2 = ( str2 != aString2.end() ) ? *str2 : wxUniChar( 0 );
876 wxUniChar uc1 = wxToupper( c1 );
877 wxUniChar uc2 = wxToupper( c2 );
880 return uc1 < uc2 ? -1 : 1;
892 if( str1 != aString1.end() )
895 if( str2 != aString2.end() )
899 if( str1 == aString1.end() && str2 != aString2.end() )
903 else if( str1 != aString1.end() && str2 == aString2.end() )
913 bool case_sensitive )
915 const wxChar* cp =
nullptr;
916 const wxChar* mp =
nullptr;
917 const wxChar* wild =
nullptr;
918 const wxChar* str =
nullptr;
919 wxString _pattern, _string_to_tst;
923 wild = pattern.GetData();
924 str = string_to_tst.GetData();
929 _pattern.MakeUpper();
930 _string_to_tst = string_to_tst;
931 _string_to_tst.MakeUpper();
932 wild = _pattern.GetData();
933 str = _string_to_tst.GetData();
936 while( ( *str ) && ( *wild !=
'*' ) )
938 if( ( *wild != *str ) && ( *wild !=
'?' ) )
955 else if( ( *wild == *str ) || ( *wild ==
'?' ) )
967 while( *wild ==
'*' )
979 static const wxString modifiers( wxT(
"afpnuµμmLRFkKMGTPE" ) );
981 if( !aString.length() )
987 if( modifiers.Find( aString[ 0 ] ) >= 0 )
989 modifier = aString[ 0 ];
990 units = aString.Mid( 1 ).Trim();
995 units = aString.Mid( 0 ).Trim();
999 && !units.IsSameAs( wxT(
"F" ),
false )
1000 && !units.IsSameAs( wxT(
"hz" ),
false )
1001 && !units.IsSameAs( wxT(
"W" ),
false )
1002 && !units.IsSameAs( wxT(
"V" ),
false )
1003 && !units.IsSameAs( wxT(
"A" ),
false )
1004 && !units.IsSameAs( wxT(
"H" ),
false ) )
1010 if( modifier ==
'a' )
1012 else if( modifier ==
'f' )
1014 if( modifier ==
'p' )
1016 if( modifier ==
'n' )
1018 else if( modifier ==
'u' || modifier == wxS(
"µ" )[0] || modifier == wxS(
"μ" )[0] )
1020 else if( modifier ==
'm' || modifier ==
'L' )
1022 else if( modifier ==
'R' || modifier ==
'F' )
1024 else if( modifier ==
'k' || modifier ==
'K' )
1026 else if( modifier ==
'M' )
1028 else if( modifier ==
'G' )
1030 else if( modifier ==
'T' )
1032 else if( modifier ==
'P' )
1034 else if( modifier ==
'E' )
1054 value->Replace( wxS(
" " ), wxEmptyString );
1056 wxChar ambiguousSeparator =
'?';
1057 wxChar thousandsSeparator =
'?';
1058 bool thousandsSeparatorFound =
false;
1059 wxChar decimalSeparator =
'?';
1060 bool decimalSeparatorFound =
false;
1063 for(
int ii = (
int) value->length() - 1; ii >= 0; --ii )
1065 wxChar c = value->GetChar( ii );
1067 if( c >=
'0' && c <=
'9' )
1071 else if( c ==
'.' || c ==
',' )
1073 if( decimalSeparator !=
'?' || thousandsSeparator !=
'?' )
1077 if( c == decimalSeparator )
1079 if( thousandsSeparatorFound )
1081 else if( decimalSeparatorFound )
1084 decimalSeparatorFound =
true;
1086 else if( c == thousandsSeparator )
1091 thousandsSeparatorFound =
true;
1094 else if( ambiguousSeparator !=
'?' )
1098 if( c == ambiguousSeparator )
1101 thousandsSeparator = ambiguousSeparator;
1102 thousandsSeparatorFound =
true;
1103 decimalSeparator = c ==
'.' ?
',' :
'.';
1108 decimalSeparator = ambiguousSeparator;
1109 decimalSeparatorFound =
true;
1110 thousandsSeparator = c;
1111 thousandsSeparatorFound =
true;
1123 if( ( ii == 1 && value->GetChar( 0 ) ==
'0' ) || digits != 3 )
1125 decimalSeparator = c;
1126 decimalSeparatorFound =
true;
1127 thousandsSeparator = c ==
'.' ?
',' :
'.';
1131 ambiguousSeparator = c;
1144 if( decimalSeparator ==
'?' && thousandsSeparator ==
'?' )
1146 const struct lconv* lc = localeconv();
1148 decimalSeparator = lc->decimal_point[0];
1149 thousandsSeparator = decimalSeparator ==
'.' ?
',' :
'.';
1153 value->Replace( thousandsSeparator, wxEmptyString );
1154 value->Replace( decimalSeparator,
'.' );
1167 wxString strFWordBeg, strFWordMid, strFWordEnd;
1168 wxString strSWordBeg, strSWordMid, strSWordEnd;
1171 SplitString( fWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
1172 SplitString( sWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
1175 int isEqual = strFWordBeg.CmpNoCase( strSWordBeg );
1181 else if( isEqual < 0 )
1188 double lFirstNumber = 0;
1189 double lSecondNumber = 0;
1190 bool endingIsModifier =
false;
1195 strFWordMid.ToCDouble( &lFirstNumber );
1196 strSWordMid.ToCDouble( &lSecondNumber );
1198 endingIsModifier |=
ApplyModifier( lFirstNumber, strFWordEnd );
1199 endingIsModifier |=
ApplyModifier( lSecondNumber, strSWordEnd );
1201 if( lFirstNumber > lSecondNumber )
1203 else if( lFirstNumber < lSecondNumber )
1206 else if( !endingIsModifier )
1207 return strFWordEnd.CmpNoCase( strSWordEnd );
1216 wxString* strBeginning,
1217 wxString* strDigits,
1220 static const wxString separators( wxT(
".," ) );
1221 wxUniChar infix = 0;
1224 strBeginning->Empty();
1229 if( strToSplit.length() == 0 )
1235 for( ii = (strToSplit.length() - 1); ii >= 0; ii-- )
1237 if( wxIsdigit( strToSplit[ii] ) )
1244 *strBeginning = strToSplit;
1249 *strEnd = strToSplit.substr( ii + 1 );
1252 int position = ii + 1;
1254 for( ; ii >= 0; ii-- )
1257 wxUniChar c = strToSplit[ii];
1259 if( wxIsdigit( c ) )
1268 else if( separators.Find( strToSplit[ii] ) >= 0 )
1281 *strDigits = strToSplit.substr( 0, position );
1286 *strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
1287 *strBeginning = strToSplit.substr( 0, ii + 1 );
1292 strDigits->Replace( infix,
'.' );
1293 *strEnd = infix + *strEnd;
1307 int index = aStr.Len() - 1;
1311 const char chr = aStr.GetChar(
index );
1313 if( chr <
'0' || chr >
'9' )
1316 number += ( chr -
'0' ) * base;
1335 if( first_illegal_pos == std::string::npos )
1342 result.reserve( aName.length() + 16 );
1344 result.append( aName, 0, first_illegal_pos );
1346 for(
size_t i = first_illegal_pos; i < aName.length(); ++i )
1355 result.push_back( aReplaceChar );
1359 fmt::format_to( std::back_inserter(
result ),
"%{:02x}",
static_cast<unsigned char>( c ) );
1368 aName = std::move(
result );
1375 bool changed =
false;
1377 result.reserve( aName.Length() );
1380 for( wxString::iterator it = aName.begin(); it != aName.end(); ++it )
1382 if( illWChars.Find( *it ) != wxNOT_FOUND )
1387 result += wxString::Format(
"%%%02x", *it );
1398 aName = std::move(
result );
1404void wxStringSplit(
const wxString& aText, wxArrayString& aStrings, wxChar aSplitter )
1408 for(
unsigned ii = 0; ii < aText.Length(); ii++ )
1410 if( aText[ii] == aSplitter )
1412 aStrings.Add( tmp );
1421 if( !tmp.IsEmpty() )
1422 aStrings.Add( tmp );
1428 struct lconv* lc = localeconv();
1429 char sep = lc->decimal_point[0];
1430 unsigned sep_pos = aStringValue.Find( sep );
1435 unsigned min_len = sep_pos + aTrailingZeroAllowed + 1;
1437 while( aStringValue.Len() > min_len )
1439 if( aStringValue.Last() ==
'0' )
1440 aStringValue.RemoveLast();
1452 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1454 buf = fmt::format(
"{:.16f}", aValue );
1457 while( !buf.empty() && buf[buf.size() - 1] ==
'0' )
1464 if( buf[buf.size() - 1] ==
'.' )
1471 buf = fmt::format(
"{:.10g}", aValue );
1483 if( aValue != 0.0 && std::fabs( aValue ) <= 0.0001 )
1487 len = snprintf( buf,
sizeof( buf ),
"%.16f", aValue );
1489 while( --len > 0 && buf[len] ==
'0' )
1492 if( buf[len] ==
'.' || buf[len] ==
',' )
1501 len = snprintf( buf,
sizeof( buf ),
"%.10g", aValue );
1504 return std::string( buf, len );
1511 wxString line = wxString::FromUTF8( cstring );
1513 if( line.IsEmpty() )
1515 line = wxConvCurrent->cMB2WC( cstring );
1517 if( line.IsEmpty() )
1518 line = wxString::From8BitData( cstring );
1528 wxString line = wxString::FromUTF8( aString );
1530 if( line.IsEmpty() )
1532 line = wxConvCurrent->cMB2WC( aString.c_str() );
1534 if( line.IsEmpty() )
1535 line = wxString::From8BitData( aString.c_str() );
1544 wxString uriPathAndFileName;
1546 wxCHECK( aFileUri.StartsWith( wxS(
"file://" ), &uriPathAndFileName ), aFileUri );
1548 wxString tmp = uriPathAndFileName;
1549 wxString retv = wxS(
"file://" );
1551 tmp.Replace( wxS(
"\\" ), wxS(
"/" ) );
1552 tmp.Replace( wxS(
":" ), wxS(
"" ) );
1554 if( !tmp.IsEmpty() && tmp[0] !=
'/' )
1555 tmp = wxS(
"/" ) + tmp;
1566 std::pair<wxString, long> ParseAlphaNumericPin(
const wxString& pinNum )
1571 size_t numStart = pinNum.length();
1572 for(
int i =
static_cast<int>( pinNum.length() ) - 1; i >= 0; --i )
1574 if( !wxIsdigit( pinNum[i] ) )
1583 if( numStart < pinNum.length() )
1585 prefix = pinNum.Left( numStart );
1586 wxString numericPart = pinNum.Mid( numStart );
1587 numericPart.ToLong( &numValue );
1590 return { prefix, numValue };
1599 std::vector<wxString> expanded;
1601 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1602 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1604 if( hasOpenBracket || hasCloseBracket )
1606 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1610 expanded.push_back( aPinName );
1615 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1617 expanded.push_back( aPinName );
1621 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1624 while( start < inner.length() )
1626 size_t comma = inner.find(
',', start );
1627 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1628 part.Trim(
true ).Trim(
false );
1631 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1635 int dashPos = part.Find(
'-' );
1636 if( dashPos != wxNOT_FOUND )
1638 wxString startTxt = part.Left( dashPos );
1639 wxString endTxt = part.Mid( dashPos + 1 );
1640 startTxt.Trim(
true ).Trim(
false );
1641 endTxt.Trim(
true ).Trim(
false );
1643 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1644 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1646 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1651 expanded.push_back( aPinName );
1655 for(
long ii = startVal; ii <= endVal; ++ii )
1657 if( startPrefix.IsEmpty() )
1658 expanded.emplace_back( wxString::Format( wxT(
"%ld" ), ii ) );
1660 expanded.emplace_back( wxString::Format( wxT(
"%s%ld" ), startPrefix, ii ) );
1665 expanded.push_back( part );
1668 if( comma == wxString::npos )
1673 if( expanded.empty() )
1675 expanded.push_back( aPinName );
1690 const bool hasOpenBracket = aPinName.Contains( wxT(
"[" ) );
1691 const bool hasCloseBracket = aPinName.Contains( wxT(
"]" ) );
1693 if( hasOpenBracket || hasCloseBracket )
1695 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1703 if( !aPinName.StartsWith( wxT(
"[" ) ) || !aPinName.EndsWith( wxT(
"]" ) ) )
1706 const wxString inner = aPinName.Mid( 1, aPinName.Length() - 2 );
1711 while( start < inner.length() )
1713 size_t comma = inner.find(
',', start );
1714 wxString part = ( comma == wxString::npos ) ? inner.Mid( start ) : inner.Mid( start, comma - start );
1715 part.Trim(
true ).Trim(
false );
1719 start = ( comma == wxString::npos ) ? inner.length() : comma + 1;
1723 int dashPos = part.Find(
'-' );
1724 if( dashPos != wxNOT_FOUND )
1726 wxString startTxt = part.Left( dashPos );
1727 wxString endTxt = part.Mid( dashPos + 1 );
1728 startTxt.Trim(
true ).Trim(
false );
1729 endTxt.Trim(
true ).Trim(
false );
1731 auto [startPrefix, startVal] = ParseAlphaNumericPin( startTxt );
1732 auto [endPrefix, endVal] = ParseAlphaNumericPin( endTxt );
1734 if( startPrefix != endPrefix || startVal == -1 || endVal == -1 || startVal > endVal )
1743 count +=
static_cast<int>( endVal - startVal + 1 );
1751 if( comma == wxString::npos )
1789 std::vector<LOAD_MESSAGE> messages;
1791 if( aErrorString.IsEmpty() )
1799 wxStringTokenizer tokenizer( aErrorString, wxS(
"\n" ), wxTOKEN_STRTOK );
1801 while( tokenizer.HasMoreTokens() )
1803 wxString line = tokenizer.GetNextToken();
1806 if( line.StartsWith( wxS(
"from " ) ) )
1809 if( line.StartsWith( wxS(
"Library '" ) ) || line.Contains( wxS(
"Expecting" ) ) )
1810 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.