Sleeping Wombat Common Library  0.50.0
swCommonLibrary
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 (ChunkReprPtr chunkRepr)
 
bool IsValid () const
 Checks if you can use this attribute properly.
 
bool operator== (Chunk other) const
 
Chunks manipulation
Chunk CreateChunk ()
 Create child chunk.
 
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.
 
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.
 
DataUPack StealData ()
 Returns chunk's data and transfers ownership to caller.
 
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.
 
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.
 

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.

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.
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.
Chunk sw::Chunk::FirstChild ( )

Gets first child chunk of this chunk.

Returns
Returns invalid chunk if there's no children.
Chunk sw::Chunk::NextChunk ( )

Gets next chunk on the same nesting level.

Returns
Returns invalid chunk if there's no next chunk.
Chunk sw::Chunk::ParentChunk ( )

Get Chunks parent.

Returns
Returned chunk can be invalid if this chunk is invalid or there's no parent.

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