8 #include "Arp/Plc/Commons/Gds/StaticStringBase.hpp"
9 namespace Arp {
namespace Plc {
namespace Commons {
namespace Gds
16 template <u
int16 Capacity = 80,
class TChar =
char8>
37 uint16 GetLength(
void)
const;
38 bool IsEmpty(
void)
const;
42 String ToString(
void)
const;
46 void Assign(
const TChar* arg);
49 static uint16 GetLengthFrom(
const TChar* arg);
52 TChar data[Capacity + 1];
58 template <u
int16 N,
class TChar>
69 template <u
int16 N,
class TChar>
72 this->capacity = arg.capacity;
73 this->length = arg.length;
74 std::char_traits<TChar>::copy(this->data,
reinterpret_cast<TChar*
>(arg.GetData()),
static_cast<size_t>(this->length) + 1);
77 template <u
int16 N,
class TChar>
80 other.capacity = this->capacity;
81 other.length = this->length;
82 std::char_traits<TChar>::copy(
reinterpret_cast<TChar*
>(other.GetData()), this->data,
static_cast<size_t>(this->length) + 1);
85 template <u
int16 N,
class TChar>
88 this->Assign(
reinterpret_cast<TChar*
>(arg.GetData()));
92 template <u
int16 N,
class TChar>
96 this->Assign(
reinterpret_cast<TChar*
>(arg.GetData()));
100 template <u
int16 N,
class TChar>
110 template <u
int16 N,
class TChar>
113 this->length = this->AssignStaticString(this->data, this->capacity, arg);
117 template <u
int16 N,
class TChar>
118 inline uint16 StaticString<N, TChar>::GetLength(
void)
const
123 template <u
int16 N,
class TChar>
124 inline uint16 StaticString<N, TChar>::GetLengthFrom(
const TChar* arg)
126 return static_cast<uint16>(std::char_traits<TChar>::length(arg));
129 template <u
int16 N,
class TChar>
130 inline String StaticString<N, TChar>::ToString(
void)
const
132 return this->ConvertStaticString(this->data);
135 template <u
int16 N,
class TChar>
136 inline bool StaticString<N, TChar>::IsEmpty(
void)
const
138 if (this->GetLength() == 0)
148 template <u
int16 N,
class TChar>
149 void StaticString<N, TChar>::Assign(
const TChar* arg)
151 uint16 currentLength = this->GetLengthFrom(arg);
152 if (currentLength > this->capacity)
154 this->length = this->capacity;
158 this->length = currentLength;
160 std::memset(this->data, 0,
sizeof(this->data));
161 std::char_traits<TChar>::copy(this->data, arg,
static_cast<size_t>(this->length));
164 template <u
int16 N,
class TChar>
165 inline void StaticString<N, TChar>::Clear(
void)
167 std::memset(this->data, 0,
sizeof(this->data));
This class is the base class used for 'IecString' and 'StaticString'.
Definition: StaticStringBase.hpp:17
This class represents the counterpart to the data type 'IecString', 'IecWString'. It's the C++ data t...
Definition: StaticString.hxx:18
StaticString(const TChar *str=nullptr)
Constructs an StaticString instance.
Definition: StaticString.hxx:59
StaticString & operator=(const StaticString< Capacity, TChar > &arg)
Assignment operator.
Definition: StaticString.hxx:86
~StaticString(void)=default
Destructs this instance and frees all resources.
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
std::uint16_t uint16
The Arp unsigned integer type of 2 byte size.
Definition: PrimitiveTypes.hpp:31
Root namespace for the PLCnext API