#include <stdbool.h>
#include <das2/units.h>
#include <das2/util.h>
#include <das2/buffer.h>
Go to the source code of this file.
Data Structures | |
struct | Descriptor |
Base structure for Stream Header Items. More... | |
Enumerations | |
enum | desc_type_t |
enumeration of Descriptor types, used internally for type checking. More... | |
Descriptor Functions | |
These work for any type of Descriptor, including PlaneDesc , PktDesc and StreamDesc. To make your compiler happy you will need to cast Plane, Packet and Stream Descriptor pointers to just the generic type of Descriptor pointer when using these functions. For example: PktDesc* pPktDesc; hasProperty((Descriptor*)pPktDesc, "SomePropName"); | |
void | Desc_init (Descriptor *pThis, desc_type_t type) |
Descriptor * | new_Descriptor (void) |
void | Desc_freeProps (Descriptor *pThis) |
bool | Desc_equals (const Descriptor *pOne, const Descriptor *pTwo) |
Check to see if two descriptors contain the same properties Note, the order of the properties may be different between the descriptors but if the contents are the same then the descriptors are considered to be equal. | |
Descriptor * | Desc_getParent (Descriptor *pThis) |
The the parent of a Descriptor. | |
size_t | Desc_getNProps (const Descriptor *pThis) |
Get the number of properties in a descriptor. | |
const char * | Desc_getPropNameByNum (const Descriptor *pThis, size_t uIdx) |
Get a property name by an index. | |
const char * | Desc_getPropValByNum (const Descriptor *pThis, size_t uIdx) |
Get a property value by an index. | |
ErrorCode | Desc_setProp (Descriptor *pThis, const char *sType, const char *sName, const char *sVal) |
Generic property setter. | |
const char * | Desc_getProp (const Descriptor *pThis, const char *propertyName) |
bool | Desc_getPropBool (Descriptor *pThis, const char *sPropName) |
Get a property boolean value. | |
ErrorCode | Desc_setPropBool (Descriptor *pThis, const char *sPropName, bool bVal) |
Set a boolean property Encodes the value as either the string "true" or the string "false". | |
ErrorCode | Desc_encode (Descriptor *pThis, DasBuf *pBuf, const char *sIndent) |
Encode a generic set of properties to a buffer. |
enum desc_type_t |
enumeration of Descriptor types, used internally for type checking.
May have one of the following values:
void Desc_init | ( | Descriptor * | pThis, | |
desc_type_t | type | |||
) |
bool Desc_equals | ( | const Descriptor * | pOne, | |
const Descriptor * | pTwo | |||
) |
Check to see if two descriptors contain the same properties Note, the order of the properties may be different between the descriptors but if the contents are the same then the descriptors are considered to be equal.
Note that parent descriptor properties are not checked when handling the comparison.
pDesc1 | The first descriptor | |
pDesc2 | The second descriptor |
Descriptor* Desc_getParent | ( | Descriptor * | pThis | ) |
The the parent of a Descriptor.
Plane descriptors are owned by packet descriptors and packet descriptors are owned by stream descriptors. This function lets you craw the ownership hierarchy
pThis |
size_t Desc_getNProps | ( | const Descriptor * | pThis | ) |
Get the number of properties in a descriptor.
Descriptor's have a hierarchy. In general when a property is requested, if a given Descriptor does not have a property the request is passed to the parent descriptor. This function only returns the number of properties in the given descriptor. It does not include properties owned by parents or ancestors.
This is useful when iterating over all properties in a descriptor.
pThis | A pointer to the descriptor to query |
const char* Desc_getPropNameByNum | ( | const Descriptor * | pThis, | |
size_t | uIdx | |||
) |
Get a property name by an index.
This is useful when iterating over all properties in a Descriptor. Only properties owed by a descriptor are queried in this manner. Parent descriptors are not consulted.
pThis | A pointer to the descriptor to query | |
uNum | The index of the property, will be a value between 0 and the return value from Desc_getNProps() |
const char* Desc_getPropValByNum | ( | const Descriptor * | pThis, | |
size_t | uIdx | |||
) |
Get a property value by an index.
This is useful when iterating over all properties in a Descriptor. Only properties owed by a descriptor are queried in this manner. Parent descriptors are not consulted. sv
pThis | A pointer to the descriptor to query | |
uNum | The number of the property, will be a value from 0 and 1 less than the return value from Desc_getNProps() |
ErrorCode Desc_setProp | ( | Descriptor * | pThis, | |
const char * | sType, | |||
const char * | sName, | |||
const char * | sVal | |||
) |
Generic property setter.
All properties are stored internally as strings. The various typed Desc_setProp* functions all call this function after converting their arguments to strings.
pThis | The Descriptor to receive the property | |
sType | The Type of property should be one of the strings:
| |
sName | The property name, which cannot contain spaces | |
sVal | The value, which may be anything including NULL |
bool Desc_getPropBool | ( | Descriptor * | pThis, | |
const char * | sPropName | |||
) |
Get a property boolean value.
pThis | the descriptor object to query | |
sPropName | the name of the proprety to retrieve |
ErrorCode Desc_setPropBool | ( | Descriptor * | pThis, | |
const char * | sPropName, | |||
bool | bVal | |||
) |
Set a boolean property Encodes the value as either the string "true" or the string "false".
pThis | The descriptor to receive the property | |
propertyName | the name of the property | |
value | either true or false. |
ErrorCode Desc_encode | ( | Descriptor * | pThis, | |
DasBuf * | pBuf, | |||
const char * | sIndent | |||
) |
Encode a generic set of properties to a buffer.
pThis | The descriptors who's properties should be encoded | |
pBuf | A buffer object to receive the XML data | |
sIndent | An indent level for the property strings, makes 'em look nice |