MCPcopy Create free account
hub / github.com/cinder/Cinder / ImFormatStringToTempBufferV

Function ImFormatStringToTempBufferV

src/imgui/imgui.cpp:2244–2273  ·  view source on GitHub ↗

FIXME: Should rework API toward allowing multiple in-flight temp buffers (easier and safer for caller) by making the caller acquire a temp buffer token, with either explicit or destructor release, e.g. ImGuiTempBufferToken token; ImFormatStringToTempBuffer(token, ...);

Source from the content-addressed store, hash-verified

2242// ImGuiTempBufferToken token;
2243// ImFormatStringToTempBuffer(token, ...);
2244void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end, const char* fmt, va_list args)
2245{
2246 ImGuiContext& g = *GImGui;
2247 if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
2248 {
2249 const char* buf = va_arg(args, const char*); // Skip formatting when using "%s"
2250 if (buf == NULL)
2251 buf = "(null)";
2252 *out_buf = buf;
2253 if (out_buf_end) { *out_buf_end = buf + ImStrlen(buf); }
2254 }
2255 else if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '*' && fmt[3] == 's' && fmt[4] == 0)
2256 {
2257 int buf_len = va_arg(args, int); // Skip formatting when using "%.*s"
2258 const char* buf = va_arg(args, const char*);
2259 if (buf == NULL)
2260 {
2261 buf = "(null)";
2262 buf_len = ImMin(buf_len, 6);
2263 }
2264 *out_buf = buf;
2265 *out_buf_end = buf + buf_len; // Disallow not passing 'out_buf_end' here. User is expected to use it.
2266 }
2267 else
2268 {
2269 int buf_len = ImFormatStringV(g.TempBuffer.Data, g.TempBuffer.Size, fmt, args);
2270 *out_buf = g.TempBuffer.Data;
2271 if (out_buf_end) { *out_buf_end = g.TempBuffer.Data + buf_len; }
2272 }
2273}
2274
2275#ifndef IMGUI_ENABLE_SSE4_2_CRC
2276// CRC32 needs a 1KB lookup table (not cache friendly)

Callers 6

TextVMethod · 0.85
TextAlignedVMethod · 0.85
LabelTextVMethod · 0.85
BulletTextVMethod · 0.85
TreeNodeExVMethod · 0.85

Calls 2

ImMinFunction · 0.85
ImFormatStringVFunction · 0.85

Tested by

no test coverage detected