Last change
on this file since 2216 was
2216,
checked in by touky, 10 years ago
|
New year copyright update.
|
-
Property svn:keywords set to
Id
|
File size:
1.1 KB
|
Line | |
---|
1 | // |
---|
2 | // Lol Engine |
---|
3 | // |
---|
4 | // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> |
---|
5 | // This program is free software; you can redistribute it and/or |
---|
6 | // modify it under the terms of the Do What The Fuck You Want To |
---|
7 | // Public License, Version 2, as published by Sam Hocevar. See |
---|
8 | // http://www.wtfpl.net/ for more details. |
---|
9 | // |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <cstdio> |
---|
16 | |
---|
17 | #ifdef WIN32 |
---|
18 | # define WIN32_LEAN_AND_MEAN |
---|
19 | # include <windows.h> |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <cstdarg> |
---|
23 | |
---|
24 | #include "core.h" |
---|
25 | |
---|
26 | namespace lol |
---|
27 | { |
---|
28 | |
---|
29 | String String::Printf(char const *format, ...) |
---|
30 | { |
---|
31 | #if defined __CELLOS_LV2__ |
---|
32 | using std::vsnprintf; |
---|
33 | #endif |
---|
34 | |
---|
35 | String ret; |
---|
36 | va_list ap; |
---|
37 | |
---|
38 | /* vsnprintf() tells us how many character we need, and we need to |
---|
39 | * add one for the terminating null byte. */ |
---|
40 | va_start(ap, format); |
---|
41 | size_t needed = vsnprintf(NULL, 0, format, ap) + 1; |
---|
42 | va_end(ap); |
---|
43 | |
---|
44 | ((Super &)ret).Reserve(needed); |
---|
45 | ret.m_count = needed; |
---|
46 | |
---|
47 | /* We don’t use va_copy because Visual Studio 2010 does not support it. */ |
---|
48 | va_start(ap, format); |
---|
49 | vsnprintf(&ret[0], needed, format, ap); |
---|
50 | va_end(ap); |
---|
51 | |
---|
52 | return ret; |
---|
53 | } |
---|
54 | |
---|
55 | } /* namespace lol */ |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.