hi guys, just want to show some of my current progress.
The Tree class can already add items, and serialize its structure into XML format. It can also dump the node structure in a nice graphical way. Look!
mytree->AddItem(_T("physics"),_T("1 - uno"));
mytree->AddItem(_T("physiology"),_T("2 - dos"));
mytree->AddItem(_T("psychic"),_T("3 - tres"));
results in:
- "" (0)
\- "p" (4)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sychic" (5)
The numbers between parenthesis are the node id's.
Unfortunately, adding another item screws up the tree, so I'm still in the process of debugging. But at least I have something now :)
I also have to thank Thomas for his valuable advice on using the STL classes like vector and map. They saved a lot of work!
Good news people! It seems I have fixed all bugs in the tree's adding of nodes.
Adding word: physics
1 items in the tree
- "" (0)
\- "physics" (1)
---
Adding word: physiology
2 items in the tree
- "" (0)
\- "physi" (2)
+- "cs" (1)
\- "ology" (3)
---
Adding word: psychics
3 items in the tree
- "" (0)
\- "p" (4)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sychics" (5)
---
Adding word: psychotic
4 items in the tree
- "" (0)
\- "p" (4)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "ics" (5)
\- "otic" (7)
---
Adding word: paranormal
5 items in the tree
- "" (0)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "ics" (5)
\- "otic" (7)
---
Adding word: psychiatrist
6 items in the tree
- "" (0)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrist" (10)
| \- "cs" (5)
\- "otic" (7)
---
Adding word: psychiatrists
7 items in the tree
- "" (0)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrists" (10)
| \- "cs" (5)
\- "otic" (7)
---
Adding word: psychic
8 items in the tree
- "" (0)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrists" (10)
| \- "cs" (5)
\- "otic" (7)
---
Adding word: psychi
9 items in the tree
- "" (0)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrists" (10)
| \- "cs" (5)
\- "otic" (7)
---
Adding word: ghosts
10 items in the tree
- "" (0)
+- "ghosts" (11)
\- "p" (4)
+- "aranormal" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrists" (10)
| \- "cs" (5)
\- "otic" (7)
---
Adding word: paranormals
11 items in the tree
- "" (0)
+- "ghosts" (11)
\- "p" (4)
+- "aranormals" (8)
+- "hysi" (2)
| +- "cs" (1)
| \- "ology" (3)
\- "sych" (6)
+- "i" (9)
| +- "atrists" (10)
| \- "cs" (5)
\- "otic" (7)
---
I haven't finished testing the class, but just in case, I'm sending a backup of the tree class to the /downloads directory. Its name is searchtree.zip.
Here's the results, part deux ;-)
I added some items, and then queried the contents of the tree.
The following " => " sequences are the results of the queries.
'physics' => ' 1 - uno'
'physiology' => ' 2 - dos'
'psychics' => ' 3 - tres'
'psychotic' => ' 4 - cuatro'
'paranormal' => ' 5 - cinco'
'psychiatrist' => ' 6 - seis'
'psychiatrists' => ' 7 - siete'
'psychi' => ' 8 - ocho'
'ghosts' => ' 9 - nueve'
'paranormals' => '10 - diez'
'blah' => ''
Adding item: blah => bleh
'blah' => 'bleh'
'' => 'this is the root node :P' (I did this to test if i
could add a value to the empty string)
'psychic' => '' (Notice that here even when 'psychic'
is contained in the tree, it doesn't have a corresponding item)
Clearing tree...
'' => 'this is the root node :)'
(i assigned this after clearing the tree)
'physics' => ''
'physiology' => ''
'psychics' => ''
'psychotic' => ''
'paranormal' => ''
'psychiatrist' => ''
'psychiatrists' => ''
'psychi' => ''
'ghosts' => ''
'paranormals' => ''
'blah' => ''
1 items in the tree
- "" (0)
---
It seems to work, alright. I'll upload the zip now. I think I'm ready now to start working on the codecompletion improvements :)
Looks really nice, great work :)
But you should also add it to the linux make system. Without it the compilation process doesn't abort (I wonder why this is the case) but Code::Blocks failes to load the plugin. After adding the two new source-files to the build system and re-compiling the plugin it seems to work fine. (Yet, I didn't check if the problem with "follow global includes" occures here, too.)
Thus, you should apply this little patch:
Index: src/plugins/codecompletion/Makefile.am
===================================================================
--- src/plugins/codecompletion/Makefile.am (revision 1584)
+++ src/plugins/codecompletion/Makefile.am (working copy)
@@ -24,7 +24,8 @@
parser/parser.cpp \
parser/parserthread.cpp \
parser/token.cpp \
- parser/tokenizer.cpp
+ parser/tokenizer.cpp \
+ parser/searchtree.cpp
noinst_HEADERS = cclist.h \
cclistctrl.h \
@@ -37,4 +38,5 @@
parser/parser.h \
parser/parserthread.h \
parser/token.h \
- parser/tokenizer.h
+ parser/tokenizer.h \
+ parser/searchtree.h
Hey rick rev1587 is not compiling. You have these two lines in searchtree.cpp (223, 232):
result << _T(" <item depth=\"") << u2s(item->first) << _T("\" itemid=\"" << u2s(item->second) << "\"") << _T(" />\n");
result << _T(" <child char=\"") << SerializeString(string(link->first)) << _T("\" nodeid=\"" << u2s(link->second) << "\"") << _T(" />\n");
That I think should be this:
result << _T(" <item depth=\"") << u2s(item->first) << _T("\" itemid=\"") << u2s(item->second) << _T("\"") << _T(" />\n");
result << _T(" <child char=\"") << SerializeString(string(link->first)) << _T("\" nodeid=\"") << u2s(link->second) << _T("\"") << _T(" />\n");