Geom Software - C++ Programming and Geometry Libraries
Fade3D Documentation pages v0.99
/home/geom/repo/dev/geomDev/dt3/dt3Library/textTools.h
1
2
// Copyright (C) Geom Software e.U, Bernhard Kornberger, Graz/Austria
3
//
4
// This file is part of the Fade3D library. The student license is free
5
// of charge and covers personal non-commercial research. Licensees
6
// holding a commercial license may use this file in accordance with
7
// the Commercial License Agreement.
8
//
9
// This software is provided AS IS with NO WARRANTY OF ANY KIND,
10
// INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS
11
// FOR A PARTICULAR PURPOSE.
12
//
13
// Please contact the author if any conditions of this licensing are
14
// not clear to you.
15
//
16
// Author: Bernhard Kornberger, bkorn (at) geom.at
17
// https://www.geom.at
18
19
20
#pragma once
21
#include <sstream>
22
#include <string>
23
#include <iostream>
24
26
void
warning(
const
std::string& who,
const
std::string& what);
28
void
error(
const
std::string& who,
const
std::string& what);
30
void
info(
const
std::string& who,
const
std::string& what);
32
void
fatBar(
const
std::string& name,
bool
em=
false
,
bool
newLines=
false
);
34
std::string redString(
const
std::string& s,
int
em=0);
36
std::string greenString(
const
std::string& s,
int
em=0);
38
std::string magentaString(
const
std::string& s,
int
em=0);
40
std::string yellowString(
const
std::string& s,
int
em=0);
42
std::string globalPrefix();
43
44
45
template
<
class
T_InType>
46
std::string toString(
const
T_InType& in)
47
{
48
std::ostringstream oss;
49
oss << in;
50
return
oss.str();
51
}
52
53
// Switch to red (and not back again)
54
inline
std::string red()
55
{
56
#ifndef _WIN32
57
return
(
"\033[0;31m"
);
58
#else
59
return
std::string(
""
);
60
#endif
61
}
62
63
inline
std::string green()
64
{
65
#ifndef _WIN32
66
return
(
"\033[0;32m"
);
67
#else
68
return
std::string(
""
);
69
#endif
70
}
71
72
inline
std::string yellow()
73
{
74
#ifndef _WIN32
75
return
(
"\033[0;33m"
);
76
#else
77
return
std::string(
""
);
78
#endif
79
}
80
81
inline
std::string magenta()
82
{
83
#ifndef _WIN32
84
return
(
"\033[0;35m"
);
85
#else
86
return
std::string(
""
);
87
#endif
88
}
89
// Switch to white (and not back again)
90
inline
std::string white()
91
{
92
#ifndef _WIN32
93
return
(
"\033[m"
);
94
#else
95
return
std::string(
""
);
96
#endif
97
}
98
99
textTools.h