libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
datum.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Chris Piker <chris-piker@uiowa.edu>
2  *
3  * This file is part of libdas2, the Core Das2 C Library.
4  *
5  * Libdas2 is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * Libdas2 is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * version 2.1 along with libdas2; if not, see <http://www.gnu.org/licenses/>.
16  */
17 
20 #ifndef _das_datum_h_
21 #define _das_datum_h_
22 
23 #include <das2/value.h>
24 #include <das2/units.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
62 typedef struct datum_t {
63  byte bytes[sizeof(das_time)];
64  das_val_type vt;
65  size_t vsize;
66  das_units units;
67 } das_datum;
68 
69 
80 bool das_datum_fromStr(das_datum* pThis, const char* sStr);
81 
91 bool das_datum_fromDbl(das_datum* pThis, double value, das_units units);
92 
112 bool das_datum_wrapStr(das_datum* pTHis, const char* sStr, das_units units);
113 
114 
115 typedef struct das_byteseq_t{
116  const byte* ptr;
117  size_t sz;
118 } das_byteseq;
119 
125 bool das_datum_byteSeq(
126  das_datum* pThis, das_byteseq seq, das_units units
127 );
128 
152 char* das_datum_toStr(
153  const das_datum* pThis, char* sStr, size_t uLen, int nFracDigits
154 );
155 
161  const das_datum* pThis, char* sStr, size_t uLen, int nFracDigits
162 );
163 
164 
173 double das_datum_toDbl(const das_datum* pThis);
174 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* _das_datum_h_ */
bool das_datum_wrapStr(das_datum *pTHis, const char *sStr, das_units units)
Wrap an external string as a datum.
A value and it&#39;s units.
Definition: datum.h:62
das_val_type
Enumeration of types stored in Das Array (DasAry) objects Not that any kind of value may be stored in...
Definition: value.h:51
bool das_datum_fromStr(das_datum *pThis, const char *sStr)
Initialize a numeric datum from a value and units string.
bool das_datum_fromDbl(das_datum *pThis, double value, das_units units)
Create a datum from a double value and units.
double das_datum_toDbl(const das_datum *pThis)
Get a datum value as a double.
bool das_datum_byteSeq(das_datum *pThis, das_byteseq seq, das_units units)
Wrap an external unknown type pointer as a datum.
Defines units used for items in the stream, most notably time units that reference an epoch and a ste...
char * das_datum_toStr(const das_datum *pThis, char *sStr, size_t uLen, int nFracDigits)
Write a UTF-8 string representation of a datum to a buffer.
A generic value type for use in arrays, datums and variables.
Basic date-time structure used throughout the Das1 &amp; Das2 utilities.
Definition: time.h:47
char * das_datum_toStrValOnly(const das_datum *pThis, char *sStr, size_t uLen, int nFracDigits)
Same as das_datum_toStr, but never print the units.
const char * das_units
Enumeration of unit types, that correspond to physical unit types.
Definition: units.h:135