netcdf-c/libdap2/dceconstraints.h

151 lines
4.0 KiB
C
Raw Normal View History

2011-04-18 02:56:10 +08:00
/*********************************************************************
2018-12-07 05:21:03 +08:00
* Copyright 2018, UCAR/Unidata
2011-04-18 02:56:10 +08:00
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
*********************************************************************/
#ifndef DCECONSTRAINTS_H
#define DCECONSTRAINTS_H 1
#include "ceconstraints.h"
/* Provide a universal cast type containing common fields */
/* Define the common "supertype */
typedef struct DCEnode {
CEsort sort;
} DCEnode;
2013-04-18 02:58:37 +08:00
/* The slice structure is assumed common to all uses.
It is initially established from [first:stride:last]
*/
2011-04-18 02:56:10 +08:00
typedef struct DCEslice {
DCEnode node;
2013-04-18 02:58:37 +08:00
size_t first;
2011-04-18 02:56:10 +08:00
size_t stride;
2013-04-18 02:58:37 +08:00
size_t length;
size_t last; /* first + length - 1*/
2013-04-18 02:58:37 +08:00
size_t count; /* (length + (stride-1))/ stride == actual # of elements returned to client*/
2011-04-18 02:56:10 +08:00
size_t declsize; /* from defining dimension, if any.*/
} DCEslice;
typedef struct DCEsegment {
DCEnode node;
char* name;
int slicesdefined; /*1=>slice counts defined, except declsize*/
int slicesdeclized; /*1=>slice declsize defined */
size_t rank;
DCEslice slices[NC_MAX_VAR_DIMS];
void* annotation;
2011-04-18 02:56:10 +08:00
} DCEsegment;
typedef struct DCEfcn {
DCEnode node;
char* name;
NClist* args;
} DCEfcn;
typedef struct DCEvar {
DCEnode node;
NClist* segments;
void* annotation;
2011-04-18 02:56:10 +08:00
} DCEvar;
typedef struct DCEconstant {
DCEnode node;
CEsort discrim;
char* text;
long long intvalue;
double floatvalue;
} DCEconstant;
typedef struct DCEvalue {
DCEnode node;
CEsort discrim;
/* Do not bother with a union */
DCEconstant* constant;
DCEvar* var;
DCEfcn* fcn;
} DCEvalue;
typedef struct DCEselection {
DCEnode node;
CEsort operator;
DCEvalue* lhs;
NClist* rhs;
} DCEselection;
typedef struct DCEprojection {
DCEnode node;
CEsort discrim;
/* Do not bother with a union */
DCEvar* var;
DCEfcn* fcn;
} DCEprojection;
typedef struct DCEconstraint {
DCEnode node;
NClist* projections;
NClist* selections;
} DCEconstraint;
extern int dceparseconstraints(char* constraints, DCEconstraint* DCEonstraint);
extern int dceslicecompose(DCEslice* s1, DCEslice* s2, DCEslice* sr);
2011-11-14 12:20:19 +08:00
extern int dcemergeprojectionlists(NClist* dst, NClist* src);
2011-04-18 02:56:10 +08:00
extern DCEnode* dceclone(DCEnode* node);
extern NClist* dceclonelist(NClist* list);
extern void dcefree(DCEnode* node);
extern void dcefreelist(NClist* list);
extern char* dcetostring(DCEnode* node);
extern char* dcelisttostring(NClist* list,char*);
extern void dcetobuffer(DCEnode* node, NCbytes* buf);
extern void dcelisttobuffer(NClist* list, NCbytes* buf,char*);
extern char* dcerawtostring(void*);
extern char* dcerawlisttostring(NClist*);
2011-04-18 02:56:10 +08:00
extern NClist* dceallnodes(DCEnode* node, CEsort which);
extern DCEnode* dcecreate(CEsort sort);
extern void dcemakewholeslice(DCEslice* slice, size_t declsize);
extern void dcemakewholeprojection(DCEprojection*);
2011-04-18 02:56:10 +08:00
extern int dceiswholesegment(DCEsegment*);
extern int dceiswholeslice(DCEslice*);
extern int dceiswholeseglist(NClist*);
2011-11-14 12:20:19 +08:00
extern int dceiswholeprojection(DCEprojection*);
2011-04-18 02:56:10 +08:00
extern int dcesamepath(NClist* list1, NClist* list2);
2011-11-14 12:20:19 +08:00
extern int dcemergeprojections(DCEprojection* dst, DCEprojection* src);
extern void dcesegment_transpose(DCEsegment* seg,
size_t* start,
size_t* count,
size_t* stride,
size_t* sizes
);
/* Find leftmost index of segment slices
2019-09-18 10:27:43 +08:00
s.t. that index and all up to last
satisfy dceiswholeslice
*/
extern size_t dcesafeindex(DCEsegment* seg, size_t start, size_t stop);
2019-09-18 10:27:43 +08:00
/* Compute segment size for start up to stop */
extern size_t dcesegmentsize(DCEsegment*, size_t start, size_t stop);
/* Convert a DCE projection/selection/constraint instance into a string
that can be used with a url. Caller must free returned string.
*/
extern char* dcebuildprojectionstring(NClist* projections);
extern char* dcebuildselectionstring(NClist* selections);
extern char* dcebuildconstraintstring(DCEconstraint* constraints);
2011-11-14 12:20:19 +08:00
extern int dceverbose;
2011-04-18 02:56:10 +08:00
#endif /*DCECONSTRAINTS_H*/