Sleeping Wombat GUI  0.100
swGUI
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sw::Chunk Class Reference

Represents memory chunk in file. More...

#include <Chunk.h>

Public Member Functions

 Chunk ()=default
 
 Chunk (ChunkReprPtr chunkRepr)
 
 ~Chunk ()=default
 
bool IsValid () const
 Checks if you can use this attribute properly. More...
 
bool operator== (Chunk other) const
 
Chunks manipulation
Chunk CreateChunk ()
 Create child chunk. More...
 
Chunk NextChunk ()
 Gets next chunk on the same nesting level. More...
 
Chunk FirstChild ()
 Gets first child chunk of this chunk. More...
 
bool HasChildren ()
 Check if you should call FirstChild or AccessData. More...
 
Chunk ParentChunk ()
 Get Chunks parent. More...
 
Data access
bool Fill (const DataPtr data, Size dataSize)
 Fills chunk with data. You can fill only chunks without children. One filled chunk, can't add children anymore. More...
 
DataUPack StealData ()
 Returns chunk's data and transfers ownership to caller. More...
 
DataPack AccessData ()
 Returns chunk's data. More...
 
Attributes manipulation
Attribute AddAttribute (AttributeType type, const DataPtr data, Size dataSize)
 Adds attribute and fills it with data. More...
 
template<typename AttributeStruct >
Attribute AddAttribute (AttributeType type, const AttributeStruct &content)
 Adds attribute and creates content from POD structure. More...
 
template<typename AttributeStruct >
Attribute AddAttribute (const AttributeStruct &content)
 Adds attribute and creates content from POD structure. Attribute type will be taken from struct. Specialize GetAttributeTypeID template. More...
 

Private Member Functions

 FRIEND_CLASS_TESTER (HCF)
 

Private Attributes

ChunkReprPtr m_chunkPtr
 

Detailed Description

Represents memory chunk in file.

Chunk can consist of nested chunks or it can contain data.

Constructor & Destructor Documentation

sw::Chunk::Chunk ( )
explicitdefault
sw::Chunk::Chunk ( ChunkReprPtr  chunkRepr)
explicit
sw::Chunk::~Chunk ( )
default

Member Function Documentation

DataPack sw::Chunk::AccessData ( )

Returns chunk's data.

Returns
Returns memory pointer and it's size but you are not owner of this pointer. You can use Chunk::StealMamory function instead.
Attribute sw::Chunk::AddAttribute ( AttributeType  type,
const DataPtr  data,
Size  dataSize 
)

Adds attribute and fills it with data.

template<typename AttributeStruct >
Attribute sw::Chunk::AddAttribute ( AttributeType  type,
const AttributeStruct &  content 
)
inline

Adds attribute and creates content from POD structure.

Parameters
[in]typeYou must provide type of attribute by yourself. Use second spetialization if struct defines attribute type getter.
template<typename AttributeStruct >
Attribute sw::Chunk::AddAttribute ( const AttributeStruct &  content)
inline

Adds attribute and creates content from POD structure. Attribute type will be taken from struct. Specialize GetAttributeTypeID template.

Chunk sw::Chunk::CreateChunk ( )

Create child chunk.

bool sw::Chunk::Fill ( const DataPtr  data,
Size  dataSize 
)

Fills chunk with data. You can fill only chunks without children. One filled chunk, can't add children anymore.

Chunk sw::Chunk::FirstChild ( )

Gets first child chunk of this chunk.

Returns
Returns invalid chunk if there's no children.
sw::Chunk::FRIEND_CLASS_TESTER ( HCF  )
private
bool sw::Chunk::HasChildren ( )

Check if you should call FirstChild or AccessData.

bool sw::Chunk::IsValid ( ) const

Checks if you can use this attribute properly.

Chunk sw::Chunk::NextChunk ( )

Gets next chunk on the same nesting level.

Returns
Returns invalid chunk if there's no next chunk.
bool sw::Chunk::operator== ( Chunk  other) const
Chunk sw::Chunk::ParentChunk ( )

Get Chunks parent.

Returns
Returned chunk can be invalid if this chunk is invalid or there's no parent.
DataUPack sw::Chunk::StealData ( )

Returns chunk's data and transfers ownership to caller.

Member Data Documentation

ChunkReprPtr sw::Chunk::m_chunkPtr
private

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