ToQString.h
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* ArmarX is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation.
7
*
8
* ArmarX is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*
16
* @package ArmarXGui::ArmarXGuiBase
17
* @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18
* @date 2017
19
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20
* GNU General Public License
21
*/
22
#pragma once
23
24
#include <string>
25
#include <sstream>
26
#include <vector>
27
28
#include <QString>
29
30
//#include <ArmarXCore/core/util/TemplateMetaProgramming.h>
31
32
namespace
armarx
33
{
34
inline
QString
ToQString
(
const
char
*
str
)
35
{
36
return
{
str
};
37
}
38
39
inline
QString
ToQString
(
const
std::string&
s
)
40
{
41
return
QString::fromStdString(
s
);
42
}
43
44
inline
QString
ToQString
(
float
v
)
45
{
46
return
QString::number(
v
);
47
}
48
49
inline
QString
ToQString
(
double
v
)
50
{
51
return
QString::number(
v
);
52
}
53
54
inline
QString
ToQString
(
char
v
)
55
{
56
return
QString::number(
v
);
57
}
58
59
inline
QString
ToQString
(std::uint8_t
v
)
60
{
61
return
QString::number(
v
);
62
}
63
64
inline
QString
ToQString
(std::uint16_t
v
)
65
{
66
return
QString::number(
v
);
67
}
68
69
inline
QString
ToQString
(std::uint32_t
v
)
70
{
71
return
QString::number(
v
);
72
}
73
74
inline
QString
ToQString
(std::uint64_t
v
)
75
{
76
return
QString::number(
v
);
77
}
78
79
inline
QString
ToQString
(std::int8_t
v
)
80
{
81
return
QString::number(
v
);
82
}
83
84
inline
QString
ToQString
(std::int16_t
v
)
85
{
86
return
QString::number(
v
);
87
}
88
89
inline
QString
ToQString
(std::int32_t
v
)
90
{
91
return
QString::number(
v
);
92
}
93
94
inline
QString
ToQString
(std::int64_t
v
)
95
{
96
return
QString::number(
v
);
97
}
98
99
inline
QString
ToQString
(
const
std::stringstream&
str
)
100
{
101
return
ToQString
(
str
.str());
102
}
103
104
inline
QString
ToQString
(
bool
b)
105
{
106
return
b ?
"true"
:
"false"
;
107
}
108
109
template
<
class
T>
110
inline
QString
ToQString
(
const
std::vector<T>&
v
)
111
{
112
if
(
v
.empty())
113
{
114
return
""
;
115
}
116
std::stringstream
str
;
117
str
<<
v
.front();
118
for
(std::size_t i = 1; i <
v
.size(); ++i)
119
{
120
str
<<
" "
<<
v
.at(i);
121
}
122
return
ToQString
(
str
);
123
}
124
125
template
<
class
T>
126
inline
QString
ToQString
(
const
std::vector<std::vector<T>>&
v
)
127
{
128
if
(
v
.empty())
129
{
130
return
""
;
131
}
132
std::stringstream
str
;
133
str
<<
ToQString
(
v
.front()).toStdString();
134
for
(std::size_t i = 1; i <
v
.size(); ++i)
135
{
136
str
<<
"\n"
<<
ToQString
(
v
.at(i)).toStdString();
137
}
138
return
ToQString
(
str
);
139
}
140
141
// template<class T>
142
// inline QString ToQString(const T& t)
143
// // inline typename std::enable_if<meta::HasToString<T>::value, QString>::type ToQString(const T& t)
144
// {
145
// return ToQString(to_string(t));
146
// }
147
148
// template<class T>
149
// inline QString ToQString(const T& t)
150
// {
151
// std::stringstream str;
152
// str << t;
153
// return ToQString(str);
154
// }
155
}
str
std::string str(const T &t)
Definition:
UserAssistedSegmenterGuiWidgetController.cpp:42
armarx::ToQString
QString ToQString(const char *str)
Definition:
ToQString.h:34
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition:
CtrlUtil.h:39
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition:
CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:28
ArmarXGui
libraries
ArmarXGuiBase
ToQString.h
Generated on Sat Oct 12 2024 09:14:03 for armarx_documentation by
1.8.17