TinyCStringBuilder
Fast snprintf replacement for embedded+ use. Header only C++11 lib
Install / Use
/learn @DraTeots/TinyCStringBuilderREADME
TinyStringBuilder
C strings builder - sprintf replacement for embedded use.
Header only library written in C++11 aimed for embedded usage. Faster than sprintf.
- No dynamic memory allocations & minimal memory foorprint
- C string safe
- Faster than sprintf family
- Floating point support (which can be switched off)
- Control over features to build (make it tiny for tiny devices)
- Follow fixed size stdint type family (uint8_t, int16_t, ...)
- No std library dependence
Developed with thought of tiny or no-OS embedded applications, where dynamic memory allocations are not advisable and C++ std:: library is not appliable.
Exameple
char buffer[100];
CStringBuilder cb(buffer); // Create cstring builder, give it the buffer
cb << "hello world! x = " << 5; // Use << operator overloads
cb.add(5); // or do it by hand
puts(cb.cstr()); // Use cstr() to get buffer pointer
if(cb.size()) ... // Use size() to get actual string size
if(cb.buffer_size()) ... // Get initial buffer size
Floating point
// Set TCSB_USE_FP 1
cb.addf(4.545) ;
// or
cb << 4.545;
Integer and floating point promotions have the same rank and integer and floating
point conversions have the same rank (more here).
So we have to use addf for floats
Future optimisation
First, needless to say that even strnlen can be implemented with
a lot of black magic to perform faster.
No doubts this project can be implemented partly in asm + #ifdefs to particular architectures
so that it is even faster.
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
