PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::FileUnit Class Reference

#include <Puma/FileUnit.h>

+ Inheritance diagram for Puma::FileUnit:

Description

Special Unit for files.

Holds its last save location, the absolute path of the file, and the source project the file belongs to.

Public Member Functions

 FileUnit ()
 Constructor.
 
 FileUnit (Unit &unit)
 Constructor.
 
 FileUnit (const List &list)
 Copy-constructor.
 
virtual ~FileUnit ()
 Destructor.
 
virtual void name (const char *filename)
 Set the name of the unit, i.e.
 
void setLocation (const char *location)
 Set the last save location of the file in the file system.
 
char * lastLocation () const
 Get the last save location of the file in the file system.
 
char * absolutePath () const
 Get the absolute version of the filename.
 
bool isFile () const
 Check if this unit refers to a file.
 
bool belongsTo (Project &project)
 Check if the file belongs to the given source project.
 
- Public Member Functions inherited from Puma::Unit
 Unit ()
 Constructor.
 
 Unit (const List &list)
 Copy-constructor.
 
virtual ~Unit ()
 Destructor.
 
char * name () const
 Get the name of the unit (usually the file name).
 
virtual void print (std::ostream &os) const
 Print the tokens of the unit on the given stream.
 
virtual bool isMacroExp () const
 Check if this is a unit for a macro expansion.
 
virtual bool isTemplateInstance () const
 Check if this is a unit for a template instance.
 
UnitStatestate ()
 Get the state of the unit.
 
char * toString () const
 Serialize the tokens of the unit.
 
Tokenfirst () const
 Get the first token in the unit.
 
Tokenlast () const
 Get the last token in the unit.
 
Tokennext (const Token *token) const
 Get the next token of the given token.
 
Tokenprev (const Token *token) const
 Get the previous token of the given token.
 
- Public Member Functions inherited from Puma::List
 List ()
 Constructor.
 
 List (const List &copy)
 Copy-constructor.
 
 ~List ()
 Destructor.
 
Listoperator= (const List &copy)
 Assignment operator.
 
Listoperator+= (const List &list)
 Append the given list.
 
List operator+ (const List &list)
 Create a new list containing the elements of this list followed by the elements of the given list.
 
void clear ()
 Destroy the list elements.
 
void append (ListElement &element)
 Append an element to the list.
 
void prepend (ListElement &element)
 Prepend an element to the list.
 
void insert (ListElement *at, ListElement &element)
 Insert an element at the given list position.
 
void remove (ListElement *element)
 Remove the given element from the list.
 
void kill (ListElement *from, ListElement *to=(ListElement *) 0)
 Remove and destroy all elements between the given list elements.
 
void cut (List &out, ListElement *from, ListElement *to=(ListElement *) 0)
 Cut all elements between the given list elements.
 
Listcopy (ListElement *from=(ListElement *) 0, ListElement *to=(ListElement *) 0)
 Copy all elements between the given list elements.
 
void paste (ListElement *at, const List &l)
 Insert copies of the elements of the given list at the given list position.
 
void paste_before (ListElement *at, const List &l)
 Insert copies of the elements of the given list before the given list position.
 
void move (ListElement *at, List &l)
 Insert the elements of the given list at the given list position.
 
void move_before (ListElement *at, List &l)
 Insert the elements of the given list before the given list position.
 
bool empty () const
 Check if the list is empty.
 
const ListElementfirst () const
 Get the first element in the list.
 
const ListElementlast () const
 Get the last element in the list.
 
const ListElementnext (const ListElement *element) const
 Get the next element of the given element.
 
const ListElementprev (const ListElement *element) const
 Get the previous element of the given element.
 
- Public Member Functions inherited from Puma::Printable
virtual ~Printable ()
 Destructor.
 

Constructor & Destructor Documentation

◆ FileUnit() [1/3]

Puma::FileUnit::FileUnit ( )
inline

Constructor.

◆ FileUnit() [2/3]

Puma::FileUnit::FileUnit ( Unit & unit)
inline

Constructor.

Parameters
unitThe unit representing the file.

◆ FileUnit() [3/3]

Puma::FileUnit::FileUnit ( const List & list)
inline

Copy-constructor.

Parameters
listThe list of tokens representing the file.

◆ ~FileUnit()

Puma::FileUnit::~FileUnit ( )
inlinevirtual

Destructor.

Frees the tokens.

Member Function Documentation

◆ absolutePath()

char * Puma::FileUnit::absolutePath ( ) const
inline

Get the absolute version of the filename.

Returns
The absolute filename.

◆ belongsTo()

bool Puma::FileUnit::belongsTo ( Project & project)

Check if the file belongs to the given source project.

Parameters
projectThe source project.

◆ isFile()

bool Puma::FileUnit::isFile ( ) const
inlinevirtual

Check if this unit refers to a file.

Returns
Always returns true.

Reimplemented from Puma::Unit.

◆ lastLocation()

char * Puma::FileUnit::lastLocation ( ) const
inline

Get the last save location of the file in the file system.

Returns
The location of the file.

◆ name()

virtual void Puma::FileUnit::name ( const char * filename)
virtual

Set the name of the unit, i.e.

the filename.

Parameters
filenameThe name of the unit.

Reimplemented from Puma::Unit.

◆ setLocation()

void Puma::FileUnit::setLocation ( const char * location)

Set the last save location of the file in the file system.

Parameters
locationThe location in the file system.