Author Topic: Compiler Messages: Sorting by Message (I'm stuck trying to do this...)  (Read 28559 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Hi guys. I'm sort of stuck trying to add a "Sort by Message" item in the compiler messages. I've needed to do it when linting a big number of javascript files (the lint is my "compiler" :P ). And there were tons of trivial errors that I wanted to tackle. And I said: Why not sort the compiler messages by the error message?

So, I began writing the code, when suddenly...

Code
WX_DECLARE_OBJARRAY(CompileError, ErrorsArray);

How on Earth do you sort a wxWhateverObjArray? I googled and searched the wxWidgets documentation, and there's no such thing as WX_DECLARE_SORTED_OBJARRAY.

Any ideas?
(Also, do we still have to rely on the WX_DECLARE macros? We're in 2011 and the STL are supported everywhere)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Compiler Messages: Sorting by Message (I'm stuck trying to do this...)
« Reply #1 on: November 03, 2012, 07:11:23 pm »
Have you read this: http://docs.wxwidgets.org/2.8/wx_wxarray.html

Looking in the docs wxSortedArray is not a good candidate for this case, because addition in the array is slower (O(log(N)) and you need to sort the array at the end.
In my opinion wxArray should never be used, because it has pretty strange const rules, see the operator[] which may lead to pretty strange and hard to fix bugs.
If you need an array you can use a vector or a deque or even one of the map/set classes in STL. You can sort them easily using std::sort.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]