3#include <Foundation/Basics.h>
4#include <Foundation/Containers/Deque.h>
5#include <Foundation/Containers/Map.h>
6#include <Foundation/IO/OpenDdlParser.h>
7#include <Foundation/Logging/Log.h>
13 PL_DECLARE_POD_TYPE();
16 PL_ALWAYS_INLINE
bool IsCustomType()
const {
return m_PrimitiveType == plOpenDdlPrimitiveType::Custom; }
21 return m_PrimitiveType == plOpenDdlPrimitiveType::Custom && m_sCustomType == sTypeName;
28 PL_ALWAYS_INLINE
bool HasName()
const {
return !m_sName.IsEmpty(); }
34 PL_ALWAYS_INLINE
bool IsNameGlobal()
const {
return (m_uiNumChildElements & PL_BIT(31)) != 0; }
37 plUInt32 GetNumChildObjects()
const;
49 plUInt32 GetNumPrimitives()
const;
52 PL_ALWAYS_INLINE plOpenDdlPrimitiveType
GetPrimitivesType()
const {
return m_PrimitiveType; }
56 bool HasPrimitives(plOpenDdlPrimitiveType type, plUInt32 uiMinNumberOfPrimitives = 1)
const;
59 PL_ALWAYS_INLINE
const bool*
GetPrimitivesBool()
const {
return reinterpret_cast<const bool*
>(m_pFirstChild); }
62 PL_ALWAYS_INLINE
const plInt8*
GetPrimitivesInt8()
const {
return reinterpret_cast<const plInt8*
>(m_pFirstChild); }
65 PL_ALWAYS_INLINE
const plInt16*
GetPrimitivesInt16()
const {
return reinterpret_cast<const plInt16*
>(m_pFirstChild); }
68 PL_ALWAYS_INLINE
const plInt32*
GetPrimitivesInt32()
const {
return reinterpret_cast<const plInt32*
>(m_pFirstChild); }
71 PL_ALWAYS_INLINE
const plInt64*
GetPrimitivesInt64()
const {
return reinterpret_cast<const plInt64*
>(m_pFirstChild); }
74 PL_ALWAYS_INLINE
const plUInt8*
GetPrimitivesUInt8()
const {
return reinterpret_cast<const plUInt8*
>(m_pFirstChild); }
77 PL_ALWAYS_INLINE
const plUInt16*
GetPrimitivesUInt16()
const {
return reinterpret_cast<const plUInt16*
>(m_pFirstChild); }
80 PL_ALWAYS_INLINE
const plUInt32*
GetPrimitivesUInt32()
const {
return reinterpret_cast<const plUInt32*
>(m_pFirstChild); }
83 PL_ALWAYS_INLINE
const plUInt64*
GetPrimitivesUInt64()
const {
return reinterpret_cast<const plUInt64*
>(m_pFirstChild); }
86 PL_ALWAYS_INLINE
const float*
GetPrimitivesFloat()
const {
return reinterpret_cast<const float*
>(m_pFirstChild); }
89 PL_ALWAYS_INLINE
const double*
GetPrimitivesDouble()
const {
return reinterpret_cast<const double*
>(m_pFirstChild); }
107 plOpenDdlPrimitiveType m_PrimitiveType = plOpenDdlPrimitiveType::Custom;
108 plUInt32 m_uiNumChildElements = 0;
109 const void* m_pFirstChild =
nullptr;
131 plUInt32 uiCacheSizeInKB = 4);
141 virtual void OnEndObject()
override;
143 virtual void OnBeginPrimitiveList(plOpenDdlPrimitiveType type,
plStringView sName,
bool bGlobalName)
override;
144 virtual void OnEndPrimitiveList()
override;
146 virtual void OnPrimitiveBool(plUInt32 count,
const bool* pData,
bool bThisIsAll)
override;
148 virtual void OnPrimitiveInt8(plUInt32 count,
const plInt8* pData,
bool bThisIsAll)
override;
149 virtual void OnPrimitiveInt16(plUInt32 count,
const plInt16* pData,
bool bThisIsAll)
override;
150 virtual void OnPrimitiveInt32(plUInt32 count,
const plInt32* pData,
bool bThisIsAll)
override;
151 virtual void OnPrimitiveInt64(plUInt32 count,
const plInt64* pData,
bool bThisIsAll)
override;
153 virtual void OnPrimitiveUInt8(plUInt32 count,
const plUInt8* pData,
bool bThisIsAll)
override;
154 virtual void OnPrimitiveUInt16(plUInt32 count,
const plUInt16* pData,
bool bThisIsAll)
override;
155 virtual void OnPrimitiveUInt32(plUInt32 count,
const plUInt32* pData,
bool bThisIsAll)
override;
156 virtual void OnPrimitiveUInt64(plUInt32 count,
const plUInt64* pData,
bool bThisIsAll)
override;
158 virtual void OnPrimitiveFloat(plUInt32 count,
const float* pData,
bool bThisIsAll)
override;
159 virtual void OnPrimitiveDouble(plUInt32 count,
const double* pData,
bool bThisIsAll)
override;
161 virtual void OnPrimitiveString(plUInt32 count,
const plStringView* pData,
bool bThisIsAll)
override;
163 virtual void OnParsingError(
plStringView sMessage,
bool bFatal, plUInt32 uiLine, plUInt32 uiColumn)
override;
168 void StorePrimitiveData(
bool bThisIsAll, plUInt32 bytecount,
const plUInt8* pData);
170 void ClearDataChunks();
171 plUInt8* AllocateBytes(plUInt32 uiNumBytes);
173 static constexpr plUInt32 s_uiChunkSize = 1000 * 4;
176 plUInt8* m_pCurrentChunk;
177 plUInt32 m_uiBytesInChunkLeft;
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
static plLogInterface * GetThreadLocalLogSystem()
Returns the currently set default logging system, or a thread local instance of plGlobalLog,...
Definition Log.cpp:345
Base class for all logging classes.
Definition Log.h:77
A low level parser for the OpenDDL format. It can incrementally parse the structure,...
Definition OpenDdlParser.h:35
Represents a single 'object' in a DDL document, e.g. either a custom type or a primitives list.
Definition OpenDdlReader.h:11
PL_ALWAYS_INLINE const plOpenDdlReaderElement * GetSibling() const
If the parent is a custom type element, the next child after this is returned.
Definition OpenDdlReader.h:46
PL_ALWAYS_INLINE const plInt64 * GetPrimitivesInt64() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:71
PL_ALWAYS_INLINE const plInt8 * GetPrimitivesInt8() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:62
PL_ALWAYS_INLINE const plStringView * GetPrimitivesString() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:92
PL_ALWAYS_INLINE const plUInt8 * GetPrimitivesUInt8() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:74
PL_ALWAYS_INLINE const plUInt32 * GetPrimitivesUInt32() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:80
PL_ALWAYS_INLINE const double * GetPrimitivesDouble() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:89
PL_ALWAYS_INLINE bool IsCustomType() const
Whether this is a custom object type that typically contains sub-elements.
Definition OpenDdlReader.h:16
PL_ALWAYS_INLINE const bool * GetPrimitivesBool() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:59
PL_ALWAYS_INLINE const plUInt16 * GetPrimitivesUInt16() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:77
PL_ALWAYS_INLINE const plUInt64 * GetPrimitivesUInt64() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:83
PL_ALWAYS_INLINE plStringView GetName() const
Returns the name of the object.
Definition OpenDdlReader.h:31
PL_ALWAYS_INLINE bool HasName() const
Whether the name of the object is non-empty.
Definition OpenDdlReader.h:28
PL_ALWAYS_INLINE const plOpenDdlReaderElement * GetFirstChild() const
If this is a custom type element, the returned pointer is to the first child element.
Definition OpenDdlReader.h:40
PL_ALWAYS_INLINE bool IsNameGlobal() const
Returns whether the element name is a global or a local name.
Definition OpenDdlReader.h:34
PL_ALWAYS_INLINE plStringView GetCustomType() const
Returns the string for the custom type name.
Definition OpenDdlReader.h:25
PL_ALWAYS_INLINE plOpenDdlPrimitiveType GetPrimitivesType() const
For non-custom types this returns the type of primitive that is stored at this element.
Definition OpenDdlReader.h:52
PL_ALWAYS_INLINE const plInt16 * GetPrimitivesInt16() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:65
PL_ALWAYS_INLINE const float * GetPrimitivesFloat() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:86
PL_ALWAYS_INLINE bool IsCustomType(plStringView sTypeName) const
Whether this is a custom object type of the requested type.
Definition OpenDdlReader.h:19
PL_ALWAYS_INLINE const plInt32 * GetPrimitivesInt32() const
Returns a pointer to the primitive data cast to a specific type. Only valid if GetPrimitivesType() ac...
Definition OpenDdlReader.h:68
An OpenDDL reader parses an entire DDL document and creates an in-memory representation of the docume...
Definition OpenDdlReader.h:118
Interface for binary in (read) streams.
Definition Stream.h:22
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54