-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsstream.cpp
More file actions
72 lines (60 loc) · 2.14 KB
/
Copy pathsstream.cpp
File metadata and controls
72 lines (60 loc) · 2.14 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <sstream>
#include <assert.h>
namespace ppcStreams
{
/**************************************************************/
stringstream::stringstream(istream::openmode mode)
/**************************************************************/
{
_currentPosition = 0;
}
/**************************************************************/
stringstream::stringstream(string inout, istream::openmode mode)
/**************************************************************/
{
_currentPosition = 0;
str(inout);
}
/**************************************************************/
stringstream::~stringstream()
/**************************************************************/
{
}
/**************************************************************/
int stringstream::InFunction(const char* format, ...)
/**************************************************************/
{
va_list argList;
va_start(argList, format);
_currentPosition = _currentPosition + _input.InFunction(format, va_arg(argList, double));
return (_currentPosition);
}
/**************************************************************/
int stringstream::OutFunction(const char* format, ...)
/**************************************************************/
{
va_list argList;
va_start(argList, format);
int retValue = 0;
retValue = _output.OutFunction(format, va_arg(argList, double));
//Update input string stream's string
_input.str(_output.str());
//As current position in input got reset, set it to the correct value
_input._currentPosition = _currentPosition; //TODO: Fix this violation of encapsulation
return(retValue);
}
/**************************************************************/
string stringstream::str()
/**************************************************************/
{
assert(_input.str()==_output.str());
return(_input.str()); //return either input or output, both should be synced
}
/**************************************************************/
void stringstream::str(string val)
/**************************************************************/
{
_output.str(val);
_input.str(val);
}
}; /*end namespace ppcStreams*/