8#include "Arp/Plc/Commons/Gds/StaticStringBase.hpp"
10namespace Arp {
namespace Plc {
namespace Commons {
namespace Gds
17template <u
int16 Capacity = 80,
class TChar =
char8>
38 uint16 GetLength(
void)
const;
39 bool IsEmpty(
void)
const;
43 String ToString(
void)
const;
47 void Assign(
const TChar* arg);
50 static uint16 GetLengthFrom(
const TChar* arg);
53 TChar data[Capacity + 1];
59template <u
int16 N,
class TChar>
70template <u
int16 N,
class TChar>
73 this->capacity = arg.capacity;
74 this->length = arg.length;
75 std::char_traits<TChar>::copy(this->data,
reinterpret_cast<TChar*
>(arg.GetData()),
static_cast<size_t>(this->length) + 1);
78template <u
int16 N,
class TChar>
81 other.capacity = this->capacity;
82 other.length = this->length;
83 std::char_traits<TChar>::copy(
reinterpret_cast<TChar*
>(other.GetData()), this->data,
static_cast<size_t>(this->length) + 1);
86template <u
int16 N,
class TChar>
89 this->Assign(
reinterpret_cast<TChar*
>(arg.GetData()));
93template <u
int16 N,
class TChar>
97 this->Assign(
reinterpret_cast<TChar*
>(arg.GetData()));
101template <u
int16 N,
class TChar>
111template <u
int16 N,
class TChar>
114 this->length = this->AssignStaticString(this->data, this->capacity, arg);
118template <u
int16 N,
class TChar>
119inline uint16 StaticString<N, TChar>::GetLength(
void)
const
124template <u
int16 N,
class TChar>
125inline uint16 StaticString<N, TChar>::GetLengthFrom(
const TChar* arg)
127 return static_cast<uint16>(std::char_traits<TChar>::length(arg));
130template <u
int16 N,
class TChar>
131inline String StaticString<N, TChar>::ToString(
void)
const
133 return this->ConvertStaticString(this->data);
136template <u
int16 N,
class TChar>
137inline bool StaticString<N, TChar>::IsEmpty(
void)
const
139 if (this->GetLength() == 0)
149template <u
int16 N,
class TChar>
150void StaticString<N, TChar>::Assign(
const TChar* arg)
152 uint16 currentLength = this->GetLengthFrom(arg);
153 if (currentLength > this->capacity)
155 this->length = this->capacity;
159 this->length = currentLength;
161 std::memset(this->data, 0,
sizeof(this->data));
162 std::char_traits<TChar>::copy(this->data, arg,
static_cast<size_t>(this->length));
165template <u
int16 N,
class TChar>
166inline void StaticString<N, TChar>::Clear(
void)
168 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:19
StaticString(const TChar *str=nullptr)
Constructs an StaticString instance.
Definition: StaticString.hxx:60
StaticString & operator=(const StaticString< Capacity, TChar > &arg)
Assignment operator.
Definition: StaticString.hxx:87
~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:32
Root namespace for the PLCnext API