Ah the wonders of boost::spirit. This class is in charge of parsing an existing C++ header and turning it into a class object. It's a fair amount of black magic, be careful when touching it.

This object is not thread safe. It keeps state information about where it is in the header. For example when it sees a "public" tag it remembers that the following members are public.


HeaderParser( )

~HeaderParser( )


This struct contains information about the classes that where found in the header.


ClassObjectPtr pClass

std::vector InheritanceList

std::string LastAction

bool Success



typedef std::list ClassInfoList

void ParseHeader( const std::string& FileName, std::vector& Info)

void ParseHeaderData( const std::string& RawData, std::vector& Info)

The workhorse for header parsing. Returns a vector of info objects. You have to loop through that to see whether or not this was a failure, success, or partial success.

bool FindPoints( const std::string& File, const std::string& ClassName, size_t& Start, size_t &End) const

static void Tokenize( const std::string& Input, std::vector& Output)

Very useful function. Takes a string separated by blanks and returnsa vector or strings.



void ClearInternalState( )

Clears out the state of the object. As this reads through a header it will keep state on where it is inside a class. This state needs to be cleared out when the class is finished.

void DEBUGPrint( const std::string& Tag, const char* First, const char* Last)

void ReadVariable( const std::string& Input, VariableObjectPtr& pVariable)

std::string Trim( const std::string& Input)

bool FindEnd( const std::string& Input, char Open, char Close, size_t& End) const

bool FindMatchedPair( const std::string& Input, size_t StartPos, const std::string& Open, const std::string& Close, size_t& Begin, size_t& End) const

std::string PreProcessor( const std::string& Input) const

void StripChunks( std::string& TheText, const std::string& Begin, const std::string& End) const

void MarkPosition( const std::string& Location, const std::string& Specific)

void BeginClassAction( const char* First, const char* Last)

void EndClassAction( const char* First, const char* Last)

void MethodNameAction( const char* First, const char* Last)

void MethodArgAction( const char* First, const char* Last)

void EndMethodAction( const char* First, const char* Last)

void VariableAction( const char* First, const char* Last)

void EnumAction( const char* First, const char* Last)

void AccessAction( const char* First, const char* Last)

void InheritanceAction( const char* First, const char* Last)

ClassInfoList m_GenerationList

The list of classes that it has found in the header.

int m_ClassDepth

I need this one to figure out if the class I'm currently reading is the top level class, or an embedded class.

std::vector m_InheritanceList

name of the classes that this inherits from. They are NOT turned into actual Inheritence objects by this class as it does not know enough about whether they will be internal of external etc. The names are just passed on for someone else to deal with

std::stack m_CurrentAccess

What is the current access type for the class it's reading though. This is a stack because it could be the access type of a child class, which will need to be popped when it's done.

std::string m_CurrentMethodName

the name of the method it's currently parsing.

std::vector m_CurrentArgs

a list of the arguments it's currently reading. Will be dealt with when it's done with the funciton declaration

boost::spirit::rule<> m_SpaceOrEOL

boost::spirit::rule<> m_ValidChars

boost::spirit::rule<> m_ValidToken

boost::spirit::rule<> m_ValidString

boost::spirit::rule<> m_ClassDecl

boost::spirit::rule<> m_Inheritance

boost::spirit::rule<> m_InheritanceNoAction

boost::spirit::rule<> m_InheritanceDecl

boost::spirit::rule<> m_InheritanceDeclNoAction

boost::spirit::rule<> m_ClassHeader

boost::spirit::rule<> m_ClassTerminator

boost::spirit::rule<> m_AccessToken

boost::spirit::rule<> m_VariableDecl

boost::spirit::rule<> m_MethodDecl

boost::spirit::rule<> m_EnumDecl

boost::spirit::rule<> m_OperatorDecl

boost::spirit::rule<> m_FullClass

boost::spirit::rule<> m_HeaderRule