MtFmt 1.0.0
MtFmt is a format library on embed. system and wrote by pure C.
载入中...
搜索中...
未找到
mm_io.h
浏览该文件的文档.
1// SPDX-License-Identifier: LGPL-3.0
12#if !defined(_INCLUDE_MM_IO_H_)
13#define _INCLUDE_MM_IO_H_ 1
14#include "mm_cfg.h"
15#include "mm_result.h"
16#include "mm_type.h"
17
23 void* ctx, const byte_t* data, usize_t len
24);
25
44
54mstr_io_init(void* context, MStrIOCallback* obj, MStrIOWrite cb_write);
55
68 MStrIOCallback* io, const char* fmt, usize_t fmt_place, ...
69);
70
85 const char* fmt,
86 usize_t fmt_place,
87 va_list* ap_ptr
88);
89
94MSTR_EXPORT_API(MStrIOCallback*) mstr_get_stdout(void);
95
96#define MSTR_COUNT_VA_ARGS_HELPER( \
97 _0, \
98 _1, \
99 _2, \
100 _3, \
101 _4, \
102 _5, \
103 _6, \
104 _7, \
105 _8, \
106 _9, \
107 _10, \
108 _11, \
109 _12, \
110 _13, \
111 _14, \
112 _15, \
113 _16, \
114 N, \
115 ... \
116) \
117 N
118
123#define MSTR_COUNT_VA_ARGS(...) \
124 MSTR_COUNT_VA_ARGS_HELPER( \
125 0, \
126 ##__VA_ARGS__, \
127 16, \
128 15, \
129 14, \
130 13, \
131 12, \
132 11, \
133 10, \
134 9, \
135 8, \
136 7, \
137 6, \
138 5, \
139 4, \
140 3, \
141 2, \
142 1, \
143 0 \
144 )
145
146#if _MSTR_USE_STD_IO
153#define mstr_print(fmt, ...) \
154 (mstr_ioformat( \
155 mstr_get_stdout(), \
156 fmt, \
157 MSTR_COUNT_VA_ARGS(__VA_ARGS__), \
158 ##__VA_ARGS__ \
159 ))
160#else
167#define mstr_print(fmt, ...) ((void)(0))
168#endif // _MSTR_USE_STD_IO
169#endif // _INCLUDE_MM_IO_H_
配置选项
#define MSTR_EXPORT_API(ret)
Definition mm_cfg.h:421
struct tagMStrIOCallback MStrIOCallback
IO回调的接口
mstr_result_t(* MStrIOWrite)(void *ctx, const byte_t *data, usize_t len)
写入数据
Definition mm_io.h:22
mstr_iovformat(MStrIOCallback *io, const char *fmt, usize_t fmt_place, va_list *ap_ptr)
格式化字符串到指定io
Definition mm_io.c:66
mstr_io_init(void *context, MStrIOCallback *obj, MStrIOWrite cb_write)
初始化IO的结构
Definition mm_io.c:40
mstr_ioformat(MStrIOCallback *io, const char *fmt, usize_t fmt_place,...)
格式化字符串到指定io
Definition mm_io.c:53
结果类型
enum tagMStrResult mstr_result_t
结果类型
type alias和type def
uint8_t byte_t
字节(无符号)
Definition mm_type.h:26
size_t usize_t
尺寸(无符号)
Definition mm_type.h:32
IO回调的接口
Definition mm_io.h:31
void * capture
上下文
Definition mm_io.h:36
MStrIOWrite io_write
写入数据callback
Definition mm_io.h:42