-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjnum.h
50 lines (44 loc) · 1.13 KB
/
jnum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*******************************************
* SPDX-License-Identifier: MIT *
* Copyright (C) 2019-.... Jing Leng *
* Contact: Jing Leng <[email protected]> *
* URL: https://github.com/lengjingzju/json *
*******************************************/
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
JNUM_NULL,
JNUM_BOOL,
JNUM_INT,
JNUM_HEX,
JNUM_LINT,
JNUM_LHEX,
JNUM_DOUBLE,
} jnum_type_t;
typedef union {
bool vbool;
int32_t vint;
uint32_t vhex;
int64_t vlint;
uint64_t vlhex;
double vdbl;
} jnum_value_t;
int jnum_itoa(int32_t num, char *buffer);
int jnum_ltoa(int64_t num, char *buffer);
int jnum_htoa(uint32_t num, char *buffer);
int jnum_lhtoa(uint64_t num, char *buffer);
int jnum_dtoa(double num, char *buffer);
int32_t jnum_atoi(const char *str);
int64_t jnum_atol(const char *str);
uint32_t jnum_atoh(const char *str);
uint64_t jnum_atolh(const char *str);
double jnum_atod(const char *str);
int jnum_parse(const char *str, jnum_type_t *type, jnum_value_t *value);
#ifdef __cplusplus
}
#endif