Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

AddTraceString Class Reference

The context class for the State Design Pattern. More...

#include <addTraceString.h>

Collaboration diagram for AddTraceString:

Collaboration graph
List of all members.

Public Member Functions

 AddTraceString ()
 Set the default context for the state pattern.
 ~AddTraceString ()
 A do nothing Dtor.
void addTraceString (const char *fileName)
 Add traceString to a single file.
void lpSet (int i)
void lpAdd (int i)
int lp ()
void lbSet (int i)
void lbAdd (int i)
int lb ()
void setFuncName (const char *fdec)
std::string & funcName ()
void setFuncArgs (const char *s)
void funcArgsAppend (const char *s)
std::string & funcArgs ()
void changeState (State *s)
Tbl & buildTbl ()
void namespacePop ()
void namespaceAppend (const char *s)
void defineMacro (CxxScanner &scanner, Token &t)
void nameSpace (CxxScanner &scanner, Token &t)
void klass (CxxScanner &scanner, Token &t)
void enumDef (CxxScanner &scanner, Token &t)
void trace (CxxScanner &scanner, Token &t)
void templateBlk (CxxScanner &scanner, Token &t)
void structDef (CxxScanner &scanner, Token &t)

Private Attributes

int m_lp
int m_lb
Tbl m_tbl
std::string m_fdec
std::string m_funcArgs
std::string m_fqName
std::string m_className
std::string m_buffer
std::vector< char * > m_namespaceA

Detailed Description

The context class for the State Design Pattern.

This provides the context needed for the State pattern. The job of this class is to implement a finite-state machine where the states change based on the type of token delivered by the scanner object.
It holds counter for the number of braces and parentheses. Most importantly it has the state pointer, mp_state, which holds a pointer to the next state.

There are also some tokens which do not change the state but must delt with independent of the state. When a c-preprocessor directive, class and enum definitions or trace strings are found, they must be grabbed from input and sent directly to the output file. Namespaces must also be detected and remembered.

Constructor & Destructor Documentation

AddTraceString::AddTraceString  ) 

Set the default context for the state pattern.

This ctor is simple, It just has to zero the paren and brace counters and zero the state pointer.

Member Function Documentation

void AddTraceString::addTraceString const char *  fileName  ) 

Add traceString to a single file.

Takes a absolute path name (or ``-'' to be standard in) and adds the traceString to that file. A token is read in and some action happens to the token: either it is like a macro definition and it is copied directly to the output or the token is handed off to the execute function for the current state.
Design Considerations
  • It prints most of the token it reads so functions from here must just print any new tokens read in.

Tbl & AddTraceString::buildTbl  ) 

Take the already found names in member variables and place in m_tbl.

void AddTraceString::changeState State s  ) 

Change current state to s. Print change of state if requested by user.

void AddTraceString::defineMacro CxxScanner scanner,
Token t

Read in the macro definition.

void AddTraceString::enumDef CxxScanner scanner,
Token t

Read in the enum definition.

std::string& AddTraceString::funcArgs  )  [inline]

Return the argument list.

void AddTraceString::funcArgsAppend const char *  s  )  [inline]

Append new argument to the current functions argument list.

std::string& AddTraceString::funcName  )  [inline]

return the function name.

void AddTraceString::klass CxxScanner scanner,
Token t

Handle any class tokens read in. It can be a class definition or a forward declaration.

int AddTraceString::lb  )  [inline]

Return the brace count.

void AddTraceString::lbAdd int  i  )  [inline]

Add i to the curly brace count.

void AddTraceString::lbSet int  i  )  [inline]

Set the curly brace count to i (usually 0)

int AddTraceString::lp  )  [inline]

Return the current paren count.

void AddTraceString::lpAdd int  i  )  [inline]

Add i to the paren counter

void AddTraceString::lpSet int  i  )  [inline]

Set the paren counter to i

void AddTraceString::nameSpace CxxScanner scanner,
Token t

Find the namespace or handle ``using namespace foo''.

void AddTraceString::namespaceAppend const char *  s  ) 

Add to the namespace array.

void AddTraceString::namespacePop  ) 

Pop the namespace array if there is any left.

void AddTraceString::setFuncArgs const char *  s  )  [inline]

Set the function's argument string

void AddTraceString::setFuncName const char *  fdec  )  [inline]

Set the function name.

void AddTraceString::structDef CxxScanner scanner,
Token t

Handle any structs. It can be a struct definition, a declaration or a return value for a function.

void AddTraceString::templateBlk CxxScanner scanner,
Token t

Handle any class or struct tokens read in. It can be a class definition or in a template definition or a forward declaration.

void AddTraceString::trace CxxScanner scanner,
Token t

Handle any traceString pairs found in a routine.

Member Data Documentation

std::string AddTraceString::m_buffer [private]

A working buffer.

std::string AddTraceString::m_className [private]

The class name plus any namespaces

std::string AddTraceString::m_fdec [private]

The function name that includes the class name if any.

std::string AddTraceString::m_fqName [private]

The fully qualified name.

std::string AddTraceString::m_funcArgs [private]

The function arguments.

int AddTraceString::m_lb [private]

Counter for curly braces

int AddTraceString::m_lp [private]

Counter for parentheses

std::vector<char*> AddTraceString::m_namespaceA [private]

An array of namespaces.

Tbl AddTraceString::m_tbl [private]

This is the dictionary that hold the FQNAME and others. The different names are found during the parsing of the source code and then placed in the table so that the replacement object can complete the generation of the traceString with the dynamic substitutions of the routine names.

State* AddTraceString::mp_state [private]

The trick that makes the state pattern work.

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

Project Hosted By: Logo