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 <sstream>
25
#include <string>
26
#include <vector>
27
28
#include <QString>
29
30
//#include <ArmarXCore/core/util/TemplateMetaProgramming.h>
31
32
namespace
armarx
33
{
34
inline
QString
35
ToQString
(
const
char
*
str
)
36
{
37
return
{
str
};
38
}
39
40
inline
QString
41
ToQString
(
const
std::string&
s
)
42
{
43
return
QString::fromStdString(
s
);
44
}
45
46
inline
QString
47
ToQString
(
float
v
)
48
{
49
return
QString::number(
v
);
50
}
51
52
inline
QString
53
ToQString
(
double
v
)
54
{
55
return
QString::number(
v
);
56
}
57
58
inline
QString
59
ToQString
(
char
v
)
60
{
61
return
QString::number(
v
);
62
}
63
64
inline
QString
65
ToQString
(std::uint8_t
v
)
66
{
67
return
QString::number(
v
);
68
}
69
70
inline
QString
71
ToQString
(std::uint16_t
v
)
72
{
73
return
QString::number(
v
);
74
}
75
76
inline
QString
77
ToQString
(std::uint32_t
v
)
78
{
79
return
QString::number(
v
);
80
}
81
82
inline
QString
83
ToQString
(std::uint64_t
v
)
84
{
85
return
QString::number(
v
);
86
}
87
88
inline
QString
89
ToQString
(std::int8_t
v
)
90
{
91
return
QString::number(
v
);
92
}
93
94
inline
QString
95
ToQString
(std::int16_t
v
)
96
{
97
return
QString::number(
v
);
98
}
99
100
inline
QString
101
ToQString
(std::int32_t
v
)
102
{
103
return
QString::number(
v
);
104
}
105
106
inline
QString
107
ToQString
(std::int64_t
v
)
108
{
109
return
QString::number(
v
);
110
}
111
112
inline
QString
113
ToQString
(
const
std::stringstream&
str
)
114
{
115
return
ToQString
(
str
.str());
116
}
117
118
inline
QString
119
ToQString
(
bool
b)
120
{
121
return
b ?
"true"
:
"false"
;
122
}
123
124
template
<
class
T>
125
inline
QString
126
ToQString
(
const
std::vector<T>&
v
)
127
{
128
if
(
v
.empty())
129
{
130
return
""
;
131
}
132
std::stringstream
str
;
133
str
<<
v
.front();
134
for
(std::size_t i = 1; i <
v
.size(); ++i)
135
{
136
str
<<
" "
<<
v
.at(i);
137
}
138
return
ToQString
(
str
);
139
}
140
141
template
<
class
T>
142
inline
QString
143
ToQString
(
const
std::vector<std::vector<T>>&
v
)
144
{
145
if
(
v
.empty())
146
{
147
return
""
;
148
}
149
std::stringstream
str
;
150
str
<<
ToQString
(
v
.front()).toStdString();
151
for
(std::size_t i = 1; i <
v
.size(); ++i)
152
{
153
str
<<
"\n"
<<
ToQString
(
v
.at(i)).toStdString();
154
}
155
return
ToQString
(
str
);
156
}
157
158
// template<class T>
159
// inline QString ToQString(const T& t)
160
// // inline typename std::enable_if<meta::HasToString<T>::value, QString>::type ToQString(const T& t)
161
// {
162
// return ToQString(to_string(t));
163
// }
164
165
// template<class T>
166
// inline QString ToQString(const T& t)
167
// {
168
// std::stringstream str;
169
// str << t;
170
// return ToQString(str);
171
// }
172
}
// namespace armarx
str
std::string str(const T &t)
Definition:
UserAssistedSegmenterGuiWidgetController.cpp:43
armarx::ToQString
QString ToQString(const char *str)
Definition:
ToQString.h:35
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:27
ArmarXGui
libraries
ArmarXGuiBase
ToQString.h
Generated on Sat Mar 29 2025 09:17:23 for armarx_documentation by
1.8.17