Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
ImGuiTextBuffer Struct Reference

#include <src/imgui/imgui.h>

+ Collaboration diagram for ImGuiTextBuffer:

Public Member Functions

 ImGuiTextBuffer ()
 
char operator[] (int i) const
 
const char * begin () const
 
const char * end () const
 
int size () const
 
bool empty () const
 
void clear ()
 
void reserve (int capacity)
 
const char * c_str () const
 
IMGUI_API void append (const char *str, const char *str_end=NULL)
 
IMGUI_API void appendf (const char *fmt,...) IM_FMTARGS(2)
 
IMGUI_API void appendfv (const char *fmt, va_list args) IM_FMTLIST(2)
 

Public Attributes

ImVector< char > Buf
 

Static Public Attributes

static IMGUI_API char EmptyString [1] = { 0 }
 

Detailed Description

Constructor & Destructor Documentation

◆ ImGuiTextBuffer()

ImGuiTextBuffer::ImGuiTextBuffer ( )
inline
2055{ }

Member Function Documentation

◆ append()

void ImGuiTextBuffer::append ( const char *  str,
const char *  str_end = NULL 
)
2138{
2139 int len = str_end ? (int)(str_end - str) : (int)strlen(str);
2140
2141 // Add zero-terminator the first time
2142 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2143 const int needed_sz = write_off + len;
2144 if (write_off + len >= Buf.Capacity)
2145 {
2146 int new_capacity = Buf.Capacity * 2;
2147 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2148 }
2149
2150 Buf.resize(needed_sz);
2151 memcpy(&Buf[write_off - 1], str, (size_t)len);
2152 Buf[write_off - 1 + len] = 0;
2153}
ImVector< char > Buf
Definition imgui.h:2052
void reserve(int new_capacity)
Definition imgui.h:1693
int Size
Definition imgui.h:1655
int Capacity
Definition imgui.h:1656
void resize(int new_size)
Definition imgui.h:1690

Referenced by ImGui::TabItemEx(), TableSettingsHandler_WriteAll(), ImGui::TableSetupColumn(), and WindowSettingsHandler_WriteAll().

+ Here is the caller graph for this function:

◆ appendf()

void ImGuiTextBuffer::appendf ( const char *  fmt,
  ... 
)
2156{
2157 va_list args;
2158 va_start(args, fmt);
2159 appendfv(fmt, args);
2160 va_end(args);
2161}
IMGUI_API void appendfv(const char *fmt, va_list args) IM_FMTLIST(2)
Definition imgui.cpp:2164

Referenced by TableSettingsHandler_WriteAll(), and WindowSettingsHandler_WriteAll().

+ Here is the caller graph for this function:

◆ appendfv()

void ImGuiTextBuffer::appendfv ( const char *  fmt,
va_list  args 
)
2165{
2166 va_list args_copy;
2167 va_copy(args_copy, args);
2168
2169 int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
2170 if (len <= 0)
2171 {
2172 va_end(args_copy);
2173 return;
2174 }
2175
2176 // Add zero-terminator the first time
2177 const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
2178 const int needed_sz = write_off + len;
2179 if (write_off + len >= Buf.Capacity)
2180 {
2181 int new_capacity = Buf.Capacity * 2;
2182 Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
2183 }
2184
2185 Buf.resize(needed_sz);
2186 ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
2187 va_end(args_copy);
2188}
#define va_copy(dest, src)
Definition imgui.cpp:2131
int ImFormatStringV(char *buf, size_t buf_size, const char *fmt, va_list args)
Definition imgui.cpp:1453

References ImFormatStringV(), and va_copy.

Referenced by ExampleAppLog::AddLog(), and LogTextV().

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

◆ begin()

const char * ImGuiTextBuffer::begin ( ) const
inline
2057{ return Buf.Data ? &Buf.front() : EmptyString; }
static IMGUI_API char EmptyString[1]
Definition imgui.h:2053
T & front()
Definition imgui.h:1683
T * Data
Definition imgui.h:1657

References ImVector< T >::Data, and ImVector< T >::front().

Referenced by ExampleAppLog::Draw(), and ImGui::LogFinish().

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

◆ c_str()

const char * ImGuiTextBuffer::c_str ( ) const
inline
2063{ return Buf.Data ? Buf.Data : EmptyString; }

References ImVector< T >::Data.

Referenced by LogTextV(), ImGui::SaveIniSettingsToMemory(), and ImGui::ShowMetricsWindow().

+ Here is the caller graph for this function:

◆ clear()

void ImGuiTextBuffer::clear ( )
inline
2061{ Buf.clear(); }
void clear()
Definition imgui.h:1678

References ImVector< T >::clear().

Referenced by ExampleAppLog::Clear(), ImGui::ClearIniSettings(), ImGui::LogFinish(), ImGui::Shutdown(), and ImGui::TableGcCompactTransientBuffers().

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

◆ empty()

bool ImGuiTextBuffer::empty ( ) const
inline
2060{ return Buf.Size <= 1; }

References ImVector< T >::Size.

Referenced by ImGui::LogBegin(), and ImGui::LogFinish().

+ Here is the caller graph for this function:

◆ end()

const char * ImGuiTextBuffer::end ( ) const
inline
2058{ return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator
T & back()
Definition imgui.h:1685

References ImVector< T >::back(), and ImVector< T >::Data.

Referenced by ExampleAppLog::Draw().

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

◆ operator[]()

char ImGuiTextBuffer::operator[] ( int  i) const
inline
2056{ IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; }
#define IM_ASSERT(_EXPR)
Definition imgui.h:81

References ImVector< T >::Data, and IM_ASSERT.

◆ reserve()

void ImGuiTextBuffer::reserve ( int  capacity)
inline
2062{ Buf.reserve(capacity); }

References ImVector< T >::reserve().

Referenced by TableSettingsHandler_WriteAll(), and WindowSettingsHandler_WriteAll().

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

◆ size()

int ImGuiTextBuffer::size ( ) const
inline
2059{ return Buf.Size ? Buf.Size - 1 : 0; }

References ImVector< T >::Size.

Referenced by ExampleAppLog::AddLog(), LogTextV(), ImGui::SaveIniSettingsToMemory(), ImGui::ShowMetricsWindow(), ImGui::TabItemEx(), TableSettingsHandler_WriteAll(), ImGui::TableSetupColumn(), and WindowSettingsHandler_WriteAll().

+ Here is the caller graph for this function:

Member Data Documentation

◆ Buf

◆ EmptyString

char ImGuiTextBuffer::EmptyString = { 0 }
static

The documentation for this struct was generated from the following files: