PLCnext API Documentation 26.6.0.38
RscSecureString.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/RscString.hxx"
9
10namespace Arp::Base::Rsc::Commons
11{
12
14template<int N>
15class RscSecureString : public RscString<N>
16{
17public: // usings
18 using RscString<N>::RscString;
19
20public: // construction
21 RscSecureString(void);
22 ~RscSecureString(void);
23
24public: // global friend operators (shall be defined implicit inline due to hidden friend pattern)
25
30 friend std::ostream& operator<<(std::ostream& os, const RscSecureString& str)
31 {
32 os << str.CStr();
33 return os;
34 }
35
40 friend std::istream& operator>>(std::istream& is, RscSecureString& str)
41 {
42 std::string s;
43 is >> s;
44 str = s;
45 return is;
46 }
47};
48
50// inline methods of class RscSecureString<N>
51
53template<int N>
55 : RscString<N>(RscType::SecureString)
56{
57}
58
60template<int N>
62{
63 RscStringBase::Clear(); // zero's the string.
64}
65
66} // end of namespace Arp::Base::Rsc::Commons
67
69// template specialization of RscSecureString<N> formatter
70template<int N>
71struct fmt::formatter<Arp::Base::Rsc::Commons::RscSecureString<N>> : public fmt::ostream_formatter
72{
73};
Specialized implementation of RscString for secure context.
Definition: RscSecureString.hxx:16
friend std::istream & operator>>(std::istream &is, RscSecureString &str)
The istream operator is used for string parsing.
Definition: RscSecureString.hxx:40
RscSecureString(void)
Constructs an empty RscSecureString.
Definition: RscSecureString.hxx:54
friend std::ostream & operator<<(std::ostream &os, const RscSecureString &str)
The ostream operator is used for logging and string formatting.
Definition: RscSecureString.hxx:30
~RscSecureString(void)
Clears the string buffer.
Definition: RscSecureString.hxx:61
void Clear(void)
Clears this instance resulting in an empty string.
Definition: RscStringBase.cpp:188
const char * CStr(void) const
Returns a const char pointer to the internal string buffer.
Definition: RscStringBase.cpp:63
Contains a static string with string lentgh up to N characters. The string shall be null terminated.
Definition: RscString.hxx:24
RscString(void)
Constructs an empty RscString.
Definition: RscString.hxx:86
Root namespace for the PLCnext API