-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathostringstream.cpp
57 lines (49 loc) · 1.65 KB
/
ostringstream.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <ostringstream>
namespace ppcStreams
{
/**************************************************************/
ostringstream::ostringstream(ios::openmode mode)
/**************************************************************/
{
str("");
}
/**************************************************************/
ostringstream::ostringstream(string output, ios::openmode mode)
/**************************************************************/
{
str(output);
}
/**************************************************************/
ostringstream::~ostringstream()
/**************************************************************/
{
}
/**************************************************************/
int ostringstream::OutFunction(const char* format, ...)
/**************************************************************/
{
va_list argList;
va_start(argList, format);
char temp[MAX_SIZE_STD_STRING_IN_STREAM]; //limit size of single argument to 2048 byte (2 K)
sprintf(temp, format, va_arg(argList, double));
size_t extraBytesNeeded = strlen(temp);
char* temp2 = new char[str().length()+1+(int)extraBytesNeeded+1];
strcpy(temp2, str().c_str());
strcat(temp2, temp);
str(string(temp2));
delete(temp2);
return (int)extraBytesNeeded;
}
/**************************************************************/
string ostringstream::str()
/**************************************************************/
{
return(_output);
}
/**************************************************************/
void ostringstream::str(string val)
/**************************************************************/
{
_output = val;
}
}; /*end namespace ppcStreams*/