Castor3D 0.17.0
Multiplatform 3D engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
castor::FileParser Class Referenceabstract

#include <FileParser.hpp>

Inheritance diagram for castor::FileParser:
Inheritance graph
[legend]
Collaboration diagram for castor::FileParser:
Collaboration graph
[legend]

Public Member Functions

CU_API FileParser (SectionId rootSectionId, void *rootBlockContext=nullptr)
 Constructor.
 
CU_API FileParser (LoggerInstance &logger, SectionId rootSectionId, void *rootBlockContext=nullptr)
 Constructor.
 
virtual CU_API ~FileParser () noexcept=default
 Destructor.
 
CU_API void registerParsers (String const &name, AdditionalParsers const &parsers)
 Registers additional parsers.
 
CU_API void processFile (String const &appName, Path path, PreprocessedFile &preprocessed)
 Parsing function.
 
CU_API void processFile (Path const &path, PreprocessedFile &preprocessed)
 Parsing function.
 
CU_API void processFile (Path const &path, String const &content, PreprocessedFile &preprocessed)
 Parsing function.
 
CU_API PreprocessedFile processFile (String const &appName, Path const &path)
 Parsing function.
 
CU_API PreprocessedFile processFile (Path const &path)
 Parsing function.
 
CU_API PreprocessedFile processFile (Path const &path, String const &content)
 Parsing function.
 
CU_API bool parseFile (String const &appName, Path const &path)
 Parsing function.
 
CU_API bool parseFile (Path const &path)
 Parsing function.
 
CU_API bool parseFile (Path const &path, String const &content)
 Parsing function.
 
CU_API void parseError (String const &functionName, uint64_t lineIndex, String const &error)
 Logs an error in the log file.
 
CU_API void parseWarning (String const &functionName, uint64_t lineIndex, String const &warning)
 Logs a warning in the log file.
 
CU_API void addParser (SectionId oldSection, SectionId newSection, String const &name, ParserFunction const &function, ParserParameterArray const &params=ParserParameterArray())
 adds a parser function to the parsers list.
 
CU_API void addParser (SectionId section, String const &name, ParserFunction const &function, ParserParameterArray const &params=ParserParameterArray())
 adds a parser function to the parsers list.
 
bool isIgnored () const
 Tells if the read lines are to be ignored.
 
void ignore ()
 Increments ignore level.
 
LoggerInstance & getLogger () const
 
SectionId getRootSectionId () const
 
void * getRootBlockContext () const
 
void validate (PreprocessedFile &preprocessed)
 
String getSectionName (SectionId section) const
 
void cleanupParser (PreprocessedFile &preprocessed)
 
auto const & getAdditionalParsers () const
 

Protected Member Functions

virtual CU_API FileParserContextUPtr doInitialiseParser (Path const &path)
 Specific initialisation function.
 
virtual CU_API void doCleanupParser (PreprocessedFile &preprocessed)=0
 Specific cleanup.
 
virtual CU_API bool doDiscardParser (PreprocessedFile &preprocessed, StringView line)
 Function called when no parser is found for the line.
 
virtual CU_API void doValidate (PreprocessedFile &preprocessed)=0
 Function called when file parsing is completed with no error.
 
virtual CU_API String doGetSectionName (SectionId section) const =0
 Gives the name associated to section ID.
 
virtual CU_API castor::RawUniquePtr< FileParser > doCreateParser () const =0
 
- Protected Member Functions inherited from castor::NonMovable
 NonMovable ()=default
 Constructor.
 
 ~NonMovable () noexcept=default
 Destructor.
 

Protected Attributes

LoggerInstance & m_logger
 
AttributeParsers m_parsers
 
bool m_ignored { false }
 
StrStrMap m_defines
 

Constructor & Destructor Documentation

◆ FileParser() [1/2]

CU_API castor::FileParser::FileParser ( SectionId rootSectionId,
void * rootBlockContext = nullptr )
explicit

Constructor.

Parameters
[in]rootSectionIdThe root section id.
[in]rootBlockContextThe root block context.

◆ FileParser() [2/2]

CU_API castor::FileParser::FileParser ( LoggerInstance & logger,
SectionId rootSectionId,
void * rootBlockContext = nullptr )

Constructor.

Parameters
[in]loggerThe logger instance.
[in]rootSectionIdThe root section id.
[in]rootBlockContextThe root block context.

◆ ~FileParser()

virtual CU_API castor::FileParser::~FileParser ( )
virtualdefaultnoexcept

Destructor.

Member Function Documentation

◆ addParser() [1/2]

CU_API void castor::FileParser::addParser ( SectionId oldSection,
SectionId newSection,
String const & name,
ParserFunction const & function,
ParserParameterArray const & params = ParserParameterArray() )

adds a parser function to the parsers list.

Parameters
[in]oldSectionThe parser section onto which the function is applied.
[in]newSectionThe parser section resulting of the function application.
[in]nameThe parser name.
[in]functionThe parser function.
[in]paramsThe expected parameters.

◆ addParser() [2/2]

CU_API void castor::FileParser::addParser ( SectionId section,
String const & name,
ParserFunction const & function,
ParserParameterArray const & params = ParserParameterArray() )

adds a parser function to the parsers list.

Parameters
[in]sectionThe parser section.
[in]nameThe parser name.
[in]functionThe parser function.
[in]paramsThe expected parameters.

◆ cleanupParser()

void castor::FileParser::cleanupParser ( PreprocessedFile & preprocessed)
inline

References doCleanupParser().

Here is the call graph for this function:

◆ doCleanupParser()

virtual CU_API void castor::FileParser::doCleanupParser ( PreprocessedFile & preprocessed)
protectedpure virtual

Specific cleanup.

Referenced by cleanupParser().

Here is the caller graph for this function:

◆ doCreateParser()

virtual CU_API castor::RawUniquePtr< FileParser > castor::FileParser::doCreateParser ( ) const
protectedpure virtual

◆ doDiscardParser()

virtual CU_API bool castor::FileParser::doDiscardParser ( PreprocessedFile & preprocessed,
StringView line )
protectedvirtual

Function called when no parser is found for the line.

Parameters
[in]preprocessedThe preprocessed file.
[in]lineThe line.
Returns
false if the line must be ignored.

◆ doGetSectionName()

virtual CU_API String castor::FileParser::doGetSectionName ( SectionId section) const
protectedpure virtual

Gives the name associated to section ID.

Parameters
[in]sectionThe section ID.
Returns
The name.

Referenced by getSectionName().

Here is the caller graph for this function:

◆ doInitialiseParser()

virtual CU_API FileParserContextUPtr castor::FileParser::doInitialiseParser ( Path const & path)
protectedvirtual

Specific initialisation function.

Parameters
[in]pathThe file access path.

◆ doValidate()

virtual CU_API void castor::FileParser::doValidate ( PreprocessedFile & preprocessed)
protectedpure virtual

Function called when file parsing is completed with no error.

Referenced by validate().

Here is the caller graph for this function:

◆ getAdditionalParsers()

auto const & castor::FileParser::getAdditionalParsers ( ) const
inline

◆ getLogger()

LoggerInstance & castor::FileParser::getLogger ( ) const
inline

References m_logger.

◆ getRootBlockContext()

void * castor::FileParser::getRootBlockContext ( ) const
inline

◆ getRootSectionId()

SectionId castor::FileParser::getRootSectionId ( ) const
inline

◆ getSectionName()

String castor::FileParser::getSectionName ( SectionId section) const
inline

References doGetSectionName().

Here is the call graph for this function:

◆ ignore()

void castor::FileParser::ignore ( )
inline

Increments ignore level.

References m_ignored.

◆ isIgnored()

bool castor::FileParser::isIgnored ( ) const
inline

Tells if the read lines are to be ignored.

References m_ignored.

◆ parseError()

CU_API void castor::FileParser::parseError ( String const & functionName,
uint64_t lineIndex,
String const & error )

Logs an error in the log file.

Parameters
[in]functionNameThe error function.
[in]lineIndexThe error line.
[in]errorThe error text.

◆ parseFile() [1/3]

CU_API bool castor::FileParser::parseFile ( Path const & path)

Parsing function.

Parameters
[in]pathThe file access path.
Returns
true if OK.

◆ parseFile() [2/3]

CU_API bool castor::FileParser::parseFile ( Path const & path,
String const & content )

Parsing function.

Parameters
[in]pathThe file access path.
[in]contentThe file content.
Returns
true if OK.

◆ parseFile() [3/3]

CU_API bool castor::FileParser::parseFile ( String const & appName,
Path const & path )

Parsing function.

Parameters
[in]appNameThe application name, if a dezip is needed.
[in]pathThe file access path.
Returns
true if OK.

◆ parseWarning()

CU_API void castor::FileParser::parseWarning ( String const & functionName,
uint64_t lineIndex,
String const & warning )

Logs a warning in the log file.

Parameters
[in]functionNameThe warning function.
[in]lineIndexThe warning line.
[in]warningThe warning text.

◆ processFile() [1/6]

CU_API PreprocessedFile castor::FileParser::processFile ( Path const & path)

Parsing function.

Parameters
[in]pathThe file access path.
Returns
The preprocessed file.

◆ processFile() [2/6]

CU_API void castor::FileParser::processFile ( Path const & path,
PreprocessedFile & preprocessed )

Parsing function.

Parameters
[in]pathThe file access path.
[in]preprocessedThe preprocessed file.

◆ processFile() [3/6]

CU_API PreprocessedFile castor::FileParser::processFile ( Path const & path,
String const & content )

Parsing function.

Parameters
[in]pathThe file access path.
[in]contentThe file content.
Returns
The preprocessed file.

◆ processFile() [4/6]

CU_API void castor::FileParser::processFile ( Path const & path,
String const & content,
PreprocessedFile & preprocessed )

Parsing function.

Parameters
[in]pathThe file access path.
[in]contentThe file content.
[in]preprocessedThe preprocessed file.

◆ processFile() [5/6]

CU_API PreprocessedFile castor::FileParser::processFile ( String const & appName,
Path const & path )

Parsing function.

Parameters
[in]appNameThe application name, if a dezip is needed.
[in]pathThe file access path.
Returns
The preprocessed file.

◆ processFile() [6/6]

CU_API void castor::FileParser::processFile ( String const & appName,
Path path,
PreprocessedFile & preprocessed )

Parsing function.

Parameters
[in]appNameThe application name, if a dezip is needed.
[in]pathThe file access path.
[in]preprocessedThe preprocessed file.

◆ registerParsers()

CU_API void castor::FileParser::registerParsers ( String const & name,
AdditionalParsers const & parsers )

Registers additional parsers.

Parameters
[in]nameThe registering name.
[in]parsersThe parsers.

◆ validate()

void castor::FileParser::validate ( PreprocessedFile & preprocessed)
inline

References doValidate().

Here is the call graph for this function:

Member Data Documentation

◆ m_defines

StrStrMap castor::FileParser::m_defines
protected

The defines map.

◆ m_ignored

bool castor::FileParser::m_ignored { false }
protected

Tells the lines parsed are to be ignored.

Referenced by ignore(), and isIgnored().

◆ m_logger

LoggerInstance& castor::FileParser::m_logger
protected

Referenced by getLogger().

◆ m_parsers

AttributeParsers castor::FileParser::m_parsers
protected

The parser functions.


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