sanitize_typename.cpp
Go to the documentation of this file.
1
#include "
sanitize_typename.h
"
2
3
#include <sstream>
4
5
#include <SimoxUtility/algorithm/string.h>
6
7
#include <RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h>
8
9
10
const
std::string
armarx::armem::gui::instance::rawMemoryIDTypeName
= armarx::armem::arondto::MemoryID::ToAronType()->getFullName();
11
const
std::string
armarx::armem::gui::instance::sanitizedMemoryIDTypeName
=
"MemoryID"
;
12
13
14
namespace
15
{
16
std::string remove_wrap(
const
std::string&
string
,
const
std::string& prefix,
const
std::string& suffix)
17
{
18
if
(
simox::alg::starts_with
(
string
, prefix) &&
simox::alg::ends_with
(
string
, suffix))
19
{
20
return
string
.substr(prefix.size(),
string
.size() - prefix.size() - suffix.size());
21
}
22
else
23
{
24
return
string;
25
}
26
}
27
}
28
29
std::string
armarx::armem::gui::instance::sanitizeTypeName
(
const
std::string& typeName)
30
{
31
if
(typeName ==
rawMemoryIDTypeName
)
32
{
33
return
sanitizedMemoryIDTypeName
;
34
}
35
36
namespace
s
=
simox::alg
;
37
std::string n = typeName;
38
n = s::replace_all(n,
"armarx::aron::type::"
,
""
);
39
n = s::replace_all(n,
"armarx::aron::data::"
,
""
);
40
41
if
(
s::starts_with
(n,
"Object<"
))
42
{
43
n = remove_wrap(n,
"Object<"
,
">"
);
44
const
std::string del =
"::"
;
// remove namespace
45
size_t
find = n.rfind(del);
46
if
(find != n.npos)
47
{
48
find += del.size();
// include del
49
std::stringstream ss;
50
ss << n.substr(find) <<
" ("
<< n.substr(0, find - del.size()) <<
")"
;
51
n = ss.str();
52
}
53
}
54
else
55
{
56
if
(
s::contains
(n,
"<"
))
// another containertype
57
{
58
std::string container = n.substr(0, n.find(
"<"
));
59
std::string subtype = remove_wrap(n, (container +
"<"
),
">"
);
60
subtype =
sanitizeTypeName
(subtype);
61
n = n.substr(0, n.find(
"<"
)+1) + subtype +
">"
;
62
}
63
}
64
65
return
n;
66
67
}
sanitize_typename.h
armarx::armem::gui::instance::sanitizeTypeName
std::string sanitizeTypeName(const std::string &typeName)
Definition:
sanitize_typename.cpp:29
simox::alg
Definition:
Impl.cpp:40
armarx::starts_with
bool starts_with(const std::string &haystack, const std::string &needle)
Definition:
StringHelpers.cpp:43
armarx::armem::contains
bool contains(const MemoryID &general, const MemoryID &specific)
Indicates whether general is "less specific" than, or equal to, specific, i.e.
Definition:
MemoryID.cpp:558
armarx::armem::gui::instance::rawMemoryIDTypeName
const std::string rawMemoryIDTypeName
Definition:
sanitize_typename.cpp:10
armarx::ends_with
bool ends_with(const std::string &haystack, const std::string &needle)
Definition:
StringHelpers.cpp:50
armarx::armem::gui::instance::sanitizedMemoryIDTypeName
const std::string sanitizedMemoryIDTypeName
Definition:
sanitize_typename.cpp:11
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition:
CtrlUtil.h:33
RobotAPI
libraries
armem_gui
instance
sanitize_typename.cpp
Generated on Sat Oct 12 2024 09:14:08 for armarx_documentation by
1.8.17