das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
Public Member Functions
DasProp Struct Reference

Individual properties of a descriptor. More...

#include <das3/property.h>

Public Member Functions

DasErrCode DasProp_init (ubyte *pBuf, size_t uBufSz, const char *sType, ubyte uType, const char *sName, const char *sValue, char cSep, das_units units, int nStandard)
 Flexible das1, das2 and das3 compatible property memory initializer.
 
size_t DasProp_size (const DasProp *pProp)
 Return the memory footprint of a property.
 
#define DasProp_name(P)   ((P)->buffer)
 Get name of a property.
 
const char * DasProp_value (const DasProp *pProp)
 Get the string value for a property.
 
size_t DasProp_escapeSize (const DasProp *pProp)
 Get the size of needed escape buffer if property contains illegal XML chars.
 
const char * DasProp_xmlValue (const DasProp *pProp, char *sBuf, size_t uLen)
 Get the string value for a property with illegal XML characters escaped.
 
char DasProp_sep (const DasProp *pProp)
 Get the value separator character for array-style properties.
 
bool DasProp_equal (const DasProp *pOne, const DasProp *pTwo)
 Determine if two properties contain equal content.
 
const char * DasProp_typeStr2 (const DasProp *pProp)
 Get a das2 type string for this property

 
const char * DasProp_typeStr3 (const DasProp *pProp)
 Get a das3 type string for this property.
 
int DasProp_convertInt (const DasProp *pProp, int64_t *pBuf, size_t uBufLen)
 Convert integer property values to 64-bit ints.
 
int DasProp_convertReal (const DasProp *pProp, double *pBuf, size_t uBufLen)
 Convert real-value properties to double.
 
int DasProp_convertBool (const DasProp *pProp, uint8_t *pBuf, size_t uBufLen)
 Convert boolean property values to bytes.
 
int DasProp_convertTt2k (const DasProp *pProp, int64_t *pBuf, size_t uBufLen)
 Convert datatime properties TT2K long integers.
 
int DasProp_convertTime (const DasProp *pProp, uint64_t *pBuf, size_t uBufLen)
 Convert datatime properties to a double based value of units.
 
int DasProp_extractItems (const DasProp *pProp, char **psBuf, size_t uNumStrs, size_t uLenEa)
 Just extract the property strings, don't convert anything.
 
ubyte DasProp_type (const DasProp *pProp)
 Get a property type code.
 
void DasProp_invalidate (DasProp *pProp)
 Mark this property as invalid, this erases the type information and is thus a non-reversible operation.
 
bool DasProp_isValid (const DasProp *pProp)
 Determine if this property has a valid type definition.
 
int DasProp_items (const DasProp *pProp)
 Determine the number of items in a multi valued property.
 
#define DasProp_isType(P, T)   ((P->flags & DASPROP_TYPE_MASK) == T)
 Ask if a property values are a particular type.
 
#define DasProp_isRange(P)   ((P->flags & DASPROP_RANGE)==DASPROP_RANGE)
 Returns true if this property has range multiplicity (aka 2 items)
 
#define DasProp_isSet(P)   ((P->flags & DASPROP_SET)==DASPROP_SET)
 Returns true if this property has more then one element (aka a set) but the set isn't a bounding range.
 

Detailed Description

Individual properties of a descriptor.

DasProp objects assume that some other object, such as a DasAry the storage buffer and that these functions configure and read that storage. Thus there are no "new_" or "del_" function for properties.

Each property has:

Member Function Documentation

◆ DasProp_init()

DasErrCode DasProp_init ( ubyte *  pBuf,
size_t  uBufSz,
const char *  sType,
ubyte  uType,
const char *  sName,
const char *  sValue,
char  cSep,
das_units  units,
int  nStandard 
)

Flexible das1, das2 and das3 compatible property memory initializer.

Parameters
pBufA byte buffer that is at least dasprop_memsz() bytes long
sTypeThe data type of the property, can be one of:
  • boolean (das2 & 3)
  • double, real (das2, das3)
  • realRange (das3)
  • doubleArray (das2)
  • Datum (das2, anything can have units in das3)
  • DatumRange (das2)
  • int,integer (das2, das3)
  • integerRange (das3)
  • String,string (das2, das3)
  • Time,datetime (das2, das3)
  • TimeRange,datetimeRange (das2,das3)
uTypeAn alternate and more efficient method of specifying the property type. If sType is NULL, this is read instead. To set uType or together one constant from each set below.

Item type: DASPROP_STRING, DASPROP_BOOL, DASPROP_INT, DASPROP_REAL, DASPROP_DATETIME

Multiplicity: DASPROP_SINGLE, DASPROP_RANGE, DASPROP_SET

Parameters
sNameThe name of the property, can be no longer then 127 bytes. This is a looser restriction then associated XSDs.
sValueThe data value, can be no longer then 130,943 bytes.
cSepFor array values, this (in addition to possible whitespace) is the separator between values. Ignored if Multiplicity is not DASPROP_SET.
unitsThe units for this value. If the type is Datum or DatumRange this value will be ignored, otherwise if this value is NULL then UNIT_DIMENSIONLESS will be assigned.
nStandard.One of 1, 2 or 3 for das1, das2, or das3. For das2 & 3, property names may only consist of the characters [a-z][A-Z][0-9] and '_'.

◆ DasProp_escapeSize()

size_t DasProp_escapeSize ( const DasProp pProp)

Get the size of needed escape buffer if property contains illegal XML chars.

Returns
0 if an XML escape buffer is not needed, the required size in bytes otherwise

◆ DasProp_xmlValue()

const char * DasProp_xmlValue ( const DasProp pProp,
char *  sBuf,
size_t  uLen 
)

Get the string value for a property with illegal XML characters escaped.

Parameters
pProppointer to the property in question
sBufpointer to a buffer to hold the translated property
uLenlength of the buffer which holds the translated property
Returns
A pointer to the escaped property value, which may be the original internal storage if XML escapes weren't needed or it may be the given buffer.

If XML escape codes are needed and the given buffer is too small das_error is called, which may (depending on the error disposition) halt the program.

◆ DasProp_convertInt()

int DasProp_convertInt ( const DasProp pProp,
int64_t *  pBuf,
size_t  uBufLen 
)

Convert integer property values to 64-bit ints.

Returns the number of conversions, or a negative error value

◆ DasProp_convertReal()

int DasProp_convertReal ( const DasProp pProp,
double *  pBuf,
size_t  uBufLen 
)

Convert real-value properties to double.

Returns
the number of conversions, or a negative error value

◆ DasProp_convertBool()

int DasProp_convertBool ( const DasProp pProp,
uint8_t *  pBuf,
size_t  uBufLen 
)

Convert boolean property values to bytes.

Returns
the number of conversions, or a negative error value

◆ DasProp_convertTt2k()

int DasProp_convertTt2k ( const DasProp pProp,
int64_t *  pBuf,
size_t  uBufLen 
)

Convert datatime properties TT2K long integers.

Returns
the number of conversions, or a negative error value

◆ DasProp_extractItems()

int DasProp_extractItems ( const DasProp pProp,
char **  psBuf,
size_t  uNumStrs,
size_t  uLenEa 
)

Just extract the property strings, don't convert anything.

Returns
the number of extracted properties, or a negative error value

◆ DasProp_type()

ubyte DasProp_type ( const DasProp pProp)

Get a property type code.

Use the values: DASPROP_MULTI_MASK & DASPROP_TYPE_MASK to extract sections


The documentation for this struct was generated from the following file: