libxcks  0.1.0.1
libxcks::XCKSDirStruct::Element Class Referenceabstract

An element of the directory structure for XCKS files. More...

Inheritance diagram for libxcks::XCKSDirStruct::Element:
Collaboration diagram for libxcks::XCKSDirStruct::Element:

Public Member Functions

 Element ()=delete
 Deleted default constructor. More...
 
 Element (const Element &)=delete
 Deleted copy constructor. More...
 
Elementoperator= (const Element &)=delete
 Deleted assignment operator. More...
 
 Element (const string &elementName, Element *parentElement, Element *previousElement)
 Constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
virtual bool hasChild () const
 Does the element have a child? More...
 
virtual bool hasPrevious () const final
 Does the element have a previous element? More...
 
virtual bool hasNext () const final
 Does the element have a following element? More...
 
virtual bool hasParent () const final
 Does the element have a parent? More...
 
virtual bool isAFile () const =0
 Does the element is a file? More...
 
virtual bool hasElement (const string &elementName) const final
 Does an element exist with the given name in the current level? More...
 
virtual string getName () const final
 Gets the name of the element. More...
 
virtual ElementgetChild () const
 Gets the child of the element. More...
 
virtual void setChild (Element *newChild)
 Sets the child of the element. More...
 
virtual ElementgetPrevious () const final
 Gets the previous element of the element. More...
 
virtual void setPrevious (Element *newPrevious) final
 Sets the previous element of the element. More...
 
virtual ElementgetNext () const final
 Gets the following element of the element. More...
 
virtual void setNext (Element *newNext) final
 Sets the following element of the element. More...
 
virtual ElementgetParent () const final
 Gets the parent element of the element. More...
 
virtual void getParent (Element *newParent) final
 Sets the parent element of the element. More...
 
virtual void * getData () const
 Gets the data associated with the element. More...
 
virtual void setData (void *newData)
 Sets the data associated with the element. More...
 
virtual ElementgetElement (const string &elementName, Element **lastElement=nullptr) const final
 Gets the element with the given name in the current level. More...
 
bool addFile (const ArrayString &dirs, const size_t cur, const string &filename, void *data=nullptr)
 Adds a new file in the directory structure. More...
 
XCKSDirStruct::FilegetNextFile () const
 Gets the next file in the directory structure. More...
 

Protected Member Functions

ElementcreateDirsAndAddFile (const ArrayString &dirs, const size_t cur, const string &filename, void *data=nullptr)
 Creates directories and adds a new file in the directory structure. More...
 
XCKSDirStruct::FilegetNextFileRec () const
 Gets the next file in the directory structure (recursive). More...
 
XCKSDirStruct::FilegetNextFile (const bool calledFromChild) const
 Gets the next file in the directory structure. More...
 

Protected Attributes

string name
 The name of the element. More...
 
Elementparent
 Address of the parent. More...
 
Elementprevious
 Address of the previous element at the same level. More...
 
Elementnext
 Address of the next element at the same level. More...
 

Friends

class XCKSDirStruct::const_file_iterator
 

Detailed Description

An element of the directory structure for XCKS files.

It could be a directory or a file.

Definition at line 102 of file xcksfilewriter.cpp.

Constructor & Destructor Documentation

◆ Element() [1/3]

libxcks::XCKSDirStruct::Element::Element ( )
delete

Deleted default constructor.

◆ Element() [2/3]

libxcks::XCKSDirStruct::Element::Element ( const Element )
delete

Deleted copy constructor.

◆ Element() [3/3]

libxcks::XCKSDirStruct::Element::Element ( const string &  elementName,
XCKSDirStruct::Element parentElement,
XCKSDirStruct::Element previousElement 
)

Constructor.

Parameters
elementNameName of the element (file or directory).
parentElementParent of the element.
previousElementAddress of the previous element (can be nullptr if is the first element of the level).

Definition at line 557 of file xcksfilewriter.cpp.

◆ ~Element()

libxcks::XCKSDirStruct::Element::~Element ( )
virtual

Destructor.

Definition at line 572 of file xcksfilewriter.cpp.

Member Function Documentation

◆ addFile()

bool libxcks::XCKSDirStruct::Element::addFile ( const ArrayString dirs,
const size_t  cur,
const string &  filename,
void *  data = nullptr 
)

Adds a new file in the directory structure.

Parameters
dirsThe array of directories where the file is.
curThe current directory.
filenameThe name of the file to add.
dataThe data associated with the file.
Returns
true is the file has been created in the structure, false otherwise.

Definition at line 654 of file xcksfilewriter.cpp.

◆ createDirsAndAddFile()

XCKSDirStruct::Element * libxcks::XCKSDirStruct::Element::createDirsAndAddFile ( const ArrayString dirs,
const size_t  cur,
const string &  filename,
void *  data = nullptr 
)
protected

Creates directories and adds a new file in the directory structure.

Parameters
dirsThe array of directories where the file is.
curThe current directory.
filenameThe name of the file to add.
dataThe data associated with the file.
Returns
The address of the first created directory.

Definition at line 718 of file xcksfilewriter.cpp.

◆ getChild()

virtual Element* libxcks::XCKSDirStruct::Element::getChild ( ) const
inlinevirtual

Gets the child of the element.

Returns
The child of the element or nullptr if the element hasn't a child.

Reimplemented in libxcks::XCKSDirStruct::Directory.

Definition at line 180 of file xcksfilewriter.cpp.

◆ getData()

virtual void* libxcks::XCKSDirStruct::Element::getData ( ) const
inlinevirtual

Gets the data associated with the element.

Returns
The data associated with the element.

Reimplemented in libxcks::XCKSDirStruct::File.

Definition at line 244 of file xcksfilewriter.cpp.

◆ getElement()

XCKSDirStruct::Element * libxcks::XCKSDirStruct::Element::getElement ( const string &  elementName,
XCKSDirStruct::Element **  lastElement = nullptr 
) const
finalvirtual

Gets the element with the given name in the current level.

Parameters
[in]elementNameName of the element to search in the current level.
[out]lastElementIf not nullptr and the given element isn't found, it will contains the address of the last element in the level.
Returns
The element with the given name in the current level or nullptr if an element with the given name doesn't exist in the current level.

Definition at line 617 of file xcksfilewriter.cpp.

◆ getName()

virtual string libxcks::XCKSDirStruct::Element::getName ( ) const
inlinefinalvirtual

Gets the name of the element.

Returns
The name of the element.

Definition at line 172 of file xcksfilewriter.cpp.

◆ getNext()

virtual Element* libxcks::XCKSDirStruct::Element::getNext ( ) const
inlinefinalvirtual

Gets the following element of the element.

Returns
The following element of the element or nullptr if the element hasn't a following element.

Definition at line 215 of file xcksfilewriter.cpp.

◆ getNextFile() [1/2]

XCKSDirStruct::File * libxcks::XCKSDirStruct::Element::getNextFile ( ) const

Gets the next file in the directory structure.

Returns
A pointer on the next file in the directory structure or nullptr if there is no more files in it.

Definition at line 842 of file xcksfilewriter.cpp.

◆ getNextFile() [2/2]

XCKSDirStruct::File * libxcks::XCKSDirStruct::Element::getNextFile ( const bool  calledFromChild) const
protected

Gets the next file in the directory structure.

Parameters
calledFromChildMust be true if called from a child, false otherwise.
Returns
A pointer on the next file in the directory structure or nullptr if there is no more files in it.

Definition at line 787 of file xcksfilewriter.cpp.

◆ getNextFileRec()

XCKSDirStruct::File * libxcks::XCKSDirStruct::Element::getNextFileRec ( ) const
protected

Gets the next file in the directory structure (recursive).

Returns
A pointer on the next file in the directory structure or nullptr if there is no more files in it.

Definition at line 746 of file xcksfilewriter.cpp.

◆ getParent() [1/2]

virtual Element* libxcks::XCKSDirStruct::Element::getParent ( ) const
inlinefinalvirtual

Gets the parent element of the element.

Returns
The parent element of the element or nullptr if the element hasn't a parent element.

Definition at line 230 of file xcksfilewriter.cpp.

◆ getParent() [2/2]

virtual void libxcks::XCKSDirStruct::Element::getParent ( Element newParent)
inlinefinalvirtual

Sets the parent element of the element.

Parameters
newParentThe parent element of the element.

Definition at line 237 of file xcksfilewriter.cpp.

◆ getPrevious()

virtual Element* libxcks::XCKSDirStruct::Element::getPrevious ( ) const
inlinefinalvirtual

Gets the previous element of the element.

Returns
The previous element of the element or nullptr if the element hasn't a previous element.

Definition at line 200 of file xcksfilewriter.cpp.

◆ hasChild()

virtual bool libxcks::XCKSDirStruct::Element::hasChild ( ) const
inlinevirtual

Does the element have a child?

Returns
true if the element has a child, false otherwise.

Reimplemented in libxcks::XCKSDirStruct::Directory.

Definition at line 134 of file xcksfilewriter.cpp.

◆ hasElement()

bool libxcks::XCKSDirStruct::Element::hasElement ( const string &  elementName) const
finalvirtual

Does an element exist with the given name in the current level?

Parameters
elementNameName of the element to search in the current level.
Returns
true if an element with the given name exists in the current level, false otherwise.

Definition at line 589 of file xcksfilewriter.cpp.

◆ hasNext()

virtual bool libxcks::XCKSDirStruct::Element::hasNext ( ) const
inlinefinalvirtual

Does the element have a following element?

Returns
true if the element has a following element, false otherwise.

Definition at line 148 of file xcksfilewriter.cpp.

◆ hasParent()

virtual bool libxcks::XCKSDirStruct::Element::hasParent ( ) const
inlinefinalvirtual

Does the element have a parent?

Returns
true if the element has a parent, false otherwise.

Definition at line 155 of file xcksfilewriter.cpp.

◆ hasPrevious()

virtual bool libxcks::XCKSDirStruct::Element::hasPrevious ( ) const
inlinefinalvirtual

Does the element have a previous element?

Returns
true if the element has a previous element, false otherwise.

Definition at line 141 of file xcksfilewriter.cpp.

◆ isAFile()

virtual bool libxcks::XCKSDirStruct::Element::isAFile ( ) const
pure virtual

Does the element is a file?

Returns
true if the element is a file, false otherwise.

Implemented in libxcks::XCKSDirStruct::Directory, and libxcks::XCKSDirStruct::File.

◆ operator=()

Element& libxcks::XCKSDirStruct::Element::operator= ( const Element )
delete

Deleted assignment operator.

◆ setChild()

virtual void libxcks::XCKSDirStruct::Element::setChild ( Element newChild)
inlinevirtual

Sets the child of the element.

Remarks
Must be only called on element of directory type.
Warning
The default implementation does nothing and always generate an assertion error.
Parameters
newChildThe new child of the element.

Reimplemented in libxcks::XCKSDirStruct::Directory.

Definition at line 192 of file xcksfilewriter.cpp.

◆ setData()

virtual void libxcks::XCKSDirStruct::Element::setData ( void *  newData)
inlinevirtual

Sets the data associated with the element.

Remarks
The data associated with the element is not owned by the element and must be deleted by the caller.
Must be only called on element of file type.
Warning
The default implementation does nothing and always generate an assertion error.
Parameters
newDataThe data associated with the element.

Reimplemented in libxcks::XCKSDirStruct::File.

Definition at line 259 of file xcksfilewriter.cpp.

◆ setNext()

virtual void libxcks::XCKSDirStruct::Element::setNext ( Element newNext)
inlinefinalvirtual

Sets the following element of the element.

Parameters
newNextThe following element of the element.

Definition at line 222 of file xcksfilewriter.cpp.

◆ setPrevious()

virtual void libxcks::XCKSDirStruct::Element::setPrevious ( Element newPrevious)
inlinefinalvirtual

Sets the previous element of the element.

Parameters
newPreviousThe previous element of the element.

Definition at line 207 of file xcksfilewriter.cpp.

Member Data Documentation

◆ name

string libxcks::XCKSDirStruct::Element::name
protected

The name of the element.

Definition at line 108 of file xcksfilewriter.cpp.

◆ next

Element* libxcks::XCKSDirStruct::Element::next
protected

Address of the next element at the same level.

Definition at line 111 of file xcksfilewriter.cpp.

◆ parent

Element* libxcks::XCKSDirStruct::Element::parent
protected

Address of the parent.

Definition at line 109 of file xcksfilewriter.cpp.

◆ previous

Element* libxcks::XCKSDirStruct::Element::previous
protected

Address of the previous element at the same level.

Definition at line 110 of file xcksfilewriter.cpp.


The documentation for this class was generated from the following file: