16#include <initializer_list>
31template <
typename TChar>
34 using VecType = StaticVectorBase<TChar>;
35 using CellType =
typename VecType::CellType;
38 static const auto npos =
static_cast<std::size_t
>(-1);
40 StaticStringBase(TChar* buf, std::size_t cap)
41 : vec_(reinterpret_cast<CellType*>(buf), cap)
46 void assign(std::size_t count, TChar ch)
49 auto countLimit = std::min(count, capacity());
51 std::fill_n(std::back_inserter(vec_), countLimit, ch);
55 void assign(
const StaticStringBase& other)
57 assign(other, 0, other.size());
60 void assign(
const StaticStringBase& other, std::size_t pos, std::size_t count)
63 auto updatedCount = std::min(other.size() - pos, count);
64 auto countLimit = std::min(updatedCount, capacity());
66 std::copy_n(other.cbegin() + pos, countLimit, std::back_inserter(vec_));
70 void assign(
const TChar* str, std::size_t count)
73 auto countLimit = std::min(count, capacity());
74 while ((vec_.size() < countLimit) && (*str != Ends)) {
81 void assign(
const TChar* str)
86 template <
typename TIter>
87 void assign(TIter first, TIter last)
89 vec_.assign(first, last);
93 TChar& at(std::size_t pos)
96 return operator[](pos);
99 const TChar& at(std::size_t pos)
const
102 return operator[](pos);
105 TChar& operator[](std::size_t pos)
110 const TChar& operator[](std::size_t pos)
const
121 const TChar& front()
const
130 return vec_[size() - 1];
133 const TChar& back()
const
136 return vec_[size() - 1];
139 const TChar* data()
const
150 const TChar* cbegin()
const
152 return vec_.cbegin();
157 return begin() + size();
160 const TChar* cend()
const
162 return cbegin() + size();
170 std::size_t size()
const
173 return vec_.size() - 1;
176 std::size_t capacity()
const
178 return vec_.capacity() - 1;
187 void insert(std::size_t idx, std::size_t count, TChar ch)
190 vec_.insert(vec_.begin() + idx, count, ch);
193 void insert(std::size_t idx,
const TChar* str)
196 vec_.insert(vec_.begin() + idx, str, str + strlen(str));
199 void insert(std::size_t idx,
const TChar* str, std::size_t count)
202 auto endStr = str + count;
203 vec_.insert(vec_.begin() + idx, str, endStr);
206 void insert(std::size_t idx,
const StaticStringBase& other)
209 vec_.insert(vec_.begin() + idx, other.cbegin(), other.cend());
212 void insert(std::size_t idx,
const StaticStringBase& str, std::size_t str_idx, std::size_t count)
216 auto begIter = str.cbegin() + str_idx;
217 auto endIter = begIter + std::min((str.size() - str_idx), count);
218 vec_.insert(vec_.begin() + idx, begIter, endIter);
221 TChar* insert(
const TChar* pos, TChar ch)
223 return vec_.insert(pos, ch);
226 TChar* insert(
const TChar* pos, std::size_t count, TChar ch)
228 return vec_.insert(pos, count, ch);
231 template <
typename TIter>
232 TChar* insert(
const TChar* pos, TIter first, TIter last)
234 return vec_.insert(pos, first, last);
237 void erase(std::size_t idx, std::size_t count)
240 auto begIter = begin() + idx;
241 auto endIter = begIter + std::min(count, size() - idx);
242 vec_.erase(begIter, endIter);
246 TChar* erase(
const TChar* pos)
248 return vec_.erase(pos, pos + 1);
251 TChar* erase(
const TChar* first,
const TChar* last)
253 return vec_.erase(first, last);
256 void push_back(TChar ch)
258 static constexpr bool The_string_is_full =
false;
259 static_cast<void>(The_string_is_full);
260 COMMS_ASSERT((size() < capacity()) || The_string_is_full);
261 vec_.insert(end(), ch);
266 static constexpr bool The_string_is_empty =
false;
267 static_cast<void>(The_string_is_empty);
269 vec_.erase(end() - 1, end());
275 const StaticStringBase& other,
277 std::size_t count2)
const
281 count1 = std::min(count1, size() - pos1);
282 count2 = std::min(count2, other.size() - pos2);
283 auto minCount = std::min(count1, count2);
284 for (
auto idx = 0U; idx < minCount; ++idx) {
285 auto thisCh = (*this)[pos1 + idx];
286 auto otherCh = other[pos2 + idx];
287 auto diff =
static_cast<int>(thisCh) -
static_cast<int>(otherCh);
293 return static_cast<int>(count1) -
static_cast<int>(count2);
296 int compare(std::size_t pos, std::size_t count,
const TChar* str)
const
299 count = std::min(count, size() - pos);
300 for (
auto idx = 0U; idx < count; ++idx) {
301 auto ch = (*this)[pos + idx];
302 auto diff =
static_cast<int>(ch) -
static_cast<int>(*str);
314 return 0 -
static_cast<int>(*str);
324 std::size_t count2)
const
327 count1 = std::min(count1, size() - pos1);
328 auto minCount = std::min(count1, count2);
329 for (
auto idx = 0U; idx < minCount; ++idx) {
330 auto thisCh = (*this)[pos1 + idx];
331 auto diff =
static_cast<int>(thisCh) -
static_cast<int>(*str);
339 return static_cast<int>(count1) -
static_cast<int>(count2);
342 template <
typename TIter>
352 auto begIter = begin() + std::distance(cbegin(), first);
353 auto endIter = begin() + std::distance(cbegin(), last);
354 for (
auto iter = begIter; iter != endIter; ++iter) {
355 if (last2 <= first2) {
356 vec_.erase(iter, endIter);
360 COMMS_GNU_WARNING_PUSH
361#if COMMS_IS_GCC_11_OR_ABOVE
362 COMMS_GNU_WARNING_DISABLE(
"-Wstringop-overflow")
364 *iter =
static_cast<TChar
>(*first2);
365 COMMS_GNU_WARNING_POP
369 vec_.insert(last, first2, last2);
380 auto begIter = begin() + std::distance(cbegin(), first);
381 auto endIter = begin() + std::distance(cbegin(), last);
382 for (
auto iter = begIter; iter != endIter; ++iter) {
384 vec_.erase(iter, endIter);
392 auto remCapacity = capacity() - size();
393 auto endStr = str + remCapacity;
394 auto lastStrIter = std::find(str, endStr, TChar(Ends));
395 vec_.insert(last, str, lastStrIter);
407 auto dist =
static_cast<std::size_t
>(std::distance(first, last));
408 auto fillDist = std::min(dist, count2);
409 auto fillIter = begin() + std::distance(cbegin(), first);
410 std::fill_n(fillIter, fillDist, ch);
411 if (count2 <= dist) {
412 vec_.erase(first + fillDist, last);
416 vec_.insert(last, count2 - fillDist, ch);
419 std::size_t copy(TChar* dest, std::size_t count, std::size_t pos)
const
422 count = std::min(count, size() - pos);
423 std::copy_n(cbegin() + pos, count, dest);
427 void resize(std::size_t count)
432 void resize(std::size_t count, TChar ch)
434 if (count <= size()) {
435 vec_.erase(cbegin() + count, cend());
441 vec_.insert(end(), count - size(), ch);
444 void swap(StaticStringBase& other)
446 vec_.swap(other.vec_);
449 std::size_t find(
const TChar* str, std::size_t pos, std::size_t count)
const
452 auto remCount = size() - pos;
453 if (remCount < count) {
457 auto maxPos = size() - count;
458 for (
auto idx = pos; idx <= maxPos; ++idx) {
459 auto thisStrBeg = &vec_[idx];
460 auto thisStrEnd = thisStrBeg + count;
461 if (std::equal(thisStrBeg, thisStrEnd, str)) {
468 std::size_t find(
const TChar* str, std::size_t pos)
const
471 auto maxStrCount = size() - pos;
472 auto maxStrEnd = str + maxStrCount;
473 auto iter = std::find(str, maxStrEnd, TChar(Ends));
474 if (iter == maxStrEnd) {
478 auto strCount =
static_cast<std::size_t
>(std::distance(str, iter));
479 return find(str, pos, strCount);
482 std::size_t find(TChar ch, std::size_t pos)
const
485 auto begIter = cbegin() + pos;
486 auto iter = std::find(begIter, cend(), ch);
487 if (iter == cend()) {
491 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
494 std::size_t rfind(
const TChar* str, std::size_t pos, std::size_t count)
const
496 if ((empty()) || (size() < count)) {
500 pos = std::min(pos, size() - 1);
501 auto startIdx =
static_cast<int>(std::min(pos, size() - count));
502 for (
auto idx = startIdx; 0 <= idx; --idx) {
503 auto thisStrBeg = &vec_[
static_cast<std::size_t
>(idx)];
504 auto thisStrEnd = thisStrBeg + count;
505 if (std::equal(thisStrBeg, thisStrEnd, str)) {
506 return static_cast<std::size_t
>(idx);
512 std::size_t rfind(
const TChar* str, std::size_t pos)
const
514 return rfind(str, pos, strlen(str));
517 std::size_t rfind(TChar ch, std::size_t pos)
const
523 pos = std::min(pos, size() - 1);
524 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
525 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
526 COMMS_ASSERT(
static_cast<std::size_t
>(std::distance(begIter, endIter)) == (pos + 1));
527 auto iter = std::find(begIter, endIter, ch);
528 if (iter == endIter) {
532 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
535 std::size_t find_first_of(
const TChar* str, std::size_t pos, std::size_t count)
const
541 pos = std::min(pos, size() - 1);
542 auto endStr = str + count;
543 for (
auto iter = cbegin() + pos; iter != cend(); ++iter) {
544 auto foundIter = std::find(str, endStr, *iter);
545 if (foundIter != endStr) {
546 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
553 std::size_t find_first_of(
const TChar* str, std::size_t pos)
const
555 return find_first_of(str, pos, strlen(str));
558 std::size_t find_first_not_of(
const TChar* str, std::size_t pos, std::size_t count)
const
564 pos = std::min(pos, size() - 1);
565 auto endStr = str + count;
566 for (
auto iter = cbegin() + pos; iter != cend(); ++iter) {
567 auto found = std::none_of(str, endStr,
568 [iter](TChar ch) ->
bool
574 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
581 std::size_t find_first_not_of(
const TChar* str, std::size_t pos)
const
583 return find_first_not_of(str, pos, strlen(str));
586 std::size_t find_first_not_of(TChar ch, std::size_t pos)
const
592 pos = std::min(pos, size() - 1);
593 auto iter = std::find_if(cbegin() + pos, cend(),
594 [ch](TChar nextCh) ->
bool
599 if (iter == cend()) {
603 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
606 std::size_t find_last_of(
const TChar* str, std::size_t pos, std::size_t count)
const
612 pos = std::min(pos, size() - 1);
613 auto endStr = str + count;
615 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
616 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
617 for (
auto iter = begIter; iter != endIter; ++iter) {
618 auto foundIter = std::find(str, endStr, *iter);
619 if (foundIter != endStr) {
620 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
627 std::size_t find_last_of(
const TChar* str, std::size_t pos)
const
629 return find_last_of(str, pos, strlen(str));
632 std::size_t find_last_not_of(
const TChar* str, std::size_t pos, std::size_t count)
const
638 pos = std::min(pos, size() - 1);
639 auto endStr = str + count;
640 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
641 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
642 for (
auto iter = begIter; iter != endIter; ++iter) {
643 auto found = std::none_of(str, endStr,
644 [iter](TChar ch) ->
bool
650 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
657 std::size_t find_last_not_of(
const TChar* str, std::size_t pos)
const
659 return find_last_not_of(str, pos, strlen(str));
662 std::size_t find_last_not_of(TChar ch, std::size_t pos)
const
668 pos = std::min(pos, size() - 1);
669 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
670 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
671 auto iter = std::find_if(begIter, endIter,
672 [ch](TChar nextCh) ->
bool
677 if (iter == endIter) {
681 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
684 bool operator<(
const TChar* str)
const
686 for (
auto idx = 0U; idx < size(); ++idx) {
707 bool operator>(
const TChar* str)
const
709 for (
auto idx = 0U; idx < size(); ++idx) {
728 bool operator==(
const TChar* str)
const
730 for (
auto idx = 0U; idx < size(); ++idx) {
743 return (*str == Ends);
749 vec_.push_back(TChar(Ends));
752 std::size_t strlen(
const TChar* str)
const
755 while (*strTmp != Ends) {
759 return static_cast<std::size_t
>(std::distance(str, strTmp));
762 static const TChar Ends =
static_cast<TChar
>(
'\0');
763 StaticVectorBase<TChar> vec_;
766template <
typename TChar, std::
size_t TSize>
767struct StaticStringStorageBase
769 using StorageType = std::array<TChar, TSize>;
785template <std::
size_t TSize,
typename TChar =
char>
787 public details::StaticStringStorageBase<TChar, TSize + 1>,
788 public details::StaticStringBase<TChar>
790 using StorageBase = details::StaticStringStorageBase<TChar, TSize + 1>;
791 using Base = details::StaticStringBase<TChar>;
818 static const decltype(Base::npos)
npos = Base::npos;
823 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
830 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
838 template <std::
size_t TOtherSize>
843 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
845 assign(other, pos, count);
851 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
859 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
866 template <
typename TIter>
868 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
876 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
883 template <std::
size_t TOtherSize>
885 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
893 : Base(StorageBase::data_.
data(), StorageBase::data_.
size())
895 assign(init.begin(), init.end());
907 template <std::
size_t TOtherSize>
938 Base::assign(count, ch);
944 template <
typename TOtherSize>
947 if (&other !=
this) {
955 template <std::
size_t TOtherSize>
964 template <std::
size_t TOtherSize>
970 Base::assign(other, pos, count);
978 Base::assign(str, count);
992 template <
typename TIter>
995 Base::assign(first, last);
1003 return assign(init.begin(), init.end());
1012 return Base::at(pos);
1021 return Base::at(pos);
1028 return Base::operator[](pos);
1035 return Base::operator[](pos);
1043 return Base::front();
1051 return Base::front();
1059 return Base::back();
1067 return Base::back();
1074 return Base::data();
1088 return Base::begin();
1102 return Base::cbegin();
1123 return Base::cend();
1172 return Base::empty();
1179 return Base::size();
1209 return Base::capacity();
1230 Base::insert(idx, count, ch);
1238 Base::insert(idx, str);
1246 Base::insert(idx, str, count);
1252 template <std::
size_t TAnySize>
1255 Base::insert(idx, str);
1261 template <std::
size_t TAnySize>
1268 Base::insert(idx, str, str_idx, count);
1276 return Base::insert(pos, ch);
1283 return Base::insert(pos, count, ch);
1288 template <
typename TIter>
1291 return Base::insert(pos, first, last);
1298 return insert(pos, init.begin(), init.end());
1305 Base::erase(idx, count);
1313 return Base::erase(pos);
1320 return Base::erase(first, last);
1327 Base::push_back(ch);
1347 template <std::
size_t TAnySize>
1355 template <std::
size_t TAnySize>
1380 template <
typename TIter>
1391 insert(
end(), init.begin(), init.end());
1397 template <std::
size_t TAnySize>
1426 template <std::
size_t TAnySize>
1434 template <std::
size_t TAnySize>
1440 return compare(pos, count, other, 0, other.
size());
1445 template <std::
size_t TAnySize>
1453 return Base::compare(pos1, count1, other, pos2, count2);
1467 return Base::compare(pos, count, str);
1474 return Base::compare(pos, count1, str, count2);
1479 template <std::
size_t TAnySize>
1486 auto begIter =
begin() + pos;
1487 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1488 auto endIter = begIter + std::min(count, remCount);
1494 template <std::
size_t TAnySize>
1505 template <std::
size_t TAnySize>
1514 auto begIter =
begin() + pos;
1515 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1516 auto endIter = begIter + std::min(count, remCount);
1519 auto begIter2 = other.
begin() + pos2;
1520 auto remCount2 =
static_cast<std::size_t
>(std::distance(begIter2, other.
end()));
1521 auto endIter2 = begIter2 + std::min(count2, remCount2);
1523 return replace(begIter, endIter, begIter2, endIter2);
1528 template <
typename TIter>
1535 Base::replace(first, last, first2, last2);
1548 auto begIter =
cbegin() + pos;
1549 auto endIter = begIter + std::min(count,
size() - pos);
1550 return replace(begIter, endIter, str, str + count2);
1561 return replace(first, last, str, str + count2);
1572 auto begIter =
cbegin() + pos;
1573 auto endIter = begIter + std::min(count,
size() - pos);
1574 return replace(begIter, endIter, str);
1584 Base::replace(first, last, str);
1597 auto begIter =
cbegin() + pos;
1598 auto endIter = begIter + std::min(count,
size() - pos);
1599 return replace(begIter, endIter, count2, ch);
1610 Base::replace(first, last, count2, ch);
1619 std::initializer_list<value_type> init)
1621 return replace(first, last, init.begin(), init.end());
1629 auto begIter =
cbegin() + pos;
1630 auto endIter = begIter + std::min(count,
size() - pos);
1638 return Base::copy(dest, count, pos);
1645 Base::resize(count);
1652 Base::resize(count, ch);
1657 template <std::
size_t TAnySize>
1665 template <std::
size_t TAnySize>
1676 return Base::find(str, pos, count);
1683 return Base::find(str, pos);
1690 return Base::find(ch, pos);
1695 template <std::
size_t TAnySize>
1705 return Base::rfind(str, pos, count);
1712 return Base::rfind(str, pos);
1719 return Base::rfind(ch, pos);
1724 template <std::
size_t TAnySize>
1735 return Base::find_first_of(str, pos, count);
1742 return Base::find_first_of(str, pos);
1749 return find(ch, pos);
1754 template <std::
size_t TAnySize>
1765 return Base::find_first_not_of(str, pos, count);
1772 return Base::find_first_not_of(str, pos);
1779 return Base::find_first_not_of(ch, pos);
1784 template <std::
size_t TAnySize>
1794 return Base::find_last_of(str, pos, count);
1801 return Base::find_last_of(str, pos);
1808 return rfind(ch, pos);
1813 template <std::
size_t TAnySize>
1823 return Base::find_last_not_of(str, pos, count);
1830 return Base::find_last_not_of(str, pos);
1837 return Base::find_last_not_of(ch, pos);
1843 return Base::operator<(str);
1849 return Base::operator>(str);
1855 return Base::operator==(str);
1862template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1865 return std::lexicographical_compare(str1.
begin(), str1.
end(), str2.
begin(), str2.
end());
1871template <std::
size_t TSize1,
typename TChar>
1874 return (str2 > str1);
1880template <std::
size_t TSize1,
typename TChar>
1883 return str1.operator<(str2);
1889template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1892 return !(str2 < str1);
1898template <std::
size_t TSize1,
typename TChar>
1901 return !(str2 < str1);
1907template <std::
size_t TSize1,
typename TChar>
1910 return !(str1 > str2);
1916template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1919 return (str2 < str1);
1925template <std::
size_t TSize1,
typename TChar>
1928 return (str2 < str1);
1934template <std::
size_t TSize1,
typename TChar>
1937 return str1.operator<(str2);
1943template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1946 return !(str1 < str2);
1952template <std::
size_t TSize1,
typename TChar>
1955 return !(str1 < str2);
1961template <std::
size_t TSize1,
typename TChar>
1964 return !(str1 < str2);
1970template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1981template <std::
size_t TSize1,
typename TChar>
1984 return str2.operator==(str1);
1990template <std::
size_t TSize1,
typename TChar>
1993 return str1.operator==(str2);
1999template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
2002 return !(str1 == str2);
2008template <std::
size_t TSize1,
typename TChar>
2011 return !(str2 == str1);
2017template <std::
size_t TSize1,
typename TChar>
2020 return !(str1 == str2);
2027template <
typename T>
2028struct IsStaticString
2030 static const bool Value =
false;
2033template <std::
size_t TSize>
2036 static const bool Value =
true;
2044template <
typename T>
2047 return details::IsStaticString<T>::Value;
2060template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
This file contains classes required for generic custom assertion functionality.
#define COMMS_ASSERT(expr)
Generic assert macro.
Definition Assert.h:170
Contains various compiler related definitions.
Contains comms::util::StaticVector class.
Replacement to std::string when no dynamic memory allocation is allowed.
Definition StaticString.h:789
size_type rfind(value_type ch, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1717
int compare(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1435
const_iterator end() const
Returns an iterator to the end.
Definition StaticString.h:1114
const_iterator begin() const
Returns an iterator to the beginning.
Definition StaticString.h:1093
bool operator!=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:2000
const_reference at(size_type pos) const
Access specified character with bounds checking.
Definition StaticString.h:1019
size_type find_last_of(const_pointer str, size_type pos, size_type count) const
Find last occurrence of characters.
Definition StaticString.h:1792
const_pointer const_iterator
Type of the const iterator.
Definition StaticString.h:811
const_reference back() const
Accesses the last character.
Definition StaticString.h:1065
const_iterator cend() const
Returns an iterator to the end.
Definition StaticString.h:1121
void swap(comms::util::StaticString< TSize1, TChar > &str1, comms::util::StaticString< TSize2, TChar > &str2)
Specializes the std::swap algorithm.
Definition StaticString.h:2061
StaticString & replace(size_type pos, size_type count, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1566
reference at(size_type pos)
Access specified character with bounds checking.
Definition StaticString.h:1010
size_type size() const
returns the number of characters.
Definition StaticString.h:1177
StaticString & operator+=(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1419
size_type copy(pointer dest, size_type count, size_type pos=0) const
Copies characters.
Definition StaticString.h:1636
size_type find_first_not_of(const_pointer str, size_type pos, size_type count) const
Find first absence of characters.
Definition StaticString.h:1763
StaticString & assign(TIter first, TIter last)
Assign characters to a string.
Definition StaticString.h:993
bool operator<=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1899
bool operator>(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1917
StaticString & append(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1389
size_type rfind(const_pointer str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1710
StaticString(TIter first, TIter last)
Constructor variant.
Definition StaticString.h:867
void clear()
Clears the contents.
Definition StaticString.h:1221
const_reverse_iterator rend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1156
const_pointer data() const
Returns a pointer to the first character of a string.
Definition StaticString.h:1072
std::size_t size_type
Type used for size information.
Definition StaticString.h:797
static constexpr bool isStaticString()
Compile time check whether the provided type is a variant of comms::util::StaticString.
Definition StaticString.h:2045
const_iterator cbegin() const
Returns an iterator to the beginning.
Definition StaticString.h:1100
size_type rfind(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1696
bool operator<=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1890
const_reference operator[](size_type pos) const
Access specified character without bounds checking.
Definition StaticString.h:1033
StaticString & operator+=(value_type ch)
Appends characters to the end.
Definition StaticString.h:1405
StaticString & replace(const_iterator first, const_iterator last, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1604
StaticString & replace(const_iterator first, const_iterator last, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1555
size_type find_last_not_of(value_type ch, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1835
size_type find_last_of(const_pointer str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1799
StaticString & assign(const StaticString< TOtherSize, TChar > &other)
Assign characters to a string.
Definition StaticString.h:956
const value_type * const_pointer
Const pointer to single character.
Definition StaticString.h:807
StaticString & append(const TChar *str, size_type count)
Appends characters to the end.
Definition StaticString.h:1366
static const decltype(Base::npos) npos
Same as std::string::npos.
Definition StaticString.h:818
bool operator<(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1841
size_type find_last_not_of(const_pointer str, size_type pos, size_type count) const
Find last absence of characters.
Definition StaticString.h:1821
bool operator>=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1953
StaticString(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Constructor variant.
Definition StaticString.h:839
StaticString & replace(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other, size_type pos2, size_type count2=npos)
Replaces specified portion of a string.
Definition StaticString.h:1506
void swap(StaticString< TAnySize, TChar > &other)
Swaps the contents of two strings.
Definition StaticString.h:1658
size_type find(const_pointer str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1681
StaticString & replace(const_iterator first, const_iterator last, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1579
StaticString & replace(size_type pos, size_type count, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1590
size_type find_first_of(const_pointer str, size_type pos, size_type count) const
Find first occurrence of characters.
Definition StaticString.h:1733
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str)
Inserts characters.
Definition StaticString.h:1253
iterator insert(const_iterator pos, std::initializer_list< value_type > init)
Inserts characters.
Definition StaticString.h:1296
size_type length() const
returns the number of characters.
Definition StaticString.h:1184
bool operator>(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1847
bool operator==(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1853
size_type find_first_of(const_pointer str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1740
const_pointer c_str() const
Returns a non-modifiable standard C character array version of the string.
Definition StaticString.h:1079
StaticString substr(size_type pos=0, size_type count=npos) const
Returns a substring.
Definition StaticString.h:1626
bool operator<(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1872
StaticString & assign(std::initializer_list< value_type > init)
Assign characters to a string.
Definition StaticString.h:1001
void push_back(value_type ch)
Appends a character to the end.
Definition StaticString.h:1325
StaticString & assign(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Assign characters to a string.
Definition StaticString.h:965
const_reference front() const
Accesses the first character.
Definition StaticString.h:1049
size_type find_first_of(value_type ch, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1747
StaticString & insert(size_type idx, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1228
StaticString(const_pointer str, size_type count)
Constructor variant.
Definition StaticString.h:850
const_reverse_iterator rbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1135
bool operator<(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1863
StaticString & append(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1348
StaticString & append(const TChar *str)
Appends characters to the end.
Definition StaticString.h:1373
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1142
size_type find_last_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1785
int compare(size_type pos1, size_type count1, const StaticString< TAnySize, TChar > &other, size_type pos2, size_type count2=npos) const
Compares two strings.
Definition StaticString.h:1446
StaticString & insert(size_type idx, const_pointer str, size_type count)
Inserts characters.
Definition StaticString.h:1244
size_type find_last_of(value_type ch, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1806
size_type find(const_pointer str, size_type pos, size_type count) const
Find characters in the string.
Definition StaticString.h:1674
bool operator>(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1926
StaticString & erase(std::size_t idx, std::size_t count=npos)
Removes characters.
Definition StaticString.h:1303
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str, size_type str_idx, size_type count=npos)
Inserts characters.
Definition StaticString.h:1262
StaticString & operator=(const_pointer str)
Assignment operator.
Definition StaticString.h:915
StaticString & assign(const_pointer str)
Assign characters to a string.
Definition StaticString.h:984
size_type find(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1666
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition StaticString.h:1149
int compare(const_pointer str) const
Compares two strings.
Definition StaticString.h:1458
size_type find_first_not_of(value_type ch, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1777
bool operator>(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1935
StaticString & assign(size_type count, value_type ch)
Assign characters to a string.
Definition StaticString.h:936
size_type find_last_not_of(const_pointer str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1828
StaticString & replace(const_iterator first, const_iterator last, std::initializer_list< value_type > init)
Replaces specified portion of a string.
Definition StaticString.h:1616
StaticString(std::initializer_list< value_type > init)
Constructor variant.
Definition StaticString.h:892
bool empty() const
Checks whether the string is empty.
Definition StaticString.h:1170
StaticString & assign(const StaticString &other)
Assign characters to a string.
Definition StaticString.h:945
bool operator!=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:2009
value_type & reference
Reference to single character.
Definition StaticString.h:801
StaticString()
Default constructor.
Definition StaticString.h:822
StaticString & append(const StaticString< TAnySize, TChar > &other, size_type pos, size_type count=npos)
Appends characters to the end.
Definition StaticString.h:1356
StaticString & replace(const_iterator first, const_iterator last, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1495
StaticString & operator=(std::initializer_list< value_type > init)
Assignment operator.
Definition StaticString.h:929
StaticString & insert(size_type idx, const_pointer str)
Inserts characters.
Definition StaticString.h:1236
StaticString & operator=(const StaticString< TOtherSize, TChar > &other)
Copy assignment from string of different capacity.
Definition StaticString.h:908
iterator insert(const_iterator pos, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1281
StaticString & operator=(value_type ch)
Assignment operator.
Definition StaticString.h:922
reference operator[](size_type pos)
Access specified character without bounds checking.
Definition StaticString.h:1026
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition StaticString.h:1128
size_type find(value_type ch, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1688
void reserve(size_type)
Reserves storage.
Definition StaticString.h:1200
StaticString & replace(size_type pos, size_type count, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1541
const_reverse_iterator crend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1163
bool operator>=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1944
StaticString & assign(const_pointer str, size_type count)
Assign characters to a string.
Definition StaticString.h:976
std::reverse_iterator< iterator > reverse_iterator
Type of the reverse iterator.
Definition StaticString.h:813
TChar value_type
Type of single character.
Definition StaticString.h:795
bool operator==(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1971
StaticString(size_type count, value_type ch)
Constructor variant.
Definition StaticString.h:829
int compare(size_type pos, size_type count1, const_pointer str, size_type count2) const
Compares two strings.
Definition StaticString.h:1472
iterator insert(const_iterator pos, value_type ch)
Inserts characters.
Definition StaticString.h:1274
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition StaticString.h:1215
reference front()
Accesses the first character.
Definition StaticString.h:1041
StaticString(const StaticString &other)
Copy constructor.
Definition StaticString.h:875
bool operator<(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1881
bool operator==(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Equality compare between the strings.
Definition StaticString.h:1982
std::reverse_iterator< const_iterator > const_reverse_iterator
Type of the const reverse iterator.
Definition StaticString.h:815
StaticString & append(TIter first, TIter last)
Appends characters to the end.
Definition StaticString.h:1381
size_type rfind(const_pointer str, size_type pos, size_type count) const
Find the last occurrence of the substring.
Definition StaticString.h:1703
StaticString & append(size_type count, value_type ch)
Appends characters to the end.
Definition StaticString.h:1340
StaticString & operator+=(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1398
typename StorageBase::StorageType::difference_type difference_type
Type used in pointer arithmetics.
Definition StaticString.h:799
StaticString & replace(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1480
size_type find_first_not_of(const_pointer str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1770
bool operator==(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Equality compare between the strings.
Definition StaticString.h:1991
bool operator<=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1908
void resize(size_type count, value_type ch)
Changes the number of characters stored.
Definition StaticString.h:1650
StaticString & replace(const_iterator first, const_iterator last, TIter first2, TIter last2)
Replaces specified portion of a string.
Definition StaticString.h:1529
bool operator>=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1962
StaticString & operator+=(const_pointer str)
Appends characters to the end.
Definition StaticString.h:1412
iterator end()
Returns an iterator to the end.
Definition StaticString.h:1107
void pop_back()
Removes the last character.
Definition StaticString.h:1333
pointer iterator
Type of the iterator.
Definition StaticString.h:809
iterator insert(const_iterator pos, TIter first, TIter last)
Inserts characters.
Definition StaticString.h:1289
const value_type & const_reference
Const reference to single character.
Definition StaticString.h:803
iterator erase(const_iterator first, const_iterator last)
Removes characters.
Definition StaticString.h:1318
StaticString(const_pointer str)
Constructor variant.
Definition StaticString.h:858
bool operator!=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Inequality compare between the strings.
Definition StaticString.h:2018
size_type find_last_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1814
iterator begin()
Returns an iterator to the beginning.
Definition StaticString.h:1086
StaticString(const StaticString< TOtherSize, TChar > &other)
Copy constructor variant.
Definition StaticString.h:884
int compare(const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1427
int compare(size_type pos, size_type count, const_pointer str) const
Compares two strings.
Definition StaticString.h:1465
size_type max_size() const
Returns the maximum number of characters.
Definition StaticString.h:1192
size_type find_first_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1755
value_type * pointer
Pointer to single character.
Definition StaticString.h:805
iterator erase(const_iterator pos)
Removes characters.
Definition StaticString.h:1311
reference back()
Accesses the last character.
Definition StaticString.h:1057
void resize(size_type count)
Changes the number of characters stored.
Definition StaticString.h:1643
StaticString & operator=(const StaticString &other)
Copy assignment.
Definition StaticString.h:900
size_type find_first_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1725
size_type capacity() const
returns the number of characters that can be held in currently allocated storage.
Definition StaticString.h:1207
void assign(T &obj, TIter from, TIter to)
Assigns a new value to provided object.
Definition assign.h:39
Main namespace for all classes / functions of COMMS library.