HL-HDF
hlhdf_node.c File Reference

Functions for working with HL_Node's. More...

#include "hlhdf.h"
#include "hlhdf_alloc.h"
#include "hlhdf_private.h"
#include "hlhdf_defines_private.h"
#include "hlhdf_node_private.h"
#include "hlhdf_debug.h"
#include <string.h>
#include <stdlib.h>

Classes

struct  _HL_Node
 Represents a HDF5 object/attribute/reference/... More...
 

Functions

void HLNodePrivate_setData (HL_Node *node, size_t datasize, unsigned char *data)
 Sets data and datasize in the node.
 
void HLNodePrivate_setRawdata (HL_Node *node, size_t datasize, unsigned char *data)
 Sets rawdata and rawdatasize in the node.
 
int HLNodePrivate_setTypeIdAndDeriveFormat (HL_Node *node, hid_t type)
 Copies the typid and sets it in the node and also atempts to derive the format name.
 
void HLNodePrivate_setHdfID (HL_Node *node, hid_t hdfid)
 Sets the HDF identifier.
 
hid_t HLNodePrivate_getHdfID (HL_Node *node)
 Returns the HDF identifier.
 
const hsize_t * HLNodePrivate_getDims (HL_Node *node)
 Returns an internal pointer to the dimensions.
 
hid_t HLNodePrivate_getTypeId (HL_Node *node)
 Returns the internal type id.
 
HL_NodeHLNode_new (const char *name)
 Creates a new HL_Node instance.
 
void HLNode_free (HL_Node *node)
 Deallocates the provided node.
 
HL_NodeHLNode_newGroup (const char *name)
 Creates an empty group HL_Node of type HL_Type::GROUP_ID.
 
HL_NodeHLNode_newAttribute (const char *name)
 Creates an empty attribute HL_Node of type HL_Type::ATTRIBUTE_ID.
 
HL_NodeHLNode_newDataset (const char *name)
 Creates an empty data set HL_Node of type HL_Type::DATASET_ID.
 
HL_NodeHLNode_newDatatype (const char *name)
 Creates an empty data type HL_Node of type HL_Type::TYPE_ID.
 
HL_NodeHLNode_newReference (const char *name)
 Creates an empty reference HL_Node of type HL_Type::REFERENCE_ID.
 
HL_NodeHLNode_copy (HL_Node *node)
 Copies an HL_Node.
 
int HLNode_setScalarValue (HL_Node *node, size_t sz, unsigned char *value, const char *fmt, hid_t typid)
 Sets a scalar value in the specified node.
 
int HLNode_setArrayValue (HL_Node *node, size_t sz, int ndims, hsize_t *dims, unsigned char *value, const char *fmt, hid_t typid)
 Sets an array value in the specified node.
 
const char * HLNode_getName (HL_Node *node)
 Returns the node name.
 
unsigned char * HLNode_getData (HL_Node *node)
 Returns the internal data pointer for this node.
 
size_t HLNode_getDataSize (HL_Node *node)
 Returns the type size for the data format.
 
unsigned char * HLNode_getRawdata (HL_Node *node)
 Returns the internal rawdata pointer for this node.
 
size_t HLNode_getRawdataSize (HL_Node *node)
 Returns the type size for the raw data format.
 
int HLNode_nameEquals (HL_Node *node, const char *name)
 Compares the nodes name with the provided name.
 
void HLNode_setMark (HL_Node *node, const HL_NodeMark mark)
 Marks a node.
 
HL_NodeMark HLNode_getMark (HL_Node *node)
 Returns the mark of a node.
 
int HLNode_fetched (HL_Node *node)
 Returns if the data for this node has been extracted from the hdf5 file or not.
 
void HLNode_setFetched (HL_Node *node, int fetched)
 Sets if this node has got its data fetched or not.
 
HL_Type HLNode_getType (HL_Node *node)
 Gets the type of the node.
 
const char * HLNode_getFormatName (HL_Node *node)
 Gets the string represenation of the data format.
 
HL_FormatSpecifier HLNode_getFormat (HL_Node *node)
 Returns the format specifier for the node.
 
void HLNode_setDataType (HL_Node *node, HL_DataType datatype)
 Sets the data type of the node.
 
HL_DataType HLNode_getDataType (HL_Node *node)
 Returns the data type of the node.
 
int HLNode_setDimensions (HL_Node *node, int ndims, hsize_t *dims)
 Sets the node dimensions.
 
void HLNode_getDimensions (HL_Node *node, int *ndims, hsize_t **dims)
 Gets the node dimensions.
 
int HLNode_getRank (HL_Node *node)
 Returns the rank (number of dimensions).
 
hsize_t HLNode_getDimension (HL_Node *node, int index)
 Returns the dimension of the specified index.
 
hsize_t HLNode_getNumberOfPoints (HL_Node *node)
 Returns the number of value points that this node has.
 
void HLNode_setCompoundDescription (HL_Node *node, HL_CompoundTypeDescription *descr)
 Sets the description for this node.
 
HL_CompoundTypeDescriptionHLNode_getCompoundDescription (HL_Node *node)
 Returns the compound description for the node (if any).
 
HL_CompressionHLNode_getCompression (HL_Node *node)
 Returns the compression object for this node.
 
void HLNode_setCompression (HL_Node *node, HL_Compression *compression)
 Sets the compression object for this node.
 
int HLNode_commitType (HL_Node *node, hid_t thid)
 Will mark the node to be committed, only applicable on type nodes.
 

Detailed Description

Functions for working with HL_Node's.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-06-11

Function Documentation

◆ HLNode_fetched()

int HLNode_fetched ( HL_Node * node)

Returns if the data for this node has been extracted from the hdf5 file or not.

Useful if implementing for example lazy-loading or similar features.

Parameters
[in]node- the node
Returns
1 if data has been fetched from HDF5 file, otherwise 0

◆ HLNode_getCompoundDescription()

HL_CompoundTypeDescription * HLNode_getCompoundDescription ( HL_Node * node)

Returns the compound description for the node (if any).

Parameters
[in]nodethe node
Returns
the compound description if any, otherwise NULL. (Do not release since it points to internal memory

◆ HLNode_getCompression()

HL_Compression * HLNode_getCompression ( HL_Node * node)

Returns the compression object for this node.

Parameters
[in]nodethe node
Returns
the compression object (points to internal memory so do not release).

◆ HLNode_getData()

unsigned char * HLNode_getData ( HL_Node * node)

Returns the internal data pointer for this node.

Parameters
[in]nodethe node
Returns
the internal data (Do not release and be careful so that the node does not change when holding the data pointer.).

◆ HLNode_getDataSize()

size_t HLNode_getDataSize ( HL_Node * node)

Returns the type size for the data format.

Parameters
[in]nodethe node
Returns
the type size for the data format

◆ HLNode_getDataType()

HL_DataType HLNode_getDataType ( HL_Node * node)

Returns the data type of the node.

Parameters
[in]nodethe node
Returns
the data type of the node

◆ HLNode_getDimension()

hsize_t HLNode_getDimension ( HL_Node * node,
int index )

Returns the dimension of the specified index.

Parameters
[in]nodethe node
[in]indexthe index
Returns
the size of the specified index. (If index < 0 or >= the rank then 0 is returned).

◆ HLNode_getDimensions()

void HLNode_getDimensions ( HL_Node * node,
int * ndims,
hsize_t ** dims )

Gets the node dimensions.

Parameters
[in]nodethe node
[out]ndimsthe rank
[out]dimsthe dimensions

◆ HLNode_getFormat()

HL_FormatSpecifier HLNode_getFormat ( HL_Node * node)

Returns the format specifier for the node.

Parameters
[in]nodethe node
Returns
the format specifier

◆ HLNode_getFormatName()

const char * HLNode_getFormatName ( HL_Node * node)

Gets the string represenation of the data format.

Parameters
[in]nodethe node
Returns
the format specifier or the string representation for HLHDF_UNDEFINED

◆ HLNode_getMark()

HL_NodeMark HLNode_getMark ( HL_Node * node)

Returns the mark of a node.

Parameters
[in]node- the node
Returns
the node mark.

◆ HLNode_getName()

const char * HLNode_getName ( HL_Node * node)

Returns the node name.

Parameters
[in]nodethe node
Returns
the name of this node, If this node is freed, then the returned name can not be relied on.

◆ HLNode_getNumberOfPoints()

hsize_t HLNode_getNumberOfPoints ( HL_Node * node)

Returns the number of value points that this node has.

If rank == 0, then 1 is returned. If rank > 0 and dims is set, then 1*dims[0]*...*dims[rank-1] is returned. If rank > 0 and dims == NULL, which not should happen, but then 0 is returned

Parameters
[in]nodethe node
Returns
the number of value points.

◆ HLNode_getRank()

int HLNode_getRank ( HL_Node * node)

Returns the rank (number of dimensions).

Parameters
[in]nodethe node
Returns
the rank.

◆ HLNode_getRawdata()

unsigned char * HLNode_getRawdata ( HL_Node * node)

Returns the internal rawdata pointer for this node.

Parameters
[in]nodethe node
Returns
the internal data (Do not release and be careful so that the node does not change when holding the data pointer.).

◆ HLNode_getRawdataSize()

size_t HLNode_getRawdataSize ( HL_Node * node)

Returns the type size for the raw data format.

Parameters
[in]nodethe node
Returns
the type size for the raw data format

◆ HLNode_getType()

HL_Type HLNode_getType ( HL_Node * node)

Gets the type of the node.

Parameters
[in]nodethe node
Returns
the type of the node

◆ HLNode_nameEquals()

int HLNode_nameEquals ( HL_Node * node,
const char * name )

Compares the nodes name with the provided name.

Parameters
[in]nodethe node
[in]namethe name to test
Returns
1 if the name equals, otherwise 0

◆ HLNode_setCompoundDescription()

void HLNode_setCompoundDescription ( HL_Node * node,
HL_CompoundTypeDescription * descr )

Sets the description for this node.

Parameters
[in]nodethe node
[in]descrthe compound description (memory taken over so do not release it)

◆ HLNode_setCompression()

void HLNode_setCompression ( HL_Node * node,
HL_Compression * compression )

Sets the compression object for this node.

Parameters
[in]nodethe node
[in]compressionthe compression object (HL_Node takes responsibility so do not free after call).

◆ HLNode_setDataType()

void HLNode_setDataType ( HL_Node * node,
HL_DataType datatype )

Sets the data type of the node.

Parameters
[in]nodethe node
[in]datatypethe datatype
Returns
the data type of the node

◆ HLNode_setDimensions()

int HLNode_setDimensions ( HL_Node * node,
int ndims,
hsize_t * dims )

Sets the node dimensions.

Parameters
[in]nodethe node
[in]ndimsthe rank
[in]dimsthe dimensions
Returns
1 on success, otherwise 0

◆ HLNode_setFetched()

void HLNode_setFetched ( HL_Node * node,
int fetched )

Sets if this node has got its data fetched or not.

Parameters
[in]node- the node
[in]fetched- 1 if data fetched, otherwise 0

◆ HLNode_setMark()

void HLNode_setMark ( HL_Node * node,
const HL_NodeMark mark )

Marks a node.

Parameters
[in]node- the node
[in]mark- the node mark

◆ HLNodePrivate_getDims()

const hsize_t * HLNodePrivate_getDims ( HL_Node * node)

Returns an internal pointer to the dimensions.

Parameters
[in]nodethe node
Returns
the internal dimension pointer (Do not free and be careful when using it).

◆ HLNodePrivate_getHdfID()

hid_t HLNodePrivate_getHdfID ( HL_Node * node)

Returns the HDF identifier.

Parameters
[in]nodethe node
Returns
the hdf identifier (Do not close).

◆ HLNodePrivate_getTypeId()

hid_t HLNodePrivate_getTypeId ( HL_Node * node)

Returns the internal type id.

Parameters
[in]nodethe node
Returns
the internal type identifier (Do not close).

◆ HLNodePrivate_setData()

void HLNodePrivate_setData ( HL_Node * node,
size_t datasize,
unsigned char * data )

Sets data and datasize in the node.

When this function has been called, responsibility for the data has been taken over so do not release that memory.

Parameters
[in]nodethe node (MAY NOT BE NULL)
[in]datasizethe size of the data type as get by H5Tget_size.
[in]datathe data (responsibility taken over so do not release after call).

◆ HLNodePrivate_setHdfID()

void HLNodePrivate_setHdfID ( HL_Node * node,
hid_t hdfid )

Sets the HDF identifier.

Parameters
[in]nodethe node
[in]hdfidthe hdf id. (The responsibility is taken over so do not delete)

◆ HLNodePrivate_setRawdata()

void HLNodePrivate_setRawdata ( HL_Node * node,
size_t datasize,
unsigned char * data )

Sets rawdata and rawdatasize in the node.

When this function has been called, responsibility for the data has been taken over so do not release that memory.

Parameters
[in]nodethe node (MAY NOT BE NULL)
[in]datasizethe size of the data type as get by H5Tget_size.
[in]datathe data (responsibility taken over so do not release after call).

◆ HLNodePrivate_setTypeIdAndDeriveFormat()

int HLNodePrivate_setTypeIdAndDeriveFormat ( HL_Node * node,
hid_t typid )

Copies the typid and sets it in the node and also atempts to derive the format name.

Parameters
[in]nodethe node
[in]typidthe type identifier
Returns
1 on success, otherwise 0.