Plasma Engine  2.0
Loading...
Searching...
No Matches
plOpenDdlParser Class Referenceabstract

A low level parser for the OpenDDL format. It can incrementally parse the structure, individual blocks can be skipped. More...

#include <OpenDdlParser.h>

Inheritance diagram for plOpenDdlParser:

Public Member Functions

bool HadFatalParsingError () const
 Whether an error occurred during parsing that resulted in cancellation of further parsing.
 

Protected Member Functions

void SetLogInterface (plLogInterface *pLog)
 Sets an plLogInterface through which errors and warnings are reported.
 
void SetCacheSize (plUInt32 uiSizeInKB)
 Data is returned in larger chunks, to reduce the number of function calls. The cache size determines the maximum chunk size per primitive type.
 
void SetInputStream (plStreamReader &stream, plUInt32 uiFirstLineOffset=0)
 Configures the parser to read from the given stream. This can only be called once on a parser instance.
 
bool ContinueParsing ()
 Call this to parse the next piece of the document. This may trigger a callback through which data is returned.
 
plResult ParseAll ()
 Calls ContinueParsing() in a loop until that returns false.
 
void SkipRestOfObject ()
 Skips the rest of the currently open object. No OnEndObject() call will be done for this object either.
 
void StopParsing ()
 Can be used to prevent parsing the rest of the document.
 
void ParsingError (plStringView sMessage, bool bFatal)
 Outputs that a parsing error was detected (via OnParsingError) and stops further parsing, if bFatal is set to true.
 
virtual void OnParsingError (plStringView sMessage, bool bFatal, plUInt32 uiLine, plUInt32 uiColumn)
 Called when something unexpected is encountered in the document.
 
virtual void OnBeginObject (plStringView sType, plStringView sName, bool bGlobalName)=0
 Called when a new object is encountered.
 
virtual void OnEndObject ()=0
 Called when the end of an object is encountered.
 
virtual void OnBeginPrimitiveList (plOpenDdlPrimitiveType type, plStringView sName, bool bGlobalName)=0
 Called when a new primitive object is encountered.
 
virtual void OnEndPrimitiveList ()=0
 Called when the end of a primitive object is encountered.
 
virtual void OnPrimitiveBool (plUInt32 count, const bool *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveInt8 (plUInt32 count, const plInt8 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveInt16 (plUInt32 count, const plInt16 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveInt32 (plUInt32 count, const plInt32 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveInt64 (plUInt32 count, const plInt64 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveUInt8 (plUInt32 count, const plUInt8 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveUInt16 (plUInt32 count, const plUInt16 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveUInt32 (plUInt32 count, const plUInt32 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveUInt64 (plUInt32 count, const plUInt64 *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveFloat (plUInt32 count, const float *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveDouble (plUInt32 count, const double *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 
virtual void OnPrimitiveString (plUInt32 count, const plStringView *pData, bool bThisIsAll)=0
 Called when data for a primitive type is available. More than one value may be reported at a time.
 

Protected Attributes

plLogInterfacem_pLogInterface
 

Detailed Description

A low level parser for the OpenDDL format. It can incrementally parse the structure, individual blocks can be skipped.

The document structure is returned through virtual functions that need to be overridden.

Member Function Documentation

◆ ContinueParsing()

bool plOpenDdlParser::ContinueParsing ( )
protected

Call this to parse the next piece of the document. This may trigger a callback through which data is returned.

This function returns false when the end of the document has been reached, or a fatal parsing error has been reported.

◆ OnBeginObject()

virtual void plOpenDdlParser::OnBeginObject ( plStringView sType,
plStringView sName,
bool bGlobalName )
protectedpure virtual

Called when a new object is encountered.

Implemented in plOpenDdlReader.

◆ OnBeginPrimitiveList()

virtual void plOpenDdlParser::OnBeginPrimitiveList ( plOpenDdlPrimitiveType type,
plStringView sName,
bool bGlobalName )
protectedpure virtual

Called when a new primitive object is encountered.

Implemented in plOpenDdlReader.

◆ OnEndObject()

virtual void plOpenDdlParser::OnEndObject ( )
protectedpure virtual

Called when the end of an object is encountered.

Implemented in plOpenDdlReader.

◆ OnEndPrimitiveList()

virtual void plOpenDdlParser::OnEndPrimitiveList ( )
protectedpure virtual

Called when the end of a primitive object is encountered.

Implemented in plOpenDdlReader.

◆ OnParsingError()

virtual void plOpenDdlParser::OnParsingError ( plStringView sMessage,
bool bFatal,
plUInt32 uiLine,
plUInt32 uiColumn )
inlineprotectedvirtual

Called when something unexpected is encountered in the document.

The error message describes what was expected and what was encountered. If bFatal is true, the error has left the parser in an unrecoverable state and thus it will not continue parsing. In that case client code will need to clean up it's open state, as no further callbacks will be called. If bFatal is false, the document is not entirely valid, but the parser is still able to continue.

Reimplemented in plOpenDdlReader.

◆ OnPrimitiveBool()

virtual void plOpenDdlParser::OnPrimitiveBool ( plUInt32 count,
const bool * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Todo
Currently not supported

Implemented in plOpenDdlReader.

◆ OnPrimitiveDouble()

virtual void plOpenDdlParser::OnPrimitiveDouble ( plUInt32 count,
const double * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveFloat()

virtual void plOpenDdlParser::OnPrimitiveFloat ( plUInt32 count,
const float * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveInt16()

virtual void plOpenDdlParser::OnPrimitiveInt16 ( plUInt32 count,
const plInt16 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveInt32()

virtual void plOpenDdlParser::OnPrimitiveInt32 ( plUInt32 count,
const plInt32 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveInt64()

virtual void plOpenDdlParser::OnPrimitiveInt64 ( plUInt32 count,
const plInt64 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveInt8()

virtual void plOpenDdlParser::OnPrimitiveInt8 ( plUInt32 count,
const plInt8 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveString()

virtual void plOpenDdlParser::OnPrimitiveString ( plUInt32 count,
const plStringView * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveUInt16()

virtual void plOpenDdlParser::OnPrimitiveUInt16 ( plUInt32 count,
const plUInt16 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveUInt32()

virtual void plOpenDdlParser::OnPrimitiveUInt32 ( plUInt32 count,
const plUInt32 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveUInt64()

virtual void plOpenDdlParser::OnPrimitiveUInt64 ( plUInt32 count,
const plUInt64 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ OnPrimitiveUInt8()

virtual void plOpenDdlParser::OnPrimitiveUInt8 ( plUInt32 count,
const plUInt8 * pData,
bool bThisIsAll )
protectedpure virtual

Called when data for a primitive type is available. More than one value may be reported at a time.

Implemented in plOpenDdlReader.

◆ SetCacheSize()

void plOpenDdlParser::SetCacheSize ( plUInt32 uiSizeInKB)
protected

Data is returned in larger chunks, to reduce the number of function calls. The cache size determines the maximum chunk size per primitive type.

Default cache size is 4 KB. That means up to 1000 integers may be returned in one chunk (or 500 doubles). It does not help to increase the chunk size, when the input data doesn't use such large data lists.


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