https://github.com/Viatorus/emio
A safe and fast high-level and low-level character input/output library for bare-metal and RTOS based embedded systems with a very small binary footprint.
https://github.com/Viatorus/emio
Last synced: 2 days ago
JSON representation
A safe and fast high-level and low-level character input/output library for bare-metal and RTOS based embedded systems with a very small binary footprint.
- Host: GitHub
- URL: https://github.com/Viatorus/emio
- Owner: Viatorus
- License: mit
- Created: 2022-01-16T13:14:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-07-13T21:49:48.000Z (4 months ago)
- Last Synced: 2025-07-13T23:33:17.101Z (4 months ago)
- Language: C++
- Homepage: https://viatorus.github.io/emio/
- Size: 764 KB
- Stars: 165
- Watchers: 4
- Forks: 6
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- fucking-awesome-cpp - emio - A safe and fast high-level and low-level character input/output library. [MIT] (Miscellaneous)
- awesome-hpp - emio - level and low-level character input/output C++20 library. | [](https://opensource.org/licenses/MIT) | (Data Formatting and Presentation)
- awesome-cpp - emio - A safe and fast high-level and low-level character input/output library. [MIT] (Miscellaneous)
- awesome-embedded-software - emio - Very small binary footprint std::format like formatting using C++20. (User Interface / printf)
README

[](https://github.com/Viatorus/emio/actions/workflows/ci.yml)
[](https://codecov.io/gh/Viatorus/emio)
[](https://conan.io/center/recipes/emio)
**em{io}** is a safe and fast high-level and low-level character input/output library for bare-metal and RTOS based
embedded systems with a very small binary footprint.
```cpp
// High-level
std::string str = emio::format("The answer is {}.", 42); // Format argument.
int answer{};
emio::result scan_res = emio::scan(str, "The answer is {}.", answer); // Scan input string.
if (scan_res) {
emio::print("The answer is {}.", answer); // Output to console.
}
// Without using heap.
emio::static_buffer<128> buf{};
emio::format_to(buf, "The answer is {:#x}.", 42).value();
buf.view(); // <- The answer is 0x2a.
// Low-level
emio::writer wrt{buf};
wrt.write_str(" In decimal: ").value();
wrt.write_int(42).value();
wrt.write_char('.').value();
buf.view(); // <- The answer is 0x2a. In decimal: 42.
emio::reader rdr{"17c"};
EMIO_TRY(uint32_t number, rdr.parse_int()); // <- 17
EMIO_TRY(char suffix, rdr.read_char()); // <- c
```
[**This library is in beta status! Please help to make it fly!**](https://github.com/Viatorus/emio/milestone/1)
* [API documentation](docs/API.md)
* Try emio [online](https://godbolt.org/z/fP7z7MzbG).
## Yet another character input/output library
Bare-metal and RTOS based embedded systems do have special requirements which are mostly overlooked by the C++ standard,
its implementations and other libraries.
Therefore, this library:
* has a very small binary footprint **(~38 times smaller than fmtlib!)**
* returns a result object instead of throwing an exception
* provides a high-level and low-level API which can be used at compile-time
Read more about it in the [DESIGN](docs/DESIGN.md) document.
## Including emio in your project
- With CMake and fetch content
```cmake
FetchContent_Declare(
emio
GIT_TAG main
GIT_REPOSITORY https://github.com/Viatorus/emio.git
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(emio)
```
- Download the [single header file](https://viatorus.github.io/emio/) generated with [Quom](https://github.com/Viatorus/quom)
- From [Conan Center](https://conan.io/center/recipes/emio)
A compiler supporting C++20 is required. Tested with GCC 11/12/13 and Clang 16/17.
## Contributing
See the [CONTRIBUTING](docs/CONTRIBUTING.md) document.
## Licensing
em{io} is distributed under the [MIT license](LICENSE).