22#include <initializer_list>
34template <
typename TChar>
37 using VecType = StaticVectorBase<TChar>;
38 using CellType =
typename VecType::CellType;
41 static const auto npos =
static_cast<std::size_t
>(-1);
43 StaticStringBase(TChar* buf, std::size_t cap)
44 : m_vec(reinterpret_cast<CellType*>(buf), cap)
49 void assign(std::size_t count, TChar ch)
52 auto countLimit = std::min(count, capacity());
54 std::fill_n(std::back_inserter(m_vec), countLimit, ch);
58 void assign(
const StaticStringBase& other)
60 assign(other, 0, other.size());
63 void assign(
const StaticStringBase& other, std::size_t pos, std::size_t count)
66 auto updatedCount = std::min(other.size() - pos, count);
67 auto countLimit = std::min(updatedCount, capacity());
69 std::copy_n(other.cbegin() + pos, countLimit, std::back_inserter(m_vec));
73 void assign(
const TChar* str, std::size_t count)
76 auto countLimit = std::min(count, capacity());
77 while ((m_vec.size() < countLimit) && (*str != Ends)) {
78 m_vec.push_back(*str);
84 void assign(
const TChar* str)
89 template <
typename TIter>
90 void assign(TIter first, TIter last)
92 m_vec.assign(first, last);
96 TChar& at(std::size_t pos)
99 return operator[](pos);
102 const TChar& at(std::size_t pos)
const
105 return operator[](pos);
108 TChar& operator[](std::size_t pos)
113 const TChar& operator[](std::size_t pos)
const
121 return m_vec.front();
124 const TChar& front()
const
127 return m_vec.front();
133 return m_vec[size() - 1];
136 const TChar& back()
const
139 return m_vec[size() - 1];
142 const TChar* data()
const
150 return m_vec.begin();
153 const TChar* cbegin()
const
155 return m_vec.cbegin();
160 return begin() + size();
163 const TChar* cend()
const
165 return cbegin() + size();
173 std::size_t size()
const
176 return m_vec.size() - 1;
179 std::size_t capacity()
const
181 return m_vec.capacity() - 1;
190 void insert(std::size_t idx, std::size_t count, TChar ch)
193 m_vec.insert(m_vec.begin() + idx, count, ch);
196 void insert(std::size_t idx,
const TChar* str)
199 m_vec.insert(m_vec.begin() + idx, str, str + strlen(str));
202 void insert(std::size_t idx,
const TChar* str, std::size_t count)
205 auto endStr = str + count;
206 m_vec.insert(m_vec.begin() + idx, str, endStr);
209 void insert(std::size_t idx,
const StaticStringBase& other)
212 m_vec.insert(m_vec.begin() + idx, other.cbegin(), other.cend());
215 void insert(std::size_t idx,
const StaticStringBase& str, std::size_t str_idx, std::size_t count)
219 auto begIter = str.cbegin() + str_idx;
220 auto endIter = begIter + std::min((str.size() - str_idx), count);
221 m_vec.insert(m_vec.begin() + idx, begIter, endIter);
224 TChar* insert(
const TChar* pos, TChar ch)
226 return m_vec.insert(pos, ch);
229 TChar* insert(
const TChar* pos, std::size_t count, TChar ch)
231 return m_vec.insert(pos, count, ch);
234 template <
typename TIter>
235 TChar* insert(
const TChar* pos, TIter first, TIter last)
237 return m_vec.insert(pos, first, last);
240 void erase(std::size_t idx, std::size_t count)
243 auto begIter = begin() + idx;
244 auto endIter = begIter + std::min(count, size() - idx);
245 m_vec.erase(begIter, endIter);
249 TChar* erase(
const TChar* pos)
251 return m_vec.erase(pos, pos + 1);
254 TChar* erase(
const TChar* first,
const TChar* last)
256 return m_vec.erase(first, last);
259 void push_back(TChar ch)
261 static constexpr bool The_string_is_full =
false;
262 static_cast<void>(The_string_is_full);
263 COMMS_ASSERT((size() < capacity()) || The_string_is_full);
264 m_vec.insert(end(), ch);
269 static constexpr bool The_string_is_empty =
false;
270 static_cast<void>(The_string_is_empty);
272 m_vec.erase(end() - 1, end());
278 const StaticStringBase& other,
280 std::size_t count2)
const
284 count1 = std::min(count1, size() - pos1);
285 count2 = std::min(count2, other.size() - pos2);
286 auto minCount = std::min(count1, count2);
287 for (
auto idx = 0U; idx < minCount; ++idx) {
288 auto thisCh = (*this)[pos1 + idx];
289 auto otherCh = other[pos2 + idx];
290 auto diff =
static_cast<int>(thisCh) -
static_cast<int>(otherCh);
296 return static_cast<int>(count1) -
static_cast<int>(count2);
299 int compare(std::size_t pos, std::size_t count,
const TChar* str)
const
302 count = std::min(count, size() - pos);
303 for (
auto idx = 0U; idx < count; ++idx) {
304 auto ch = (*this)[pos + idx];
305 auto diff =
static_cast<int>(ch) -
static_cast<int>(*str);
317 return 0 -
static_cast<int>(*str);
327 std::size_t count2)
const
330 count1 = std::min(count1, size() - pos1);
331 auto minCount = std::min(count1, count2);
332 for (
auto idx = 0U; idx < minCount; ++idx) {
333 auto thisCh = (*this)[pos1 + idx];
334 auto diff =
static_cast<int>(thisCh) -
static_cast<int>(*str);
342 return static_cast<int>(count1) -
static_cast<int>(count2);
345 template <
typename TIter>
355 auto begIter = begin() + std::distance(cbegin(), first);
356 auto endIter = begin() + std::distance(cbegin(), last);
357 for (
auto iter = begIter; iter != endIter; ++iter) {
358 if (last2 <= first2) {
359 m_vec.erase(iter, endIter);
363 COMMS_GNU_WARNING_PUSH
364#if COMMS_IS_GCC_11_OR_ABOVE
365 COMMS_GNU_WARNING_DISABLE(
"-Wstringop-overflow")
367 *iter =
static_cast<TChar
>(*first2);
368 COMMS_GNU_WARNING_POP
372 m_vec.insert(last, first2, last2);
383 auto begIter = begin() + std::distance(cbegin(), first);
384 auto endIter = begin() + std::distance(cbegin(), last);
385 for (
auto iter = begIter; iter != endIter; ++iter) {
387 m_vec.erase(iter, endIter);
395 auto remCapacity = capacity() - size();
396 auto endStr = str + remCapacity;
397 auto lastStrIter = std::find(str, endStr, TChar(Ends));
398 m_vec.insert(last, str, lastStrIter);
410 auto dist =
static_cast<std::size_t
>(std::distance(first, last));
411 auto fillDist = std::min(dist, count2);
412 auto fillIter = begin() + std::distance(cbegin(), first);
413 std::fill_n(fillIter, fillDist, ch);
414 if (count2 <= dist) {
415 m_vec.erase(first + fillDist, last);
419 m_vec.insert(last, count2 - fillDist, ch);
422 std::size_t copy(TChar* dest, std::size_t count, std::size_t pos)
const
425 count = std::min(count, size() - pos);
426 std::copy_n(cbegin() + pos, count, dest);
430 void resize(std::size_t count)
435 void resize(std::size_t count, TChar ch)
437 if (count <= size()) {
438 m_vec.erase(cbegin() + count, cend());
444 m_vec.insert(end(), count - size(), ch);
447 void swap(StaticStringBase& other)
449 m_vec.swap(other.m_vec);
452 std::size_t find(
const TChar* str, std::size_t pos, std::size_t count)
const
455 auto remCount = size() - pos;
456 if (remCount < count) {
460 auto maxPos = size() - count;
461 for (
auto idx = pos; idx <= maxPos; ++idx) {
462 auto thisStrBeg = &m_vec[idx];
463 auto thisStrEnd = thisStrBeg + count;
464 if (std::equal(thisStrBeg, thisStrEnd, str)) {
471 std::size_t find(
const TChar* str, std::size_t pos)
const
474 auto maxStrCount = size() - pos;
475 auto maxStrEnd = str + maxStrCount;
476 auto iter = std::find(str, maxStrEnd, TChar(Ends));
477 if (iter == maxStrEnd) {
481 auto strCount =
static_cast<std::size_t
>(std::distance(str, iter));
482 return find(str, pos, strCount);
485 std::size_t find(TChar ch, std::size_t pos)
const
488 auto begIter = cbegin() + pos;
489 auto iter = std::find(begIter, cend(), ch);
490 if (iter == cend()) {
494 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
497 std::size_t rfind(
const TChar* str, std::size_t pos, std::size_t count)
const
499 if ((empty()) || (size() < count)) {
503 pos = std::min(pos, size() - 1);
504 auto startIdx =
static_cast<int>(std::min(pos, size() - count));
505 for (
auto idx = startIdx; 0 <= idx; --idx) {
506 auto thisStrBeg = &m_vec[
static_cast<std::size_t
>(idx)];
507 auto thisStrEnd = thisStrBeg + count;
508 if (std::equal(thisStrBeg, thisStrEnd, str)) {
509 return static_cast<std::size_t
>(idx);
515 std::size_t rfind(
const TChar* str, std::size_t pos)
const
517 return rfind(str, pos, strlen(str));
520 std::size_t rfind(TChar ch, std::size_t pos)
const
526 pos = std::min(pos, size() - 1);
527 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
528 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
529 COMMS_ASSERT(
static_cast<std::size_t
>(std::distance(begIter, endIter)) == (pos + 1));
530 auto iter = std::find(begIter, endIter, ch);
531 if (iter == endIter) {
535 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
538 std::size_t find_first_of(
const TChar* str, std::size_t pos, std::size_t count)
const
544 pos = std::min(pos, size() - 1);
545 auto endStr = str + count;
546 for (
auto iter = cbegin() + pos; iter != cend(); ++iter) {
547 auto foundIter = std::find(str, endStr, *iter);
548 if (foundIter != endStr) {
549 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
556 std::size_t find_first_of(
const TChar* str, std::size_t pos)
const
558 return find_first_of(str, pos, strlen(str));
561 std::size_t find_first_not_of(
const TChar* str, std::size_t pos, std::size_t count)
const
567 pos = std::min(pos, size() - 1);
568 auto endStr = str + count;
569 for (
auto iter = cbegin() + pos; iter != cend(); ++iter) {
570 auto found = std::none_of(str, endStr,
571 [iter](TChar ch) ->
bool
577 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
584 std::size_t find_first_not_of(
const TChar* str, std::size_t pos)
const
586 return find_first_not_of(str, pos, strlen(str));
589 std::size_t find_first_not_of(TChar ch, std::size_t pos)
const
595 pos = std::min(pos, size() - 1);
596 auto iter = std::find_if(cbegin() + pos, cend(),
597 [ch](TChar nextCh) ->
bool
602 if (iter == cend()) {
606 return static_cast<std::size_t
>(std::distance(cbegin(), iter));
609 std::size_t find_last_of(
const TChar* str, std::size_t pos, std::size_t count)
const
615 pos = std::min(pos, size() - 1);
616 auto endStr = str + count;
618 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
619 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
620 for (
auto iter = begIter; iter != endIter; ++iter) {
621 auto foundIter = std::find(str, endStr, *iter);
622 if (foundIter != endStr) {
623 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
630 std::size_t find_last_of(
const TChar* str, std::size_t pos)
const
632 return find_last_of(str, pos, strlen(str));
635 std::size_t find_last_not_of(
const TChar* str, std::size_t pos, std::size_t count)
const
641 pos = std::min(pos, size() - 1);
642 auto endStr = str + count;
643 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
644 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
645 for (
auto iter = begIter; iter != endIter; ++iter) {
646 auto found = std::none_of(str, endStr,
647 [iter](TChar ch) ->
bool
653 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
660 std::size_t find_last_not_of(
const TChar* str, std::size_t pos)
const
662 return find_last_not_of(str, pos, strlen(str));
665 std::size_t find_last_not_of(TChar ch, std::size_t pos)
const
671 pos = std::min(pos, size() - 1);
672 auto begIter = std::reverse_iterator<const TChar*>(cbegin() + pos + 1);
673 auto endIter = std::reverse_iterator<const TChar*>(cbegin());
674 auto iter = std::find_if(begIter, endIter,
675 [ch](TChar nextCh) ->
bool
680 if (iter == endIter) {
684 return static_cast<std::size_t
>(std::distance(iter, endIter)) - 1U;
687 bool operator<(
const TChar* str)
const
689 for (
auto idx = 0U; idx < size(); ++idx) {
694 auto ch = m_vec[idx];
710 bool operator>(
const TChar* str)
const
712 for (
auto idx = 0U; idx < size(); ++idx) {
717 auto ch = m_vec[idx];
731 bool operator==(
const TChar* str)
const
733 for (
auto idx = 0U; idx < size(); ++idx) {
738 auto ch = m_vec[idx];
746 return (*str == Ends);
752 m_vec.push_back(TChar(Ends));
755 std::size_t strlen(
const TChar* str)
const
758 while (*strTmp != Ends) {
762 return static_cast<std::size_t
>(std::distance(str, strTmp));
765 static const TChar Ends =
static_cast<TChar
>(
'\0');
766 StaticVectorBase<TChar> m_vec;
769template <
typename TChar, std::
size_t TSize>
770struct StaticStringStorageBase
772 using StorageType = std::array<TChar, TSize>;
787template <std::
size_t TSize,
typename TChar =
char>
789 public details::StaticStringStorageBase<TChar, TSize + 1>,
790 public details::StaticStringBase<TChar>
792 using StorageBase = details::StaticStringStorageBase<TChar, TSize + 1>;
793 using Base = details::StaticStringBase<TChar>;
820 static const decltype(Base::npos)
npos = Base::npos;
825 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
832 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
840 template <std::
size_t TOtherSize>
845 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
847 assign(other, pos, count);
853 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
861 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
868 template <
typename TIter>
870 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
878 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
885 template <std::
size_t TOtherSize>
887 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
895 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
897 assign(init.begin(), init.end());
909 template <std::
size_t TOtherSize>
940 Base::assign(count, ch);
946 template <
typename TOtherSize>
949 if (&other !=
this) {
957 template <std::
size_t TOtherSize>
966 template <std::
size_t TOtherSize>
972 Base::assign(other, pos, count);
980 Base::assign(str, count);
994 template <
typename TIter>
997 Base::assign(first, last);
1005 return assign(init.begin(), init.end());
1014 return Base::at(pos);
1023 return Base::at(pos);
1030 return Base::operator[](pos);
1037 return Base::operator[](pos);
1045 return Base::front();
1053 return Base::front();
1061 return Base::back();
1069 return Base::back();
1076 return Base::data();
1090 return Base::begin();
1104 return Base::cbegin();
1125 return Base::cend();
1174 return Base::empty();
1181 return Base::size();
1211 return Base::capacity();
1232 Base::insert(idx, count, ch);
1240 Base::insert(idx, str);
1248 Base::insert(idx, str, count);
1254 template <std::
size_t TAnySize>
1257 Base::insert(idx, str);
1263 template <std::
size_t TAnySize>
1270 Base::insert(idx, str, str_idx, count);
1278 return Base::insert(pos, ch);
1285 return Base::insert(pos, count, ch);
1290 template <
typename TIter>
1293 return Base::insert(pos, first, last);
1300 return insert(pos, init.begin(), init.end());
1307 Base::erase(idx, count);
1315 return Base::erase(pos);
1322 return Base::erase(first, last);
1329 Base::push_back(ch);
1349 template <std::
size_t TAnySize>
1357 template <std::
size_t TAnySize>
1382 template <
typename TIter>
1393 insert(
end(), init.begin(), init.end());
1399 template <std::
size_t TAnySize>
1428 template <std::
size_t TAnySize>
1436 template <std::
size_t TAnySize>
1442 return compare(pos, count, other, 0, other.
size());
1447 template <std::
size_t TAnySize>
1455 return Base::compare(pos1, count1, other, pos2, count2);
1469 return Base::compare(pos, count, str);
1476 return Base::compare(pos, count1, str, count2);
1481 template <std::
size_t TAnySize>
1488 auto begIter =
begin() + pos;
1489 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1490 auto endIter = begIter + std::min(count, remCount);
1496 template <std::
size_t TAnySize>
1507 template <std::
size_t TAnySize>
1516 auto begIter =
begin() + pos;
1517 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1518 auto endIter = begIter + std::min(count, remCount);
1521 auto begIter2 = other.
begin() + pos2;
1522 auto remCount2 =
static_cast<std::size_t
>(std::distance(begIter2, other.
end()));
1523 auto endIter2 = begIter2 + std::min(count2, remCount2);
1525 return replace(begIter, endIter, begIter2, endIter2);
1530 template <
typename TIter>
1537 Base::replace(first, last, first2, last2);
1550 auto begIter =
cbegin() + pos;
1551 auto endIter = begIter + std::min(count,
size() - pos);
1552 return replace(begIter, endIter, str, str + count2);
1563 return replace(first, last, str, str + count2);
1574 auto begIter =
cbegin() + pos;
1575 auto endIter = begIter + std::min(count,
size() - pos);
1576 return replace(begIter, endIter, str);
1586 Base::replace(first, last, str);
1599 auto begIter =
cbegin() + pos;
1600 auto endIter = begIter + std::min(count,
size() - pos);
1601 return replace(begIter, endIter, count2, ch);
1612 Base::replace(first, last, count2, ch);
1621 std::initializer_list<value_type> init)
1623 return replace(first, last, init.begin(), init.end());
1631 auto begIter =
cbegin() + pos;
1632 auto endIter = begIter + std::min(count,
size() - pos);
1640 return Base::copy(dest, count, pos);
1647 Base::resize(count);
1654 Base::resize(count, ch);
1659 template <std::
size_t TAnySize>
1667 template <std::
size_t TAnySize>
1678 return Base::find(str, pos, count);
1685 return Base::find(str, pos);
1692 return Base::find(ch, pos);
1697 template <std::
size_t TAnySize>
1707 return Base::rfind(str, pos, count);
1714 return Base::rfind(str, pos);
1721 return Base::rfind(ch, pos);
1726 template <std::
size_t TAnySize>
1737 return Base::find_first_of(str, pos, count);
1744 return Base::find_first_of(str, pos);
1751 return find(ch, pos);
1756 template <std::
size_t TAnySize>
1767 return Base::find_first_not_of(str, pos, count);
1774 return Base::find_first_not_of(str, pos);
1781 return Base::find_first_not_of(ch, pos);
1786 template <std::
size_t TAnySize>
1796 return Base::find_last_of(str, pos, count);
1803 return Base::find_last_of(str, pos);
1810 return rfind(ch, pos);
1815 template <std::
size_t TAnySize>
1825 return Base::find_last_not_of(str, pos, count);
1832 return Base::find_last_not_of(str, pos);
1839 return Base::find_last_not_of(ch, pos);
1845 return Base::operator<(str);
1851 return Base::operator>(str);
1857 return Base::operator==(str);
1864template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1867 return std::lexicographical_compare(str1.
begin(), str1.
end(), str2.
begin(), str2.
end());
1873template <std::
size_t TSize1,
typename TChar>
1876 return (str2 > str1);
1882template <std::
size_t TSize1,
typename TChar>
1885 return str1.operator<(str2);
1891template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1894 return !(str2 < str1);
1900template <std::
size_t TSize1,
typename TChar>
1903 return !(str2 < str1);
1909template <std::
size_t TSize1,
typename TChar>
1912 return !(str1 > str2);
1918template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1921 return (str2 < str1);
1927template <std::
size_t TSize1,
typename TChar>
1930 return (str2 < str1);
1936template <std::
size_t TSize1,
typename TChar>
1939 return str1.operator<(str2);
1945template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1948 return !(str1 < str2);
1954template <std::
size_t TSize1,
typename TChar>
1957 return !(str1 < str2);
1963template <std::
size_t TSize1,
typename TChar>
1966 return !(str1 < str2);
1972template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1983template <std::
size_t TSize1,
typename TChar>
1986 return str2.operator==(str1);
1992template <std::
size_t TSize1,
typename TChar>
1995 return str1.operator==(str2);
2001template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
2004 return !(str1 == str2);
2010template <std::
size_t TSize1,
typename TChar>
2013 return !(str2 == str1);
2019template <std::
size_t TSize1,
typename TChar>
2022 return !(str1 == str2);
2028template <
typename T>
2029struct IsStaticString
2031 static const bool Value =
false;
2034template <std::
size_t TSize>
2037 static const bool Value =
true;
2045template <
typename T>
2048 return details::IsStaticString<T>::Value;
2061template <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:791
size_type rfind(value_type ch, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1719
int compare(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1437
const_iterator end() const
Returns an iterator to the end.
Definition StaticString.h:1116
const_iterator begin() const
Returns an iterator to the beginning.
Definition StaticString.h:1095
bool operator!=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:2002
const_reference at(size_type pos) const
Access specified character with bounds checking.
Definition StaticString.h:1021
size_type find_last_of(const_pointer str, size_type pos, size_type count) const
Find last occurrence of characters.
Definition StaticString.h:1794
const_pointer const_iterator
Type of the const iterator.
Definition StaticString.h:813
const_reference back() const
Accesses the last character.
Definition StaticString.h:1067
const_iterator cend() const
Returns an iterator to the end.
Definition StaticString.h:1123
void swap(comms::util::StaticString< TSize1, TChar > &str1, comms::util::StaticString< TSize2, TChar > &str2)
Specializes the std::swap algorithm.
Definition StaticString.h:2062
StaticString & replace(size_type pos, size_type count, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1568
reference at(size_type pos)
Access specified character with bounds checking.
Definition StaticString.h:1012
size_type size() const
returns the number of characters.
Definition StaticString.h:1179
StaticString & operator+=(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1421
size_type copy(pointer dest, size_type count, size_type pos=0) const
Copies characters.
Definition StaticString.h:1638
size_type find_first_not_of(const_pointer str, size_type pos, size_type count) const
Find first absence of characters.
Definition StaticString.h:1765
StaticString & assign(TIter first, TIter last)
Assign characters to a string.
Definition StaticString.h:995
bool operator<=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1901
bool operator>(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1919
StaticString & append(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1391
size_type rfind(const_pointer str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1712
StaticString(TIter first, TIter last)
Constructor variant.
Definition StaticString.h:869
void clear()
Clears the contents.
Definition StaticString.h:1223
const_reverse_iterator rend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1158
const_pointer data() const
Returns a pointer to the first character of a string.
Definition StaticString.h:1074
std::size_t size_type
Type used for size information.
Definition StaticString.h:799
static constexpr bool isStaticString()
Compile time check whether the provided type is a variant of comms::util::StaticString.
Definition StaticString.h:2046
const_iterator cbegin() const
Returns an iterator to the beginning.
Definition StaticString.h:1102
size_type rfind(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1698
bool operator<=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1892
const_reference operator[](size_type pos) const
Access specified character without bounds checking.
Definition StaticString.h:1035
StaticString & operator+=(value_type ch)
Appends characters to the end.
Definition StaticString.h:1407
StaticString & replace(const_iterator first, const_iterator last, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1606
StaticString & replace(const_iterator first, const_iterator last, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1557
size_type find_last_not_of(value_type ch, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1837
size_type find_last_of(const_pointer str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1801
StaticString & assign(const StaticString< TOtherSize, TChar > &other)
Assign characters to a string.
Definition StaticString.h:958
const value_type * const_pointer
Const pointer to single character.
Definition StaticString.h:809
StaticString & append(const TChar *str, size_type count)
Appends characters to the end.
Definition StaticString.h:1368
static const decltype(Base::npos) npos
Same as std::string::npos.
Definition StaticString.h:820
bool operator<(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1843
size_type find_last_not_of(const_pointer str, size_type pos, size_type count) const
Find last absence of characters.
Definition StaticString.h:1823
bool operator>=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1955
StaticString(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Constructor variant.
Definition StaticString.h:841
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:1508
void swap(StaticString< TAnySize, TChar > &other)
Swaps the contents of two strings.
Definition StaticString.h:1660
size_type find(const_pointer str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1683
StaticString & replace(const_iterator first, const_iterator last, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1581
StaticString & replace(size_type pos, size_type count, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1592
size_type find_first_of(const_pointer str, size_type pos, size_type count) const
Find first occurrence of characters.
Definition StaticString.h:1735
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str)
Inserts characters.
Definition StaticString.h:1255
iterator insert(const_iterator pos, std::initializer_list< value_type > init)
Inserts characters.
Definition StaticString.h:1298
size_type length() const
returns the number of characters.
Definition StaticString.h:1186
bool operator>(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1849
bool operator==(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1855
size_type find_first_of(const_pointer str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1742
const_pointer c_str() const
Returns a non-modifiable standard C character array version of the string.
Definition StaticString.h:1081
StaticString substr(size_type pos=0, size_type count=npos) const
Returns a substring.
Definition StaticString.h:1628
bool operator<(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1874
StaticString & assign(std::initializer_list< value_type > init)
Assign characters to a string.
Definition StaticString.h:1003
void push_back(value_type ch)
Appends a character to the end.
Definition StaticString.h:1327
StaticString & assign(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Assign characters to a string.
Definition StaticString.h:967
const_reference front() const
Accesses the first character.
Definition StaticString.h:1051
size_type find_first_of(value_type ch, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1749
StaticString & insert(size_type idx, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1230
StaticString(const_pointer str, size_type count)
Constructor variant.
Definition StaticString.h:852
const_reverse_iterator rbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1137
bool operator<(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1865
StaticString & append(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1350
StaticString & append(const TChar *str)
Appends characters to the end.
Definition StaticString.h:1375
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1144
size_type find_last_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1787
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:1448
StaticString & insert(size_type idx, const_pointer str, size_type count)
Inserts characters.
Definition StaticString.h:1246
size_type find_last_of(value_type ch, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1808
size_type find(const_pointer str, size_type pos, size_type count) const
Find characters in the string.
Definition StaticString.h:1676
bool operator>(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1928
StaticString & erase(std::size_t idx, std::size_t count=npos)
Removes characters.
Definition StaticString.h:1305
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str, size_type str_idx, size_type count=npos)
Inserts characters.
Definition StaticString.h:1264
StaticString & operator=(const_pointer str)
Assignment operator.
Definition StaticString.h:917
StaticString & assign(const_pointer str)
Assign characters to a string.
Definition StaticString.h:986
size_type find(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1668
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition StaticString.h:1151
int compare(const_pointer str) const
Compares two strings.
Definition StaticString.h:1460
size_type find_first_not_of(value_type ch, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1779
bool operator>(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1937
StaticString & assign(size_type count, value_type ch)
Assign characters to a string.
Definition StaticString.h:938
size_type find_last_not_of(const_pointer str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1830
StaticString & replace(const_iterator first, const_iterator last, std::initializer_list< value_type > init)
Replaces specified portion of a string.
Definition StaticString.h:1618
StaticString(std::initializer_list< value_type > init)
Constructor variant.
Definition StaticString.h:894
bool empty() const
Checks whether the string is empty.
Definition StaticString.h:1172
StaticString & assign(const StaticString &other)
Assign characters to a string.
Definition StaticString.h:947
bool operator!=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:2011
value_type & reference
Reference to single character.
Definition StaticString.h:803
StaticString()
Default constructor.
Definition StaticString.h:824
StaticString & append(const StaticString< TAnySize, TChar > &other, size_type pos, size_type count=npos)
Appends characters to the end.
Definition StaticString.h:1358
StaticString & replace(const_iterator first, const_iterator last, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1497
StaticString & operator=(std::initializer_list< value_type > init)
Assignment operator.
Definition StaticString.h:931
StaticString & insert(size_type idx, const_pointer str)
Inserts characters.
Definition StaticString.h:1238
StaticString & operator=(const StaticString< TOtherSize, TChar > &other)
Copy assignment from string of different capacity.
Definition StaticString.h:910
iterator insert(const_iterator pos, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1283
StaticString & operator=(value_type ch)
Assignment operator.
Definition StaticString.h:924
reference operator[](size_type pos)
Access specified character without bounds checking.
Definition StaticString.h:1028
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition StaticString.h:1130
size_type find(value_type ch, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1690
void reserve(size_type)
Reserves storage.
Definition StaticString.h:1202
StaticString & replace(size_type pos, size_type count, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1543
const_reverse_iterator crend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1165
bool operator>=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1946
StaticString & assign(const_pointer str, size_type count)
Assign characters to a string.
Definition StaticString.h:978
std::reverse_iterator< iterator > reverse_iterator
Type of the reverse iterator.
Definition StaticString.h:815
TChar value_type
Type of single character.
Definition StaticString.h:797
bool operator==(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1973
StaticString(size_type count, value_type ch)
Constructor variant.
Definition StaticString.h:831
int compare(size_type pos, size_type count1, const_pointer str, size_type count2) const
Compares two strings.
Definition StaticString.h:1474
iterator insert(const_iterator pos, value_type ch)
Inserts characters.
Definition StaticString.h:1276
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition StaticString.h:1217
reference front()
Accesses the first character.
Definition StaticString.h:1043
StaticString(const StaticString &other)
Copy constructor.
Definition StaticString.h:877
bool operator<(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1883
bool operator==(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Equality compare between the strings.
Definition StaticString.h:1984
std::reverse_iterator< const_iterator > const_reverse_iterator
Type of the const reverse iterator.
Definition StaticString.h:817
StaticString & append(TIter first, TIter last)
Appends characters to the end.
Definition StaticString.h:1383
size_type rfind(const_pointer str, size_type pos, size_type count) const
Find the last occurrence of the substring.
Definition StaticString.h:1705
StaticString & append(size_type count, value_type ch)
Appends characters to the end.
Definition StaticString.h:1342
StaticString & operator+=(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1400
typename StorageBase::StorageType::difference_type difference_type
Type used in pointer arithmetics.
Definition StaticString.h:801
StaticString & replace(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1482
size_type find_first_not_of(const_pointer str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1772
bool operator==(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Equality compare between the strings.
Definition StaticString.h:1993
bool operator<=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1910
void resize(size_type count, value_type ch)
Changes the number of characters stored.
Definition StaticString.h:1652
StaticString & replace(const_iterator first, const_iterator last, TIter first2, TIter last2)
Replaces specified portion of a string.
Definition StaticString.h:1531
bool operator>=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1964
StaticString & operator+=(const_pointer str)
Appends characters to the end.
Definition StaticString.h:1414
iterator end()
Returns an iterator to the end.
Definition StaticString.h:1109
void pop_back()
Removes the last character.
Definition StaticString.h:1335
pointer iterator
Type of the iterator.
Definition StaticString.h:811
iterator insert(const_iterator pos, TIter first, TIter last)
Inserts characters.
Definition StaticString.h:1291
const value_type & const_reference
Const reference to single character.
Definition StaticString.h:805
iterator erase(const_iterator first, const_iterator last)
Removes characters.
Definition StaticString.h:1320
StaticString(const_pointer str)
Constructor variant.
Definition StaticString.h:860
bool operator!=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Inequality compare between the strings.
Definition StaticString.h:2020
size_type find_last_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1816
iterator begin()
Returns an iterator to the beginning.
Definition StaticString.h:1088
StaticString(const StaticString< TOtherSize, TChar > &other)
Copy constructor variant.
Definition StaticString.h:886
int compare(const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1429
int compare(size_type pos, size_type count, const_pointer str) const
Compares two strings.
Definition StaticString.h:1467
size_type max_size() const
Returns the maximum number of characters.
Definition StaticString.h:1194
size_type find_first_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1757
value_type * pointer
Pointer to single character.
Definition StaticString.h:807
iterator erase(const_iterator pos)
Removes characters.
Definition StaticString.h:1313
reference back()
Accesses the last character.
Definition StaticString.h:1059
void resize(size_type count)
Changes the number of characters stored.
Definition StaticString.h:1645
StaticString & operator=(const StaticString &other)
Copy assignment.
Definition StaticString.h:902
size_type find_first_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1727
size_type capacity() const
returns the number of characters that can be held in currently allocated storage.
Definition StaticString.h:1209
void assign(T &obj, TIter from, TIter to)
Assigns a new value to provided object.
Definition assign.h:41
Main namespace for all classes / functions of COMMS library.