20 #ifndef KERNEL_UTILITIES_STATICCORD_H 21 #define KERNEL_UTILITIES_STATICCORD_H 26 #include "pedigree/kernel/compiler.h" 27 #include "pedigree/kernel/processor/types.h" 28 #include "pedigree/kernel/utilities/template.h" 29 #include "pedigree/kernel/utilities/assert.h" 30 #include "pedigree/kernel/utilities/utility.h" 31 #include "pedigree/kernel/utilities/String.h" 37 template <
unsigned int N>
54 if (index >= cord.m_Segments[segment].length)
60 if (segment > cord.m_NumSegments)
62 segment = cord.m_NumSegments;
78 index = cord.m_Segments[segment].length;
84 char operator*()
const 86 return cord.m_Segments[segment].ptr[index];
91 return segment == other.segment && index == other.index;
96 return !(*
this == other);
102 segment = owner.m_NumSegments;
126 m_Length = other.m_Length;
127 m_NumSegments = other.m_NumSegments;
128 pedigree_std::copy(m_Segments, other.m_Segments, N);
137 size_t length()
const 142 char operator[](
size_t index)
const 145 for (
size_t i = 0; i < m_NumSegments; ++i)
147 if ((index >= offset) && (index < (offset + m_Segments[i].length)))
149 return m_Segments[i].ptr[index - offset];
152 offset += m_Segments[i].length;
160 char *buf =
new char[m_Length + 1];
162 for (
size_t i = 0; i < m_NumSegments; ++i)
164 MemoryCopy(buf + offset, m_Segments[i].ptr, m_Segments[i].length);
165 offset += m_Segments[i].length;
170 String result(buf, m_Length);
175 void append(
const char *s,
size_t len=0)
177 assert(m_NumSegments < N);
181 len = StringLength(s);
202 CordSegment(
const char *s,
size_t len) : ptr(s), length(len) {}
204 const char *ptr =
nullptr;
210 size_t m_NumSegments = 0;
218 #endif // KERNEL_UTILITIES_STATICCORD_H
T operator++(T &x, int)
Global postincrement operator for types with overloaded preincrement operator.
T operator--(T &x, int)
Global postdecrement operator for types with overloaded predecrement operator.
bool operator==(const Iterator< originalT, Struct, FunctionPrev, FunctionNext, T1 > &x1, const Iterator< originalT, Struct, FunctionPrev, FunctionNext, T2 > &x2)
bool operator!=(const T1 &x1, const T2 &x2)
Global != operator for types with overloaded == operator.