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

#include <Puma/CUnit.h>

+ Inheritance diagram for Puma::CUnit:

Description

Specialized token unit for C/C++ tokens.

Provides a streaming interface for easy scanning of C/C++ tokens using a Puma::CScanner object. The input stream is scanned either by calling Puma::CUnit::scan() or by using the stream manipulator Puma::endu.

Example:

Puma::CUnit unit(es)
unit << "int main() {" << std::endl;
unit << " int fac0 = 1;" << std::endl;
for (int i = 1; i < 10; i++) {
unit << " int fac" << i << " = " << i
<< " * fac" << (i-1) << ";" << std::endl;
}
unit << "}\n" << Puma::endu;
Specialized token unit for C/C++ tokens.
Definition: CUnit.h:52
An error stream is a special ErrorSink that prints out an error message as soon as it is complete.
Definition: ErrorStream.h:37
std::ostream & endu(std::ostream &outs)
End-of-unit stream manipulator.
Definition: CUnit.h:71


Public Member Functions

 CUnit (ErrorSink &err)
 Constructor. More...
 
virtual ~CUnit ()
 Destructor. More...
 
CScannerscanner () const
 Get the scanner used to scan the string stream. More...
 
void scan ()
 Scan the stream now. More...
 
- Public Member Functions inherited from Puma::Unit
 Unit ()
 Constructor. More...
 
 Unit (const List &list)
 Copy-constructor. More...
 
virtual ~Unit ()
 Destructor. More...
 
virtual void name (const char *name)
 Set the name of the unit (usually the file name). More...
 
char * name () const
 Get the name of the unit (usually the file name). More...
 
virtual void print (std::ostream &os) const
 Print the tokens of the unit on the given stream. More...
 
virtual bool isFile () const
 Check if this is a unit for a file. More...
 
virtual bool isMacroExp () const
 Check if this is a unit for a macro expansion. More...
 
virtual bool isTemplateInstance () const
 Check if this is a unit for a template instance. More...
 
UnitStatestate ()
 Get the state of the unit. More...
 
char * toString () const
 Serialize the tokens of the unit. More...
 
Tokenfirst () const
 Get the first token in the unit. More...
 
Tokenlast () const
 Get the last token in the unit. More...
 
Tokennext (const Token *token) const
 Get the next token of the given token. More...
 
Tokenprev (const Token *token) const
 Get the previous token of the given token. More...
 
- Public Member Functions inherited from Puma::List
 List ()
 Constructor. More...
 
 List (const List &copy)
 Copy-constructor. More...
 
 ~List ()
 Destructor. More...
 
Listoperator= (const List &copy)
 Assignment operator. More...
 
Listoperator+= (const List &list)
 Append the given list. More...
 
List operator+ (const List &list)
 Create a new list containing the elements of this list followed by the elements of the given list. More...
 
void clear ()
 Destroy the list elements. More...
 
void append (ListElement &element)
 Append an element to the list. More...
 
void prepend (ListElement &element)
 Prepend an element to the list. More...
 
void insert (ListElement *at, ListElement &element)
 Insert an element at the given list position. More...
 
void remove (ListElement *element)
 Remove the given element from the list. More...
 
void kill (ListElement *from, ListElement *to=(ListElement *) 0)
 Remove and destroy all elements between the given list elements. More...
 
void cut (List &out, ListElement *from, ListElement *to=(ListElement *) 0)
 Cut all elements between the given list elements. More...
 
Listcopy (ListElement *from=(ListElement *) 0, ListElement *to=(ListElement *) 0)
 Copy all elements between the given list elements. More...
 
void paste (ListElement *at, const List &l)
 Insert copies of the elements of the given list at the given list position. More...
 
void paste_before (ListElement *at, const List &l)
 Insert copies of the elements of the given list before the given list position. More...
 
void move (ListElement *at, List &l)
 Insert the elements of the given list at the given list position. More...
 
void move_before (ListElement *at, List &l)
 Insert the elements of the given list before the given list position. More...
 
bool empty () const
 Check if the list is empty. More...
 
const ListElementfirst () const
 Get the first element in the list. More...
 
const ListElementlast () const
 Get the last element in the list. More...
 
const ListElementnext (const ListElement *element) const
 Get the next element of the given element. More...
 
const ListElementprev (const ListElement *element) const
 Get the previous element of the given element. More...
 
- Public Member Functions inherited from Puma::Printable
virtual ~Printable ()
 Destructor. More...
 
virtual void print (std::ostream &os) const =0
 Print object information on the given output stream. More...
 

Constructor & Destructor Documentation

◆ CUnit()

Puma::CUnit::CUnit ( ErrorSink err)
inline

Constructor.

Parameters
errThe error stream on which to report errors.

◆ ~CUnit()

virtual Puma::CUnit::~CUnit ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ scan()

void Puma::CUnit::scan ( )

Scan the stream now.

Produces the token chain.

◆ scanner()

CScanner & Puma::CUnit::scanner ( ) const
inline

Get the scanner used to scan the string stream.