Thread Previous • Date Previous • Date Next • Thread Next |
Okay, I came up with a solution for which I'm not so sure if it would be generally accepted: http://pastebin.com/Y7rVzHV1It is similar to a string comparison (for string sorting) but unlike the usual strncmp() or strncasecmp() functions, when digits are encountered in a string, they are converted to a number and this is the number value which is taken in account for comparison.I've written my own back then for the pin table, factored out into eeschema/pin_number.cpp. This should be merged with the other implementations then in the same process, and possibly generalized (there is special treatment of "V" as a decimal point if it is placed between numbers, for example, that may not always be appropriate).
It should compile as is.The big part of that code is made off the class CONST_WX_STRING_VIEW, which does nothing more than encapsulate a pair of wxString iterators, dereferencing yields the beginning character, incrementing increments the begin iterator etc. like in "ranges". I found such a range helper immensely helpful for parsing generally, but it might be a bit bulky to include only for StrNumCmp. Simon, I tried to mimic the behaviour of your function, see the below the comment "Gyros-Mode", I doubt that the float-parsing is particularly clever however. Feel free to drop me compatible code that I could use instead.
Cheers! Michael
Thread Previous • Date Previous • Date Next • Thread Next |