LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
taintedstring.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include <QString>
12
13
namespace
LC::Util
14
{
15
template
<
typename
L,
typename
R>
16
concept
Concatable
=
requires
(L&& l, R&& r) { std::forward<L> (l) + std::forward<R> (r); };
17
18
class
TaintedString
19
{
20
QString String_;
21
public
:
22
template
<
typename
... Args>
23
requires
std::constructible_from<QString, Args&&...>
24
explicit
TaintedString
(Args&&... args)
25
: String_ { std::forward<Args> (args)... }
26
{
27
}
28
29
TaintedString
(
const
TaintedString
&) =
default
;
30
TaintedString
(
TaintedString
&&) =
default
;
31
TaintedString
&
operator=
(
const
TaintedString
&) =
default
;
32
TaintedString
&
operator=
(
TaintedString
&&) =
default
;
33
34
[[nodiscard]] QString
ToHtmlEscaped
()
const
35
{
36
return
String_.toHtmlEscaped ();
37
}
38
39
[[nodiscard]] QString
UnsafeGetRaw
()
const
40
{
41
return
String_;
42
}
43
44
bool
IsEmpty
()
const
45
{
46
return
String_.isEmpty ();
47
}
48
49
template
<
typename
... Args>
50
requires
(std::is_same_v<TaintedString, std::decay_t<Args>>&& ...)
51
friend
TaintedString
Format
(
const
QString& pattern, Args&&... args)
52
{
53
return
TaintedString
{ pattern.arg (std::forward_like<Args> (args.String_)...) };
54
}
55
56
friend
TaintedString
operator+
(
const
TaintedString
& l,
const
TaintedString
& r)
57
{
58
return
TaintedString
{ l.String_ + r.String_ };
59
}
60
61
template
<
typename
T>
62
requires
(!std::same_as<std::decay_t<T>,
TaintedString
>) &&
Concatable<const QString&, T&&>
63
friend
TaintedString
operator
+ (
const
TaintedString
& l, T&& r)
64
{
65
return
TaintedString
{ l.String_ + std::forward<T> (r) };
66
}
67
68
template
<
typename
T>
69
requires
(!std::same_as<std::decay_t<T>,
TaintedString
>) &&
Concatable<T&&, const QString&>
70
friend
TaintedString
operator
+ (T&& l,
const
TaintedString
& r)
71
{
72
return
TaintedString
{ std::forward<T> (l) + r.String_ };
73
}
74
};
75
}
LC::Util::TaintedString
Definition
taintedstring.h:19
LC::Util::TaintedString::IsEmpty
bool IsEmpty() const
Definition
taintedstring.h:44
LC::Util::TaintedString::UnsafeGetRaw
QString UnsafeGetRaw() const
Definition
taintedstring.h:39
LC::Util::TaintedString::Format
friend TaintedString Format(const QString &pattern, Args &&... args)
Definition
taintedstring.h:51
LC::Util::TaintedString::TaintedString
TaintedString(TaintedString &&)=default
LC::Util::TaintedString::TaintedString
TaintedString(Args &&... args)
Definition
taintedstring.h:24
LC::Util::TaintedString::operator=
TaintedString & operator=(const TaintedString &)=default
LC::Util::TaintedString::operator+
friend TaintedString operator+(const TaintedString &l, const TaintedString &r)
Definition
taintedstring.h:56
LC::Util::TaintedString::TaintedString
TaintedString(const TaintedString &)=default
LC::Util::TaintedString::ToHtmlEscaped
QString ToHtmlEscaped() const
Definition
taintedstring.h:34
LC::Util::Concatable
Definition
taintedstring.h:16
LC::Util
Definition
icoreproxy.h:34
src
util
sll
taintedstring.h
Generated by
1.17.0