Line | |
---|
1 | #ifndef MARS_MString
|
---|
2 | #define MARS_MString
|
---|
3 |
|
---|
4 | #ifndef ROOT_TString
|
---|
5 | #include <TString.h>
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <stdarg.h>
|
---|
10 |
|
---|
11 | class MString : public TString
|
---|
12 | {
|
---|
13 | public:
|
---|
14 | MString &Print(const char *fmt, ...)
|
---|
15 | {
|
---|
16 | va_list ap;
|
---|
17 | va_start(ap, fmt);
|
---|
18 |
|
---|
19 | Int_t n=256;
|
---|
20 |
|
---|
21 | char *ret=0;
|
---|
22 |
|
---|
23 | while (1)
|
---|
24 | {
|
---|
25 | ret = new char[n+1];
|
---|
26 | Int_t sz = vsnprintf(ret, n, fmt, ap);
|
---|
27 | if (sz<=n)
|
---|
28 | break;
|
---|
29 |
|
---|
30 | n *= 2;
|
---|
31 | delete [] ret;
|
---|
32 | };
|
---|
33 |
|
---|
34 | va_end(ap);
|
---|
35 |
|
---|
36 | *static_cast<TString*>(this) = ret;
|
---|
37 |
|
---|
38 | delete [] ret;
|
---|
39 |
|
---|
40 | return *this;
|
---|
41 | }
|
---|
42 | ClassDef(MString, 1)
|
---|
43 | };
|
---|
44 |
|
---|
45 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.