libcsdbg  1.28
C++ exception (and generic) stack trace debug library
string & csdbg::string::format ( const i8 fmt,
va_list  args 
)
protectedvirtual

Fill with a printf-style format C-string expanded with the values of a variable argument list.

Parameters
[in]fmta printf-style format C-string
[in]argsa variable argument list (as a va_list variable)
Returns
*this
Exceptions
std::bad_alloc
csdbg::exception

Definition at line 79 of file string.cpp.

References __D_ASSERT, m_data, m_length, memalign(), unlikely, csdbg::util::va_format(), and csdbg::util::va_size().

Referenced by append(), insert(), set(), and string().

80 {
81  __D_ASSERT(fmt != NULL);
82  if ( unlikely(fmt == NULL) ) {
83  va_end(args);
84  return memalign(0);
85  }
86 
87  try {
88  va_list cpargs;
89  va_copy(cpargs, args);
90  u32 len = util::va_size(fmt, cpargs);
91  memalign(len);
92 
93  util::va_format(m_data, fmt, args);
94  m_length = len;
95  return *this;
96  }
97 
98  catch (...) {
99  va_end(args);
100  throw;
101  }
102 }
virtual string & memalign(u32, bool=false)
Allocate aligned memory, mandate a minimum buffer size.
Definition: string.cpp:26
i8 * m_data
String data.
Definition: string.hpp:42
static i8 * va_format(const i8 *, va_list)
Format a buffer with a printf-style string expanded with the values of a variable argument list...
Definition: util.cpp:519
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
static i32 va_size(const i8 *, va_list)
Compute the size of a printf-style format string expanded with the values of a variable argument list...
Definition: util.cpp:489
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
u32 m_length
Character count.
Definition: string.hpp:44
#define __D_ASSERT(x)
Assertion macro.
Definition: config.hpp:268

+ Here is the call graph for this function:

+ Here is the caller graph for this function: