File tree Expand file tree Collapse file tree 1 file changed +79
-1
lines changed
Expand file tree Collapse file tree 1 file changed +79
-1
lines changed Original file line number Diff line number Diff line change 11# reisfmt
2- A tiny implementation of the c++23 std::print for embedded systems.
2+ This is a tiny implementation, header only of the c++23 std::print for embedded systems.
3+ It only depend on some headers of the standard lib.
4+
5+ ## How to download using CMake
6+ ``` Cmake
7+ <!-- CMakelist.txt -->
8+ cmake_minimum_required(VERSION 3.13)
9+ include(FetchContent)
10+
11+ FetchContent_Declare(REISFMT
12+ GIT_REPOSITORY https://github.com/engdoreis/reisfmt
13+ GIT_TAG <git hash>
14+ )
15+ FetchContent_Populate(REISFMT)
16+
17+ set(NAME my_app)
18+ add_executable(${NAME} main.cc)
19+ target_include_directories(${NAME} PRIVATE "${reisfmt_SOURCE_DIR}/include")
20+ ```
21+
22+ ## How to instantiate in your project
23+ ``` cpp
24+ // log.hh
25+ #include " fmt.h"
26+ #include " uart.h"
27+
28+ struct LogUart {
29+ Uart* uart;
30+ // Implement your serialization here (UART, USB...)
31+ void write(const char* buf, size_t n) {
32+ while (n--) {
33+ uart->putc(* buf++);
34+ }
35+ }
36+ };
37+
38+ using Log = reisfmt::Fmt<LogUart>;
39+
40+ // main.cc
41+ #include " log.h"
42+ // ...
43+ int main () {
44+ // ...
45+ LogUart log_uart{uart0};
46+ Log log(log_uart);
47+ log.print("Hello {}", "World");
48+ return 0;
49+ }
50+ ```
51+
52+ ## Formating specification
53+ This library follows the libc++ format specification defined [ here] ( https://en.cppreference.com/w/cpp/utility/format/spec ) .
54+
55+ The following features above from the specifications are implemented:
56+
57+ | Spec| Implmented|
58+ | -| -|
59+ | fill-and-align| yes|
60+ | sign| no|
61+ | #| yes|
62+ | width| yes|
63+ | precision| no|
64+ | locale| no|
65+ | type| See below|
66+
67+ | Type| Implmemented|
68+ | -| -|
69+ | d| yes|
70+ | b| yes|
71+ | x| yes|
72+ | o| yes|
73+ | f| no|
74+ | a| no|
75+ | e| no|
76+ | g| no|
77+ | p| no|
78+ | ?| no|
79+
80+
You can’t perform that action at this time.
0 commit comments