ezEngine Release 26.3
Loading...
Searching...
No Matches
ezOpenDdlParser Class Referenceabstract

Low-level streaming parser for OpenDDL documents. More...

#include <OpenDdlParser.h>

Inheritance diagram for ezOpenDdlParser:

Public Member Functions

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

Protected Member Functions

void SetLogInterface (ezLogInterface *pLog)
 Sets an ezLogInterface through which errors and warnings are reported.
 
void SetCacheSize (ezUInt32 uiSizeInKB)
 Sets the internal cache size for batching primitive data callbacks.
 
void SetInputStream (ezStreamReader &stream, ezUInt32 uiFirstLineOffset=0)
 Configures the parser to read from the given stream. This can only be called once on a parser instance.
 
bool ContinueParsing ()
 Parses the next portion of the document and triggers appropriate callbacks.
 
ezResult 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 (ezStringView 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 (ezStringView sMessage, bool bFatal, ezUInt32 uiLine, ezUInt32 uiColumn)
 Called when something unexpected is encountered in the document.
 
virtual void OnBeginObject (ezStringView sType, ezStringView 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 (ezOpenDdlPrimitiveType type, ezStringView 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 (ezUInt32 count, const bool *pData, bool bThisIsAll)=0
 Called when boolean primitive data is available.
 
virtual void OnPrimitiveInt8 (ezUInt32 count, const ezInt8 *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 (ezUInt32 count, const ezInt16 *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 (ezUInt32 count, const ezInt32 *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 (ezUInt32 count, const ezInt64 *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 (ezUInt32 count, const ezUInt8 *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 (ezUInt32 count, const ezUInt16 *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 (ezUInt32 count, const ezUInt32 *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 (ezUInt32 count, const ezUInt64 *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 (ezUInt32 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 (ezUInt32 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 (ezUInt32 count, const ezStringView *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

ezLogInterfacem_pLogInterface
 

Detailed Description

Low-level streaming parser for OpenDDL documents.

This abstract base class provides incremental parsing of OpenDDL (Open Data Description Language) format. Unlike ezOpenDdlReader which builds a complete in-memory tree, this parser operates in streaming mode, calling virtual functions as elements are encountered. This allows processing large documents with minimal memory usage and enables selective parsing where only certain parts are processed. Derived classes must override the virtual On* methods to handle parsed elements.

Member Function Documentation

◆ ContinueParsing()

bool ezOpenDdlParser::ContinueParsing ( )
protected

Parses the next portion of the document and triggers appropriate callbacks.

Returns false when the end of the document has been reached or a fatal parsing error occurred. Use this for incremental parsing where you want to control when parsing happens.

◆ OnBeginObject()

virtual void ezOpenDdlParser::OnBeginObject ( ezStringView  sType,
ezStringView  sName,
bool  bGlobalName 
)
protectedpure virtual

Called when a new object is encountered.

Implemented in ezOpenDdlReader.

◆ OnBeginPrimitiveList()

virtual void ezOpenDdlParser::OnBeginPrimitiveList ( ezOpenDdlPrimitiveType  type,
ezStringView  sName,
bool  bGlobalName 
)
protectedpure virtual

Called when a new primitive object is encountered.

Implemented in ezOpenDdlReader.

◆ OnEndObject()

virtual void ezOpenDdlParser::OnEndObject ( )
protectedpure virtual

Called when the end of an object is encountered.

Implemented in ezOpenDdlReader.

◆ OnEndPrimitiveList()

virtual void ezOpenDdlParser::OnEndPrimitiveList ( )
protectedpure virtual

Called when the end of a primitive object is encountered.

Implemented in ezOpenDdlReader.

◆ OnParsingError()

virtual void ezOpenDdlParser::OnParsingError ( ezStringView  sMessage,
bool  bFatal,
ezUInt32  uiLine,
ezUInt32  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 ezOpenDdlReader.

◆ OnPrimitiveBool()

virtual void ezOpenDdlParser::OnPrimitiveBool ( ezUInt32  count,
const bool *  pData,
bool  bThisIsAll 
)
protectedpure virtual

Called when boolean primitive data is available.

Todo:
Currently not supported

Multiple values may be reported at once for efficiency. bThisIsAll indicates if this is the final batch for the current primitive list. Implementations should accumulate data if bThisIsAll is false.

Implemented in ezOpenDdlReader.

◆ OnPrimitiveDouble()

virtual void ezOpenDdlParser::OnPrimitiveDouble ( ezUInt32  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 ezOpenDdlReader.

◆ OnPrimitiveFloat()

virtual void ezOpenDdlParser::OnPrimitiveFloat ( ezUInt32  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 ezOpenDdlReader.

◆ OnPrimitiveInt16()

virtual void ezOpenDdlParser::OnPrimitiveInt16 ( ezUInt32  count,
const ezInt16 *  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 ezOpenDdlReader.

◆ OnPrimitiveInt32()

virtual void ezOpenDdlParser::OnPrimitiveInt32 ( ezUInt32  count,
const ezInt32 *  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 ezOpenDdlReader.

◆ OnPrimitiveInt64()

virtual void ezOpenDdlParser::OnPrimitiveInt64 ( ezUInt32  count,
const ezInt64 *  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 ezOpenDdlReader.

◆ OnPrimitiveInt8()

virtual void ezOpenDdlParser::OnPrimitiveInt8 ( ezUInt32  count,
const ezInt8 *  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 ezOpenDdlReader.

◆ OnPrimitiveString()

virtual void ezOpenDdlParser::OnPrimitiveString ( ezUInt32  count,
const ezStringView 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 ezOpenDdlReader.

◆ OnPrimitiveUInt16()

virtual void ezOpenDdlParser::OnPrimitiveUInt16 ( ezUInt32  count,
const ezUInt16 *  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 ezOpenDdlReader.

◆ OnPrimitiveUInt32()

virtual void ezOpenDdlParser::OnPrimitiveUInt32 ( ezUInt32  count,
const ezUInt32 *  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 ezOpenDdlReader.

◆ OnPrimitiveUInt64()

virtual void ezOpenDdlParser::OnPrimitiveUInt64 ( ezUInt32  count,
const ezUInt64 *  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 ezOpenDdlReader.

◆ OnPrimitiveUInt8()

virtual void ezOpenDdlParser::OnPrimitiveUInt8 ( ezUInt32  count,
const ezUInt8 *  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 ezOpenDdlReader.

◆ SetCacheSize()

void ezOpenDdlParser::SetCacheSize ( ezUInt32  uiSizeInKB)
protected

Sets the internal cache size for batching primitive data callbacks.

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, allowing up to 1000 integers or 500 doubles per chunk. Increasing the cache size only helps when the input data contains large primitive arrays, otherwise it provides no benefit.


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