tvariant.h 2.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

H
Haojun Liao 已提交
16 17
#ifndef TDENGINE_TVARIANT_H
#define TDENGINE_TVARIANT_H
H
hzcheng 已提交
18

19 20 21 22
#ifdef __cplusplus
extern "C" {
#endif

H
Haojun Liao 已提交
23 24
#include "tarray.h"

25
// variant, each number/string/field_id has a corresponding struct during parsing sql
H
Haojun Liao 已提交
26 27 28
typedef struct SVariant {
  uint32_t   nType;
  int32_t    nLen;  // only used for string, for number, it is useless
29
  union {
30 31
    int64_t  i;
    uint64_t u;
H
Haojun Liao 已提交
32 33
    double   d;
    char    *pz;
34
    wchar_t *wpz;
weixin_48148422's avatar
weixin_48148422 已提交
35
    SArray  *arr; // only for 'in' query to hold value list, not value for a field
36
  };
H
Haojun Liao 已提交
37
} SVariant;
38

39 40
int32_t toInteger(const char* z, int32_t n, int32_t base, int64_t* value, bool* issigned);

H
Haojun Liao 已提交
41
bool taosVariantIsValid(SVariant *pVar);
42

43
void taosVariantCreate(SVariant *pVar, const char* z, int32_t n, int32_t type);
44

H
Haojun Liao 已提交
45
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
46

H
Haojun Liao 已提交
47
void taosVariantDestroy(SVariant *pV);
48

H
Haojun Liao 已提交
49
void taosVariantAssign(SVariant *pDst, const SVariant *pSrc);
50

H
Haojun Liao 已提交
51
int32_t taosVariantCompare(const SVariant* p1, const SVariant* p2);
52

H
Haojun Liao 已提交
53
int32_t taosVariantToString(SVariant *pVar, char *dst);
54

H
Haojun Liao 已提交
55
int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix);
56

H
Haojun Liao 已提交
57 58 59
#if 0
int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo);
#endif
W
wpan 已提交
60

H
Haojun Liao 已提交
61
int32_t taosVariantTypeSetType(SVariant *pVariant, char type);
62 63 64 65 66

#ifdef __cplusplus
}
#endif

H
Haojun Liao 已提交
67
#endif  // TDENGINE_TVARIANT_H