deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
u_sstream.h
1/*
2 * Copyright (c) 2023 Manuel Pietschmann.
3 * All rights reserved.
4 *
5 * The software in this package is published under the terms of the BSD
6 * style license a copy of which has been included with this distribution in
7 * the LICENSE.txt file.
8 *
9 */
10
11#ifndef U_SSTREAM_H
12#define U_SSTREAM_H
13
14#ifndef U_LIBAPI
15#ifdef _WIN32
16 #ifdef USE_ULIB_SHARED
17 #define U_LIBAPI __declspec(dllimport)
18 #endif
19 #ifdef BUILD_ULIB_SHARED
20 #define U_LIBAPI __declspec(dllexport)
21 #endif
22#endif
23#endif /* ! defined(U_LIBAPI) */
24
25#ifndef U_LIBAPI
26#define U_LIBAPI
27#endif
28
29/* ANSI C module for building and parsing strings.
30
31 The library is standalone without using libc.
32 Upstream repository: https://git.sr.ht/~cryo/u_sstream
33*/
34
35typedef enum
36{
37 U_SSTREAM_OK = 0,
38 U_SSTREAM_ERR_RANGE = 1,
39 U_SSTREAM_ERR_INVALID = 2,
40 U_SSTREAM_ERR_NO_SPACE = 3,
41} U_sstream_status;
42
43typedef struct U_SStream
44{
45 char *str;
46 unsigned pos;
47 unsigned len;
48 U_sstream_status status;
49} U_SStream;
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55U_LIBAPI void U_sstream_init(U_SStream *ss, void *str, unsigned size);
56U_LIBAPI unsigned U_sstream_pos(const U_SStream *ss);
57U_LIBAPI const char *U_sstream_str(const U_SStream *ss);
58U_LIBAPI unsigned U_sstream_remaining(const U_SStream *ss);
59U_LIBAPI int U_sstream_at_end(const U_SStream *ss);
60U_LIBAPI long U_sstream_get_long(U_SStream *ss);
61U_LIBAPI double U_sstream_get_double(U_SStream *ss);
62U_LIBAPI char U_sstream_peek_char(U_SStream *ss);
63U_LIBAPI void U_sstream_skip_whitespace(U_SStream *ss);
64U_LIBAPI int U_sstream_starts_with(U_SStream *ss, const char *str);
65U_LIBAPI int U_sstream_find(U_SStream *ss, const char *str);
66U_LIBAPI void U_sstream_seek(U_SStream *ss, unsigned pos);
67U_LIBAPI void U_sstream_put_str(U_SStream *ss, const char *str);
68
86U_LIBAPI void U_sstream_put_double(U_SStream *ss, double num, int precision);
87U_LIBAPI void U_sstream_put_long(U_SStream *ss, long num);
88U_LIBAPI void U_sstream_put_longlong(U_SStream *ss, long long num);
89U_LIBAPI void U_sstream_put_ulonglong(U_SStream *ss, unsigned long long num);
90U_LIBAPI void U_sstream_put_hex(U_SStream *ss, const void *data, unsigned size);
91
92U_LIBAPI long U_strtol(const char *s, unsigned len, const char **endp, int *err);
93U_LIBAPI double U_strtod(const char *str, unsigned len, const char **endp, int *err);
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif /* U_SSTREAM_H */
Definition u_sstream.h:44