MCPcopy Create free account
hub / github.com/anjo76/angelscript / Format

Method Format

sdk/angelscript/source/as_string.cpp:281–315  ·  view source on GitHub ↗

Returns the length

Source from the content-addressed store, hash-verified

279
280// Returns the length
281size_t asCString::Format(const char *format, ...)
282{
283 va_list args;
284 va_start(args, format);
285
286 const size_t startSize = 1024;
287 char tmp[startSize];
288 int r = asVSNPRINTF(tmp, startSize-1, format, args);
289
290 if( r > 0 && r < int(startSize) )
291 {
292 Assign(tmp, r);
293 }
294 else
295 {
296 // TODO: For some reason this doesn't work properly on Linux. Perhaps the
297 // problem is related to vsnprintf not keeping the state of va_arg.
298 // Perhaps I need to rewrite this in some way to keep the state
299 size_t n = startSize*2;
300 asCString str; // Use temporary string in case the current buffer is a parameter
301 str.Allocate(n, false);
302
303 while( (r = asVSNPRINTF(str.AddressOf(), n, format, args)) < 0 || r >= int(n) )
304 {
305 n *= 2;
306 str.Allocate(n, false);
307 }
308
309 Assign(str.AddressOf(), r);
310 }
311
312 va_end(args);
313
314 return length;
315}
316
317char &asCString::operator [](size_t index)
318{

Callers 15

AddRefMethod · 0.45
ErrorMethod · 0.45
ReadInnerMethod · 0.45
ReadFunctionMethod · 0.45
ReadTypeDeclarationMethod · 0.45
ReadTypeInfoMethod · 0.45
CompileFunctionMethod · 0.45
CallCopyConstructorMethod · 0.45
CompileStatementBlockMethod · 0.45

Calls 3

AssignFunction · 0.85
AllocateMethod · 0.45
AddressOfMethod · 0.45

Tested by

no test coverage detected