source: trunk/MagicSoft/Mars/mbase/MString.h@ 4079

Last change on this file since 4079 was 4079, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 685 bytes
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
11class MString : public TString
12{
13public:
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.