FastLED 3.10.6
Loading...
Searching...
No Matches

◆ snprintf() [1/2]

int fl::snprintf ( char * buffer,
fl::size size,
const char * format )

Definition at line 292 of file stdio.cpp.hpp.

292 {
293 if (!buffer || size == 0) {
294 return 0;
295 }
296
297 fl::size written = 0;
298 const auto append_char = [&](char value) {
299 if (written < size - 1) {
300 buffer[written++] = value;
301 }
302 };
303 const auto append_text = [&](const char* text) {
304 while (*text && written < size - 1) {
305 buffer[written++] = *text++;
306 }
307 };
308
309 while (*format && written < size - 1) {
310 if (*format == '%') {
313 append_text(spec.type == '%' ? "%" : "<missing_arg>");
314 continue;
315 }
316 if (format[0] == '{' && format[1] == '{') {
317 append_char('{');
318 format += 2;
319 continue;
320 }
321 if (format[0] == '}' && format[1] == '}') {
322 append_char('}');
323 format += 2;
324 continue;
325 }
326 if (format[0] == '{' && format[1] == '}') {
327 append_text("<missing_arg>");
328 format += 2;
329 continue;
330 }
331 append_char(*format++);
332 }
333 buffer[written] = '\0';
334 return static_cast<int>(written);
335}
FormatSpec parse_format_spec(const char *&format) FL_NO_EXCEPT
Definition stdio.h:130
constexpr int type_rank< T >::value
fl::string format(const char *fmt)
Format with no arguments.
Definition format.h:439

References FL_NO_EXCEPT, format(), fl::printf_detail::parse_format_spec(), fl::printf_detail::FormatSpec::type, and type_rank< T >::value.

Referenced by fl::net::http::ChunkedWriter::chunkOverhead(), fl::ScopedTrace::dump(), fl::audio::detector::Key::getKeyName(), getPort(), fl::net::http::HttpStreamTransport::idToString(), fl::third_party::TJpgInstanceDecoder::initializeDecoder(), fl::detail::log_format_string(), fl::SerialPort::printf(), fl::third_party::TJpgInstanceDecoder::processChunk(), and fl::net::http::ChunkedWriter::writeChunk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: