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 cell 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 int das_shape_toStr (const ptrdiff_t *pShape, int nRank, char *sBuf, int nLen)
 Emit a shape string, the exact inverse of das_shape_fromStr().
 

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 int das_shape_toStr ( const ptrdiff_t *  pShape,
int  nRank,
char *  sBuf,
int  nLen 
)

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

Returns
the length written, or -1 if the buffer is too small.