das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
Macros | Functions
generator.h File Reference

Value sources for the DasVar layer. More...

#include <das3/value.h>
#include <das3/array.h>
Include dependency graph for generator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VARIDX_MAX   ARYIDX_MAX
 Max index count for the model.
 
#define VARIDX_MAXFLG   VARIDX_RAGGED
 Every flag is <= this, so (n > VARIDX_MAXFLG) reads as "is a real extent".
 
#define DasGen_type(P)   ((P)->kind)
 Promote any plain numeric element to double.
 
#define DasGen_elemType(P)   ((P)->elem)
 What one storage element of this generator holds.
 

Functions

DAS_API void das_varindex_merge (int nRank, ptrdiff_t *pDest, ptrdiff_t *pSrc)
 Merge two shapes in the model's index space, taking the lattice.
 
DAS_API ptrdiff_t das_varlength_merge (ptrdiff_t nLeft, ptrdiff_t nRight)
 Merge the length of one index position, same lattice as above.
 
DAS_API DasErrCode das_shape_fromStr (const char *sShape, int nMaxRank, bool bAllowFlags, ptrdiff_t *pShape, int *pnRank, const char *sWhere)
 Parse a shape string in the model's index vocabulary.
 
DAS_API char * das_shape_toStr (const ptrdiff_t *pShape, int nRank, char *sBuf, size_t uLen)
 Emit a shape string, the exact inverse of das_shape_fromStr().
 
DAS_API int das_shape_info (const ptrdiff_t *pShape, int nExtRank, int nShapeLen, char *sBuf, size_t uLen)
 Print shape information using symbols i,j,k etc for index positions.
 
DAS_API void das_varindex_prndir (bool bFastLast)
 Set index printing direction for das_shape_info().
 

Detailed Description

Value sources for the DasVar layer.

Macro Definition Documentation

◆ VARIDX_MAX

#define VARIDX_MAX   ARYIDX_MAX

Max index count for the model.

Same number as ARYIDX_MAX and always will be, since every model index eventually lands in one array's index list; a separate spelling because it is a separate audience.

◆ DasGen_type

#define DasGen_type (   P)    ((P)->kind)

Promote any plain numeric element to double.

Parameters
etthe element type held at p
pthe element to read
pOutreceives the promoted value
Returns
false for a struct time, which has no single double form. How this generator produces values (gtArray, gtSeq, ...).

Function Documentation

◆ das_varindex_merge()

DAS_API void das_varindex_merge ( int  nRank,
ptrdiff_t *  pDest,
ptrdiff_t *  pSrc 
)

Merge two shapes in the model's index space, taking the lattice.

Ragged > Number > Borrow > Unused

with two real numbers going to the smaller. pDest is updated in place.

NOT for array storage shapes: an array marks an unset extent with ARYIDX_UNBOUND (0), which this reads as a real extent of zero.

◆ das_varlength_merge()

DAS_API ptrdiff_t das_varlength_merge ( ptrdiff_t  nLeft,
ptrdiff_t  nRight 
)

Merge the length of one index position, same lattice as above.

Two real lengths give the SMALLER on purpose: mid-stream, variables fill different sized blocks and the extent usable across all of them is the minimum currently populated. A mismatch is a normal live-read state, not an error.

◆ das_shape_fromStr()

DAS_API DasErrCode das_shape_fromStr ( const char *  sShape,
int  nMaxRank,
bool  bAllowFlags,
ptrdiff_t *  pShape,
int *  pnRank,
const char *  sWhere 
)

Parse a shape string in the model's index vocabulary.

The grammar is ';'-separated tokens: a positive count, '*' ragged, '^' an extent borrowed from the container, '-' an index this thing does not use. The same grammar serves index= and intern=.

Parameters
nMaxRankthe most entries pShape can take
bAllowFlagsfalse to refuse '^' and '-'. A dataset IS the container, so it can neither borrow an extent nor decline an index; a variable may do both.
sWherea short context for diagnostics, e.g. "<composite> in dataset 30"
Returns
DAS_OKAY, or an error code with das_error already called. Rank is NOT checked against any expected value; that is the caller's policy.

◆ das_shape_toStr()

DAS_API char * das_shape_toStr ( const ptrdiff_t *  pShape,
int  nRank,
char *  sBuf,
size_t  uLen 
)

Emit a shape string, the exact inverse of das_shape_fromStr().

This is the wire form used in index= and intern=, for example "*;3".

Parameters
pShapeThe extents, as das_shape_fromStr() produces them
nRankThe number of entries in pShape to write
sBufThe output buffer
uLenThe size of sBuf, including room for the NUL
Returns
sBuf, or NULL if the whole string did not fit. A cut off shape can't be parsed back, so callers writing headers must check.

◆ das_shape_info()

DAS_API int das_shape_info ( const ptrdiff_t *  pShape,
int  nExtRank,
int  nShapeLen,
char *  sBuf,
size_t  uLen 
)

Print shape information using symbols i,j,k etc for index positions.

This is the display form used by the _info printers, the wire form is das_shape_toStr(). Output is a comma separated list of item counts, one per index that is in use, for example "i:2442, j:*, I:3". Since every index starts at 0 only the count is given, and '*' marks a ragged or borrowed extent. Indices set to VARIDX_UNUSED are skipped.

External indices are lettered i,j,k in print order, so a column-major caller still reads i,j,k; internal (item) indices follow as I,J,K.

Parameters
pShapeThe extents, external indices first
nExtRankHow many leading entries are external indices
nShapeLenAn index 1 past the last entry to print
sBufThe output buffer, may be NULL if uLen is 0
uLenThe size of sBuf, including room for the NUL
Returns
The length of the full text, not counting the NUL, as snprintf() does. sBuf is always NUL terminated when uLen > 0.

◆ das_varindex_prndir()

DAS_API void das_varindex_prndir ( bool  bFastLast)

Set index printing direction for das_shape_info().

Does not affect the internal layout of the data. The default print order is "Fastest index last."

WARNING: This function is NOT thread safe, the setting is a process global.