J
Jonathan Wilson
I am looking for a C++ class library that can store data in a tree.
The class library needs to be:
1.Available under a licence like GPL, LGPL or BSD so I can use it in my GPL
program
and 2.Usable on multiple compilers (specificly, Visual C++ on windows and
GCC 3.x MingW on windows. If it works on GCC on Linux, thats even better
but not essential)
What I am storing in this tree is data for a directory tree (its going to
represent the directory tree in a program for working with compressed files
such as .zip or .rar). There will be one root directory node and subnodes
(which might be directory nodes or file nodes). Directory nodes will have
subnodes (unless they are empty of course). File nodes do not have
subnodes. Both directory and file nodes will store a name plus a per-node
structure (which stores different data for files and directories but
provides a way to tell between them)
5 operations will be performed on this tree:
1.Add a new node, either directory or file, given its full path and
per-node data
2.Sort all subnodes of a given node by the name (or better yet, manage
things so that when added, they get sorted automaticly so that node 1 is
the first node alphabeticly and so on)
3.Retrieve a node given its full "path" within the tree
4.Retrieve the subnodes of a given node, given its full "path" within the
tree and a number specifying which subnode to retrieve (for example
retrieve subnode 1 of node abc\def\ghi). This is needed to provide a way to
retrieve all files and folders in a directory to display them in the UI for
my archiver.
5.Walk the tree, deleting the nodes and the per-node structures.
So, it should ideally be able to do these operations efficiantly,
especially no 4
Does a sutable class (or one that could be adapted) already exist?
The class library needs to be:
1.Available under a licence like GPL, LGPL or BSD so I can use it in my GPL
program
and 2.Usable on multiple compilers (specificly, Visual C++ on windows and
GCC 3.x MingW on windows. If it works on GCC on Linux, thats even better
but not essential)
What I am storing in this tree is data for a directory tree (its going to
represent the directory tree in a program for working with compressed files
such as .zip or .rar). There will be one root directory node and subnodes
(which might be directory nodes or file nodes). Directory nodes will have
subnodes (unless they are empty of course). File nodes do not have
subnodes. Both directory and file nodes will store a name plus a per-node
structure (which stores different data for files and directories but
provides a way to tell between them)
5 operations will be performed on this tree:
1.Add a new node, either directory or file, given its full path and
per-node data
2.Sort all subnodes of a given node by the name (or better yet, manage
things so that when added, they get sorted automaticly so that node 1 is
the first node alphabeticly and so on)
3.Retrieve a node given its full "path" within the tree
4.Retrieve the subnodes of a given node, given its full "path" within the
tree and a number specifying which subnode to retrieve (for example
retrieve subnode 1 of node abc\def\ghi). This is needed to provide a way to
retrieve all files and folders in a directory to display them in the UI for
my archiver.
5.Walk the tree, deleting the nodes and the per-node structures.
So, it should ideally be able to do these operations efficiantly,
especially no 4
Does a sutable class (or one that could be adapted) already exist?