Ai
1 Star 0 Fork 24

microcolin/json

forked from lengjing/json 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
jnum.h 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
lengjing 提交于 2024-02-23 19:56 +08:00 . Adjust code structure
/*******************************************
* SPDX-License-Identifier: MIT *
* Copyright (C) 2019-.... Jing Leng *
* Contact: Jing Leng <lengjingzju@163.com> *
* URL: https://github.com/lengjingzju/json *
*******************************************/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
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_hex(const char *str, jnum_type_t *type, jnum_value_t *value);
int jnum_parse_num(const char *str, jnum_type_t *type, jnum_value_t *value);
static inline int jnum_parse(const char *str, jnum_type_t *type, jnum_value_t *value)
{
const char *s = str;
if (*s == '0' && (*(s+1) == 'x' || *(s+1) == 'X'))
return jnum_parse_hex(str, type, value);
return jnum_parse_num(str, type, value);
}
#ifdef __cplusplus
}
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/microcolin/json.git
git@gitee.com:microcolin/json.git
microcolin
json
json
master

搜索帮助