Tree Class Reference

A tree of file names, representing a directory hierarcy. More...

#include <file.h>

Collaboration diagram for Tree:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list< Tree * > children_t
 data storage type for the tree

Public Member Functions

void add_child (Tree *tree)
 add a child to the tree and give ownership thereof to the tree
void add_child (FileName const &name, FileStatus const &status)
 add child to this node (no error detection is done)
children_t const & children () const
 get children of this node
int depth () const
 Return the relative depth in of this node within the tree. The top item in the tree has depth of 0, its children have depth of 1, etc.
FileName name () const
 get name of this node
Treeoperator= (Tree const &r)
FileName path () const
 get pathname of this node -- as specified by parent hierarchy not by inquiring the current directory -- use convert_to_absolute_path if you need the complete pathname.
void remove_child (FileName const &name)
 remove a specified child of this node ( warning: O(n)!)
FileStatus const & status () const
 get info for this node
 Tree (std::string const &name, FileStatus const &status, Tree *parent=0, int depth=0)
 Tree (Tree const &r)
 copy constructor
 Tree (Tree *parent=0)
 ~Tree ()
 destructor

Private Attributes

children_t children_
 This node's children (if this is a dir).
int depth_
 Depth within the hierarchy, top = 0.
std::string name_
 This node's name.
Treeparent_
 This node's parent directory.
FileStatus status_
 This node's status.

Friends

class FileName

Detailed Description

A tree of file names, representing a directory hierarcy.

The FileName::Tree class is meant for implementing simplistic directory hierarchies. It is not a general purpose tool. See FileName::tree();

Definition at line 1297 of file file.h.


Member Typedef Documentation

typedef std::list<Tree*> children_t

data storage type for the tree

Definition at line 1306 of file file.h.


Constructor & Destructor Documentation

Tree ( Tree parent = 0  ) 

Construct an empty tree

Definition at line 1322 of file file.h.

Here is the caller graph for this function:

~Tree (  ) 

destructor

Definition at line 2236 of file file.cxx.

Tree ( Tree const &  r  ) 

copy constructor

Definition at line 2247 of file file.cxx.

Here is the call graph for this function:

Tree ( std::string const &  name,
FileStatus const &  status,
Tree parent = 0,
int  depth = 0 
)

Construct a tree node with no children but specified name and file info

Definition at line 1332 of file file.h.


Member Function Documentation

void add_child ( Tree tree  ) 

add a child to the tree and give ownership thereof to the tree

Definition at line 1376 of file file.h.

void add_child ( FileName const &  name,
FileStatus const &  status 
)

add child to this node (no error detection is done)

Definition at line 1370 of file file.h.

Here is the caller graph for this function:

children_t const& children (  )  const

get children of this node

Definition at line 1367 of file file.h.

Here is the caller graph for this function:

int depth (  )  const

Return the relative depth in of this node within the tree. The top item in the tree has depth of 0, its children have depth of 1, etc.

Definition at line 1362 of file file.h.

FileName name (  )  const

get name of this node

Definition at line 1353 of file file.h.

Here is the caller graph for this function:

Tree& operator= ( Tree const &  r  ) 

Definition at line 1342 of file file.h.

FileName path (  )  const

get pathname of this node -- as specified by parent hierarchy not by inquiring the current directory -- use convert_to_absolute_path if you need the complete pathname.

Definition at line 2288 of file file.cxx.

Here is the call graph for this function:

void remove_child ( FileName const &  name  ) 

remove a specified child of this node ( warning: O(n)!)

Definition at line 2266 of file file.cxx.

FileStatus const& status (  )  const

get info for this node

Definition at line 1350 of file file.h.

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class FileName [friend]

Definition at line 1308 of file file.h.


Member Data Documentation

children_t children_ [private]

This node's children (if this is a dir).

Definition at line 1314 of file file.h.

int depth_ [private]

Depth within the hierarchy, top = 0.

Definition at line 1318 of file file.h.

std::string name_ [private]

This node's name.

Definition at line 1313 of file file.h.

Tree* parent_ [private]

This node's parent directory.

Definition at line 1316 of file file.h.

FileStatus status_ [private]

This node's status.

Definition at line 1312 of file file.h.


The documentation for this class was generated from the following files:
Generated on Wed Feb 29 22:55:28 2012 for CXXUtilities by  doxygen 1.6.3