Toggle navigation
ivorium
iv_components
Example project
GitHub
Main Page
Modules
Classes
Files
File List
File Members
ivorium_core
DebugView
TextDebugView.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
DebugView.hpp
"
4
#include <streambuf>
5
#include <iostream>
6
7
namespace
iv
8
{
9
10
//----------------------------------------------------------------------------------------------------------------------
11
//------------- TextDebugView ---------------------------------------------------------------------------------------
14
class
TextDebugView
:
public
DebugView
15
{
16
public
:
17
TextDebugView
(
Context
*
context
);
18
19
std::ostream &
out
();
20
21
void
prefix_push
(
const
char
* pref );
22
void
prefix_push_align
();
23
void
prefix_pop
();
24
25
void
postfix_push
(
const
char
* postf );
26
void
postfix_pop
();
27
28
protected
:
29
virtual
void
print_line
(
const
char
* prefix,
const
char
* line,
const
char
* postfix ) = 0;
30
void
endline
();
31
32
private
:
33
class
tdc_streambuf
:
public
std::streambuf
34
{
35
public
:
36
tdc_streambuf
(
TextDebugView
*
context
);
37
virtual
std::streambuf::int_type overflow( std::streambuf::int_type value )
override
;
38
void
endline
();
39
size_t
get_line_size();
40
private
:
41
void
flush_as_line();
42
private
:
43
std::string buffer;
44
TextDebugView
*
context
;
45
};
46
47
class
tdc_ostream :
public
std::ostream
48
{
49
public
:
50
tdc_ostream(
TextDebugView
*
context
);
51
~tdc_ostream();
52
53
void
endline
();
54
size_t
get_line_size();
55
};
56
57
friend
class
tdc_streambuf
;
58
59
void
write_line(
const
char
* line );
60
void
init_line();
61
std::string prefix();
62
std::string postfix();
63
64
private
:
65
std::vector< std::string > prefixes;
66
std::string _prefix;
67
std::vector< std::string > postfixes;
68
std::string _postfix;
69
tdc_ostream outstream;
70
};
71
72
}