18#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 : m_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(m_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(m_vec));
70 void assign(
const TChar* str, std::size_t count)
73 auto countLimit = std::min(count, capacity());
74 while ((m_vec.size() < countLimit) && (*str != Ends)) {
75 m_vec.push_back(*str);
81 void assign(
const TChar* str)
86 template <
typename TIter>
87 void assign(TIter first, TIter last)
89 m_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
118 return m_vec.front();
121 const TChar& front()
const
124 return m_vec.front();
130 return m_vec[size() - 1];
133 const TChar& back()
const
136 return m_vec[size() - 1];
139 const TChar* data()
const
147 return m_vec.begin();
150 const TChar* cbegin()
const
152 return m_vec.cbegin();
157 return begin() + size();
160 const TChar* cend()
const
162 return cbegin() + size();
170 std::size_t size()
const
173 return m_vec.size() - 1;
176 std::size_t capacity()
const
178 return m_vec.capacity() - 1;
187 void insert(std::size_t idx, std::size_t count, TChar ch)
190 m_vec.insert(m_vec.begin() + idx, count, ch);
193 void insert(std::size_t idx,
const TChar* str)
196 m_vec.insert(m_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 m_vec.insert(m_vec.begin() + idx, str, endStr);
206 void insert(std::size_t idx,
const StaticStringBase& other)
209 m_vec.insert(m_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 m_vec.insert(m_vec.begin() + idx, begIter, endIter);
221 TChar* insert(
const TChar* pos, TChar ch)
223 return m_vec.insert(pos, ch);
226 TChar* insert(
const TChar* pos, std::size_t count, TChar ch)
228 return m_vec.insert(pos, count, ch);
231 template <
typename TIter>
232 TChar* insert(
const TChar* pos, TIter first, TIter last)
234 return m_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 m_vec.erase(begIter, endIter);
246 TChar* erase(
const TChar* pos)
248 return m_vec.erase(pos, pos + 1);
251 TChar* erase(
const TChar* first,
const TChar* last)
253 return m_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 m_vec.insert(end(), ch);
266 static constexpr bool The_string_is_empty =
false;
267 static_cast<void>(The_string_is_empty);
269 m_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 m_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 m_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 m_vec.erase(iter, endIter);
392 auto remCapacity = capacity() - size();
393 auto endStr = str + remCapacity;
394 auto lastStrIter = std::find(str, endStr, TChar(Ends));
395 m_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 m_vec.erase(first + fillDist, last);
416 m_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 m_vec.erase(cbegin() + count, cend());
441 m_vec.insert(end(), count - size(), ch);
444 void swap(StaticStringBase& other)
446 m_vec.swap(other.m_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 = &m_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 = &m_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) {
691 auto ch = m_vec[idx];
707 bool operator>(
const TChar* str)
const
709 for (
auto idx = 0U; idx < size(); ++idx) {
714 auto ch = m_vec[idx];
728 bool operator==(
const TChar* str)
const
730 for (
auto idx = 0U; idx < size(); ++idx) {
735 auto ch = m_vec[idx];
743 return (*str == Ends);
749 m_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> m_vec;
766template <
typename TChar, std::
size_t TSize>
767struct StaticStringStorageBase
769 using StorageType = std::array<TChar, TSize>;
784template <std::
size_t TSize,
typename TChar =
char>
786 public details::StaticStringStorageBase<TChar, TSize + 1>,
787 public details::StaticStringBase<TChar>
789 using StorageBase = details::StaticStringStorageBase<TChar, TSize + 1>;
790 using Base = details::StaticStringBase<TChar>;
817 static const decltype(Base::npos)
npos = Base::npos;
822 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
829 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
837 template <std::
size_t TOtherSize>
842 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
844 assign(other, pos, count);
850 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
858 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
865 template <
typename TIter>
867 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
875 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
882 template <std::
size_t TOtherSize>
884 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
892 : Base(StorageBase::m_data.
data(), StorageBase::m_data.
size())
894 assign(init.begin(), init.end());
906 template <std::
size_t TOtherSize>
937 Base::assign(count, ch);
943 template <
typename TOtherSize>
946 if (&other !=
this) {
954 template <std::
size_t TOtherSize>
963 template <std::
size_t TOtherSize>
969 Base::assign(other, pos, count);
977 Base::assign(str, count);
991 template <
typename TIter>
994 Base::assign(first, last);
1002 return assign(init.begin(), init.end());
1011 return Base::at(pos);
1020 return Base::at(pos);
1027 return Base::operator[](pos);
1034 return Base::operator[](pos);
1042 return Base::front();
1050 return Base::front();
1058 return Base::back();
1066 return Base::back();
1073 return Base::data();
1087 return Base::begin();
1101 return Base::cbegin();
1122 return Base::cend();
1171 return Base::empty();
1178 return Base::size();
1208 return Base::capacity();
1229 Base::insert(idx, count, ch);
1237 Base::insert(idx, str);
1245 Base::insert(idx, str, count);
1251 template <std::
size_t TAnySize>
1254 Base::insert(idx, str);
1260 template <std::
size_t TAnySize>
1267 Base::insert(idx, str, str_idx, count);
1275 return Base::insert(pos, ch);
1282 return Base::insert(pos, count, ch);
1287 template <
typename TIter>
1290 return Base::insert(pos, first, last);
1297 return insert(pos, init.begin(), init.end());
1304 Base::erase(idx, count);
1312 return Base::erase(pos);
1319 return Base::erase(first, last);
1326 Base::push_back(ch);
1346 template <std::
size_t TAnySize>
1354 template <std::
size_t TAnySize>
1379 template <
typename TIter>
1390 insert(
end(), init.begin(), init.end());
1396 template <std::
size_t TAnySize>
1425 template <std::
size_t TAnySize>
1433 template <std::
size_t TAnySize>
1439 return compare(pos, count, other, 0, other.
size());
1444 template <std::
size_t TAnySize>
1452 return Base::compare(pos1, count1, other, pos2, count2);
1466 return Base::compare(pos, count, str);
1473 return Base::compare(pos, count1, str, count2);
1478 template <std::
size_t TAnySize>
1485 auto begIter =
begin() + pos;
1486 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1487 auto endIter = begIter + std::min(count, remCount);
1493 template <std::
size_t TAnySize>
1504 template <std::
size_t TAnySize>
1513 auto begIter =
begin() + pos;
1514 auto remCount =
static_cast<std::size_t
>(std::distance(begIter,
end()));
1515 auto endIter = begIter + std::min(count, remCount);
1518 auto begIter2 = other.
begin() + pos2;
1519 auto remCount2 =
static_cast<std::size_t
>(std::distance(begIter2, other.
end()));
1520 auto endIter2 = begIter2 + std::min(count2, remCount2);
1522 return replace(begIter, endIter, begIter2, endIter2);
1527 template <
typename TIter>
1534 Base::replace(first, last, first2, last2);
1547 auto begIter =
cbegin() + pos;
1548 auto endIter = begIter + std::min(count,
size() - pos);
1549 return replace(begIter, endIter, str, str + count2);
1560 return replace(first, last, str, str + count2);
1571 auto begIter =
cbegin() + pos;
1572 auto endIter = begIter + std::min(count,
size() - pos);
1573 return replace(begIter, endIter, str);
1583 Base::replace(first, last, str);
1596 auto begIter =
cbegin() + pos;
1597 auto endIter = begIter + std::min(count,
size() - pos);
1598 return replace(begIter, endIter, count2, ch);
1609 Base::replace(first, last, count2, ch);
1618 std::initializer_list<value_type> init)
1620 return replace(first, last, init.begin(), init.end());
1628 auto begIter =
cbegin() + pos;
1629 auto endIter = begIter + std::min(count,
size() - pos);
1637 return Base::copy(dest, count, pos);
1644 Base::resize(count);
1651 Base::resize(count, ch);
1656 template <std::
size_t TAnySize>
1664 template <std::
size_t TAnySize>
1675 return Base::find(str, pos, count);
1682 return Base::find(str, pos);
1689 return Base::find(ch, pos);
1694 template <std::
size_t TAnySize>
1704 return Base::rfind(str, pos, count);
1711 return Base::rfind(str, pos);
1718 return Base::rfind(ch, pos);
1723 template <std::
size_t TAnySize>
1734 return Base::find_first_of(str, pos, count);
1741 return Base::find_first_of(str, pos);
1748 return find(ch, pos);
1753 template <std::
size_t TAnySize>
1764 return Base::find_first_not_of(str, pos, count);
1771 return Base::find_first_not_of(str, pos);
1778 return Base::find_first_not_of(ch, pos);
1783 template <std::
size_t TAnySize>
1793 return Base::find_last_of(str, pos, count);
1800 return Base::find_last_of(str, pos);
1807 return rfind(ch, pos);
1812 template <std::
size_t TAnySize>
1822 return Base::find_last_not_of(str, pos, count);
1829 return Base::find_last_not_of(str, pos);
1836 return Base::find_last_not_of(ch, pos);
1842 return Base::operator<(str);
1848 return Base::operator>(str);
1854 return Base::operator==(str);
1861template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1864 return std::lexicographical_compare(str1.
begin(), str1.
end(), str2.
begin(), str2.
end());
1870template <std::
size_t TSize1,
typename TChar>
1873 return (str2 > str1);
1879template <std::
size_t TSize1,
typename TChar>
1882 return str1.operator<(str2);
1888template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1891 return !(str2 < str1);
1897template <std::
size_t TSize1,
typename TChar>
1900 return !(str2 < str1);
1906template <std::
size_t TSize1,
typename TChar>
1909 return !(str1 > str2);
1915template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1918 return (str2 < str1);
1924template <std::
size_t TSize1,
typename TChar>
1927 return (str2 < str1);
1933template <std::
size_t TSize1,
typename TChar>
1936 return str1.operator<(str2);
1942template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1945 return !(str1 < str2);
1951template <std::
size_t TSize1,
typename TChar>
1954 return !(str1 < str2);
1960template <std::
size_t TSize1,
typename TChar>
1963 return !(str1 < str2);
1969template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
1980template <std::
size_t TSize1,
typename TChar>
1983 return str2.operator==(str1);
1989template <std::
size_t TSize1,
typename TChar>
1992 return str1.operator==(str2);
1998template <std::
size_t TSize1, std::
size_t TSize2,
typename TChar>
2001 return !(str1 == str2);
2007template <std::
size_t TSize1,
typename TChar>
2010 return !(str2 == str1);
2016template <std::
size_t TSize1,
typename TChar>
2019 return !(str1 == str2);
2025template <
typename T>
2026struct IsStaticString
2028 static const bool Value =
false;
2031template <std::
size_t TSize>
2034 static const bool Value =
true;
2042template <
typename T>
2045 return details::IsStaticString<T>::Value;
2058template <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:168
Contains various compiler related definitions.
Contains comms::util::StaticVector class.
Replacement to std::string when no dynamic memory allocation is allowed.
Definition StaticString.h:788
size_type rfind(value_type ch, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1716
int compare(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1434
const_iterator end() const
Returns an iterator to the end.
Definition StaticString.h:1113
const_iterator begin() const
Returns an iterator to the beginning.
Definition StaticString.h:1092
bool operator!=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:1999
const_reference at(size_type pos) const
Access specified character with bounds checking.
Definition StaticString.h:1018
size_type find_last_of(const_pointer str, size_type pos, size_type count) const
Find last occurrence of characters.
Definition StaticString.h:1791
const_pointer const_iterator
Type of the const iterator.
Definition StaticString.h:810
const_reference back() const
Accesses the last character.
Definition StaticString.h:1064
const_iterator cend() const
Returns an iterator to the end.
Definition StaticString.h:1120
void swap(comms::util::StaticString< TSize1, TChar > &str1, comms::util::StaticString< TSize2, TChar > &str2)
Specializes the std::swap algorithm.
Definition StaticString.h:2059
StaticString & replace(size_type pos, size_type count, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1565
reference at(size_type pos)
Access specified character with bounds checking.
Definition StaticString.h:1009
size_type size() const
returns the number of characters.
Definition StaticString.h:1176
StaticString & operator+=(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1418
size_type copy(pointer dest, size_type count, size_type pos=0) const
Copies characters.
Definition StaticString.h:1635
size_type find_first_not_of(const_pointer str, size_type pos, size_type count) const
Find first absence of characters.
Definition StaticString.h:1762
StaticString & assign(TIter first, TIter last)
Assign characters to a string.
Definition StaticString.h:992
bool operator<=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1898
bool operator>(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1916
StaticString & append(std::initializer_list< value_type > init)
Appends characters to the end.
Definition StaticString.h:1388
size_type rfind(const_pointer str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1709
StaticString(TIter first, TIter last)
Constructor variant.
Definition StaticString.h:866
void clear()
Clears the contents.
Definition StaticString.h:1220
const_reverse_iterator rend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1155
const_pointer data() const
Returns a pointer to the first character of a string.
Definition StaticString.h:1071
std::size_t size_type
Type used for size information.
Definition StaticString.h:796
static constexpr bool isStaticString()
Compile time check whether the provided type is a variant of comms::util::StaticString.
Definition StaticString.h:2043
const_iterator cbegin() const
Returns an iterator to the beginning.
Definition StaticString.h:1099
size_type rfind(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find the last occurrence of the substring.
Definition StaticString.h:1695
bool operator<=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1889
const_reference operator[](size_type pos) const
Access specified character without bounds checking.
Definition StaticString.h:1032
StaticString & operator+=(value_type ch)
Appends characters to the end.
Definition StaticString.h:1404
StaticString & replace(const_iterator first, const_iterator last, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1603
StaticString & replace(const_iterator first, const_iterator last, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1554
size_type find_last_not_of(value_type ch, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1834
size_type find_last_of(const_pointer str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1798
StaticString & assign(const StaticString< TOtherSize, TChar > &other)
Assign characters to a string.
Definition StaticString.h:955
const value_type * const_pointer
Const pointer to single character.
Definition StaticString.h:806
StaticString & append(const TChar *str, size_type count)
Appends characters to the end.
Definition StaticString.h:1365
static const decltype(Base::npos) npos
Same as std::string::npos.
Definition StaticString.h:817
bool operator<(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1840
size_type find_last_not_of(const_pointer str, size_type pos, size_type count) const
Find last absence of characters.
Definition StaticString.h:1820
bool operator>=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1952
StaticString(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Constructor variant.
Definition StaticString.h:838
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:1505
void swap(StaticString< TAnySize, TChar > &other)
Swaps the contents of two strings.
Definition StaticString.h:1657
size_type find(const_pointer str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1680
StaticString & replace(const_iterator first, const_iterator last, const_pointer str)
Replaces specified portion of a string.
Definition StaticString.h:1578
StaticString & replace(size_type pos, size_type count, size_type count2, value_type ch)
Replaces specified portion of a string.
Definition StaticString.h:1589
size_type find_first_of(const_pointer str, size_type pos, size_type count) const
Find first occurrence of characters.
Definition StaticString.h:1732
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str)
Inserts characters.
Definition StaticString.h:1252
iterator insert(const_iterator pos, std::initializer_list< value_type > init)
Inserts characters.
Definition StaticString.h:1295
size_type length() const
returns the number of characters.
Definition StaticString.h:1183
bool operator>(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1846
bool operator==(const_pointer str) const
Lexicographical compare to other string.
Definition StaticString.h:1852
size_type find_first_of(const_pointer str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1739
const_pointer c_str() const
Returns a non-modifiable standard C character array version of the string.
Definition StaticString.h:1078
StaticString substr(size_type pos=0, size_type count=npos) const
Returns a substring.
Definition StaticString.h:1625
bool operator<(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1871
StaticString & assign(std::initializer_list< value_type > init)
Assign characters to a string.
Definition StaticString.h:1000
void push_back(value_type ch)
Appends a character to the end.
Definition StaticString.h:1324
StaticString & assign(const StaticString< TOtherSize, TChar > &other, size_type pos, size_type count=npos)
Assign characters to a string.
Definition StaticString.h:964
const_reference front() const
Accesses the first character.
Definition StaticString.h:1048
size_type find_first_of(value_type ch, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1746
StaticString & insert(size_type idx, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1227
StaticString(const_pointer str, size_type count)
Constructor variant.
Definition StaticString.h:849
const_reverse_iterator rbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1134
bool operator<(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1862
StaticString & append(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1347
StaticString & append(const TChar *str)
Appends characters to the end.
Definition StaticString.h:1372
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition StaticString.h:1141
size_type find_last_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1784
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:1445
StaticString & insert(size_type idx, const_pointer str, size_type count)
Inserts characters.
Definition StaticString.h:1243
size_type find_last_of(value_type ch, size_type pos=npos) const
Find last occurrence of characters.
Definition StaticString.h:1805
size_type find(const_pointer str, size_type pos, size_type count) const
Find characters in the string.
Definition StaticString.h:1673
bool operator>(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1925
StaticString & erase(std::size_t idx, std::size_t count=npos)
Removes characters.
Definition StaticString.h:1302
StaticString & insert(size_type idx, const StaticString< TAnySize, TChar > &str, size_type str_idx, size_type count=npos)
Inserts characters.
Definition StaticString.h:1261
StaticString & operator=(const_pointer str)
Assignment operator.
Definition StaticString.h:914
StaticString & assign(const_pointer str)
Assign characters to a string.
Definition StaticString.h:983
size_type find(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1665
reverse_iterator rend()
Returns a reverse iterator to the end.
Definition StaticString.h:1148
int compare(const_pointer str) const
Compares two strings.
Definition StaticString.h:1457
size_type find_first_not_of(value_type ch, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1776
bool operator>(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1934
StaticString & assign(size_type count, value_type ch)
Assign characters to a string.
Definition StaticString.h:935
size_type find_last_not_of(const_pointer str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1827
StaticString & replace(const_iterator first, const_iterator last, std::initializer_list< value_type > init)
Replaces specified portion of a string.
Definition StaticString.h:1615
StaticString(std::initializer_list< value_type > init)
Constructor variant.
Definition StaticString.h:891
bool empty() const
Checks whether the string is empty.
Definition StaticString.h:1169
StaticString & assign(const StaticString &other)
Assign characters to a string.
Definition StaticString.h:944
bool operator!=(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Inequality compare between the strings.
Definition StaticString.h:2008
value_type & reference
Reference to single character.
Definition StaticString.h:800
StaticString()
Default constructor.
Definition StaticString.h:821
StaticString & append(const StaticString< TAnySize, TChar > &other, size_type pos, size_type count=npos)
Appends characters to the end.
Definition StaticString.h:1355
StaticString & replace(const_iterator first, const_iterator last, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1494
StaticString & operator=(std::initializer_list< value_type > init)
Assignment operator.
Definition StaticString.h:928
StaticString & insert(size_type idx, const_pointer str)
Inserts characters.
Definition StaticString.h:1235
StaticString & operator=(const StaticString< TOtherSize, TChar > &other)
Copy assignment from string of different capacity.
Definition StaticString.h:907
iterator insert(const_iterator pos, size_type count, value_type ch)
Inserts characters.
Definition StaticString.h:1280
StaticString & operator=(value_type ch)
Assignment operator.
Definition StaticString.h:921
reference operator[](size_type pos)
Access specified character without bounds checking.
Definition StaticString.h:1025
reverse_iterator rbegin()
Returns a reverse iterator to the beginning.
Definition StaticString.h:1127
size_type find(value_type ch, size_type pos=0) const
Find characters in the string.
Definition StaticString.h:1687
void reserve(size_type)
Reserves storage.
Definition StaticString.h:1199
StaticString & replace(size_type pos, size_type count, const_pointer str, size_type count2)
Replaces specified portion of a string.
Definition StaticString.h:1540
const_reverse_iterator crend() const
Returns a reverse iterator to the end.
Definition StaticString.h:1162
bool operator>=(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1943
StaticString & assign(const_pointer str, size_type count)
Assign characters to a string.
Definition StaticString.h:975
std::reverse_iterator< iterator > reverse_iterator
Type of the reverse iterator.
Definition StaticString.h:812
TChar value_type
Type of single character.
Definition StaticString.h:794
bool operator==(const StaticString< TSize1, TChar > &str1, const StaticString< TSize2, TChar > &str2)
Lexicographical compare between the strings.
Definition StaticString.h:1970
StaticString(size_type count, value_type ch)
Constructor variant.
Definition StaticString.h:828
int compare(size_type pos, size_type count1, const_pointer str, size_type count2) const
Compares two strings.
Definition StaticString.h:1471
iterator insert(const_iterator pos, value_type ch)
Inserts characters.
Definition StaticString.h:1273
void shrink_to_fit()
Reduces memory usage by freeing unused memory.
Definition StaticString.h:1214
reference front()
Accesses the first character.
Definition StaticString.h:1040
StaticString(const StaticString &other)
Copy constructor.
Definition StaticString.h:874
bool operator<(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1880
bool operator==(const TChar *str1, const StaticString< TSize1, TChar > &str2)
Equality compare between the strings.
Definition StaticString.h:1981
std::reverse_iterator< const_iterator > const_reverse_iterator
Type of the const reverse iterator.
Definition StaticString.h:814
StaticString & append(TIter first, TIter last)
Appends characters to the end.
Definition StaticString.h:1380
size_type rfind(const_pointer str, size_type pos, size_type count) const
Find the last occurrence of the substring.
Definition StaticString.h:1702
StaticString & append(size_type count, value_type ch)
Appends characters to the end.
Definition StaticString.h:1339
StaticString & operator+=(const StaticString< TAnySize, TChar > &other)
Appends characters to the end.
Definition StaticString.h:1397
typename StorageBase::StorageType::difference_type difference_type
Type used in pointer arithmetics.
Definition StaticString.h:798
StaticString & replace(size_type pos, size_type count, const StaticString< TAnySize, TChar > &other)
Replaces specified portion of a string.
Definition StaticString.h:1479
size_type find_first_not_of(const_pointer str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1769
bool operator==(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Equality compare between the strings.
Definition StaticString.h:1990
bool operator<=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1907
void resize(size_type count, value_type ch)
Changes the number of characters stored.
Definition StaticString.h:1649
StaticString & replace(const_iterator first, const_iterator last, TIter first2, TIter last2)
Replaces specified portion of a string.
Definition StaticString.h:1528
bool operator>=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Lexicographical compare between the strings.
Definition StaticString.h:1961
StaticString & operator+=(const_pointer str)
Appends characters to the end.
Definition StaticString.h:1411
iterator end()
Returns an iterator to the end.
Definition StaticString.h:1106
void pop_back()
Removes the last character.
Definition StaticString.h:1332
pointer iterator
Type of the iterator.
Definition StaticString.h:808
iterator insert(const_iterator pos, TIter first, TIter last)
Inserts characters.
Definition StaticString.h:1288
const value_type & const_reference
Const reference to single character.
Definition StaticString.h:802
iterator erase(const_iterator first, const_iterator last)
Removes characters.
Definition StaticString.h:1317
StaticString(const_pointer str)
Constructor variant.
Definition StaticString.h:857
bool operator!=(const StaticString< TSize1, TChar > &str1, const TChar *str2)
Inequality compare between the strings.
Definition StaticString.h:2017
size_type find_last_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=npos) const
Find last absence of characters.
Definition StaticString.h:1813
iterator begin()
Returns an iterator to the beginning.
Definition StaticString.h:1085
StaticString(const StaticString< TOtherSize, TChar > &other)
Copy constructor variant.
Definition StaticString.h:883
int compare(const StaticString< TAnySize, TChar > &other) const
Compares two strings.
Definition StaticString.h:1426
int compare(size_type pos, size_type count, const_pointer str) const
Compares two strings.
Definition StaticString.h:1464
size_type max_size() const
Returns the maximum number of characters.
Definition StaticString.h:1191
size_type find_first_not_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first absence of characters.
Definition StaticString.h:1754
value_type * pointer
Pointer to single character.
Definition StaticString.h:804
iterator erase(const_iterator pos)
Removes characters.
Definition StaticString.h:1310
reference back()
Accesses the last character.
Definition StaticString.h:1056
void resize(size_type count)
Changes the number of characters stored.
Definition StaticString.h:1642
StaticString & operator=(const StaticString &other)
Copy assignment.
Definition StaticString.h:899
size_type find_first_of(const StaticString< TAnySize, TChar > &str, size_type pos=0) const
Find first occurrence of characters.
Definition StaticString.h:1724
size_type capacity() const
returns the number of characters that can be held in currently allocated storage.
Definition StaticString.h:1206
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.