summaryrefslogtreecommitdiff
path: root/project2/console/consolePresenter.cpp
blob: 05285a23acaab13e3d4cb7c4b958dad80b7afddb (plain)
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
73
74
75
76
77
78
79
#include <pch.hpp>
#include <stdio.h>
#include "consolePresenter.h"

ConsolePresenter::ConsolePresenter() :
	Presenter(Default),
	indent(0),
	out(stdout, true)
{
}

void
ConsolePresenter::init(ExecContext *)
{
}

void
ConsolePresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const
{
	fprintf(stdout, "%*s", indent, "");
	fprintf(stdout, ">>> ");
	if (!ns.empty()) {
		fprintf(stdout, "%s::", ns.c_str());
	}
	fprintf(stdout, "%s\n", name.c_str());
	indent += 2;
}

void
ConsolePresenter::addAttribute(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const
{
	fprintf(stdout, "%*s", indent, "");
	if (!ns.empty()) {
		fprintf(stdout, "%s::", ns.c_str());
	}
	fprintf(stdout, "@%s = ", name.c_str());
	boost::apply_visitor(out, value);
	fprintf(stdout, "\n");
}

void
ConsolePresenter::addNamedValue(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const
{
	fprintf(stdout, "%*s", indent, "");
	if (!ns.empty()) {
		fprintf(stdout, "%s::", ns.c_str());
	}
	fprintf(stdout, "%s = ", name.c_str());
	boost::apply_visitor(out, value);
	fprintf(stdout, "\n");
}

void
ConsolePresenter::addText(const VariableType & value) const
{
	fprintf(stdout, "%*s<local> = ", indent, "");
	boost::apply_visitor(out, value);
	fprintf(stdout, "\n");
}

void
ConsolePresenter::popSub() const
{
	indent -= 2;
	fprintf(stdout, "%*s<<<\n", indent, "");
}

void
ConsolePresenter::addNewArray(const Glib::ustring & name, bool) const
{
	pushSub(name, "");
}

void
ConsolePresenter::finishArray(bool) const
{
	popSub();
}