|
Get the Redbook. What you ask is not a trivial question.
earl
|
|
|
|
|
Please do not get offended...
There are free spell checkers you can use on your posts even in the browser, I also don't have English as my natural language, if you can't make your thoughts understandable, the ratio of replies will be smaller...
/// HACK: Don't PANIC ...
http://en.wikibooks.org/wiki/User:Panic2k4
|
|
|
|
|
Does anyone know of a class that parses C/C++ code (like the classview tree in VS)?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Parse how? You mean a lexer?
|
|
|
|
|
earl wrote: Parse how? You mean a lexer?
I'm not sure what it's called else I would have googled it.... I want to extract structs, typedefs, classes, externs, globals, etc. the same way the class-view tree does in Visual Studio. I don't know what the act of doing such is called, other than "parsing".
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Man, that's not a trivial thing to do.
To start you'll need a lexer -- takes text and determines if it's valid C++. This alone takes some doing, cause C++ isn't the most syntactically pretty language around. Don't try and do it yourself or you'll die of old age; instead, write a grammer and lean on a lexer.
Then you'll need a parser; it takes the output from a lexer and typically gives you a structure tree.
Grab the dragon book and read about compiler construction; you're building the first two or three stages of one.
For available tools, try lex, yacc, and bison.
earl
|
|
|
|
|
Parsing C++ is insanely difficult.
You could try hacking the gcc parser (hard) or maybe take a look at this[^]. It's a long time since I looked at PCCTS but IIRC, it seemed to work
I use CCCC[^] for metrics sometimes and that has a parser as well.
0 bottles of beer on the wall, 0 bottles of beer, you take 1 down, pass it around, 4294967295 bottles of beer on the wall.
Awasu 2.2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Hello,
I have a list control item with a given amount of columns and respective headers. I would now like to add some sorting functionality, where, upon clicking the header of the respective column, it sorts alphabetically. Are there any functions to accomplish this?
|
|
|
|
|
BOOL SortItems(<br />
PFNLVCOMPARE pfnCompare,<br />
DWORD_PTR dwData <br />
);
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
You'll have to create a compare function to handle how it will sort the items, but after that you can just call SortItems. See the MSDN documentation for details and an example.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
aafcls wrote: Are there any functions to accomplish this?
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
okay but what action item will take care of the header clicking functionality, because from there I can call sorting method.
|
|
|
|
|
|
In your CListView /CListCtrl -derived class, provide a handler for the HDN_ITEMCLICK notification. Call the SortItems() method from there. See here for more.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
FarPointer wrote: Please check this out :-
Why (send this to me)? I know very well how to sort a list control.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well to first add the notification for HDN_ITEMCLICK is tough:-
why because the on notify macro is as follows
ON_NOTIFY( wNotifyCode, id, memberFxn ) and the id of the header control is zero unless explicitly set .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
FarPointer wrote: Well to first add the notification for HDN_ITEMCLICK is tough:-
Compared to what, chewing gum? It gets added to the message map just like any other. How's that tough?
FarPointer wrote: why because the on notify macro is as follows
ON_NOTIFY( wNotifyCode, id, memberFxn )
Yeah, so?
FarPointer wrote: ...the id of the header control is zero unless explicitly set .
Of course it's zero, and has been since the control's inception. Why would it need to be anything else?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well not compared to chewing gum
ya my mistake i was expecting the message map to be like this:-
ON_NOTIFY( HDN_ITEMCLICK, 0, OnHeaderClick)
but it will be like this i guess
ON_NOTIFY( HDN_ITEMCLICK, IDC_LIST, OnHeaderClick)
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
are there any available comparison functions just for a simple list control for a clicked-on header, to be passed to SortItem?
|
|
|
|
|
Other than the one I already provided? It doesn't get much simpler.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
are you referring to the CompareFunction in the article you sent?
in that case, would I have to make use of "GetItemText" to fill in the "items" in CompareFunction? i'm just not sure how to implement this with a list of unknown quantity of items..
|
|
|
|
|
aafcls wrote: in that case, would I have to make use of "GetItemText"
No. You would cast lParam1 and lParam2 to the appropriate pointer value (the pointer value used with SetItemData() ).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am very sorry I do not understand.
I do not make use of SetItemData().
All I have is my list control where I have a few InsertColumn()s and SetItemText() accordingly.
When you tell me to cast these as pointers
int CALLBACK CompareFunction(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
...pointing to what exactly?
|
|
|
|
|
Have you tried the sample code in the link David Crow gave you?
They probably point to either an LVITEM or some MFC wrapper class. This information was obtained by reading the docs for the CListCtrl class; you get there by clicking up from DC's link.
earl
|
|
|
|