The Pedigree Project
0.1
src
system
include
pedigree
kernel
utilities
Cord.h
1
/*
2
* Copyright (c) 2008-2014, Pedigree Developers
3
*
4
* Please see the CONTRIB file in the root of the source tree for a full
5
* list of contributors.
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*/
19
20
#ifndef KERNEL_UTILITIES_CORD_H
21
#define KERNEL_UTILITIES_CORD_H
22
26
#include "pedigree/kernel/compiler.h"
27
#include "pedigree/kernel/processor/types.h"
28
#include "pedigree/kernel/utilities/Vector.h"
29
#include "pedigree/kernel/utilities/template.h"
// IWYU pragma: keep
30
31
class
String
;
32
33
class
EXPORTED_PUBLIC
Cord
{
34
friend
class
CordIterator
;
35
friend
class
String
;
36
37
struct
CordSegment
;
38
39
public
:
40
class
CordIterator
{
41
friend
class
Cord
;
42
43
public
:
44
CordIterator
(
const
Cord
& owner);
45
virtual
~CordIterator
();
46
47
CordIterator
&
operator++
();
48
CordIterator
&
operator--
();
49
50
char
operator*()
const
;
51
52
bool
operator==
(
const
CordIterator
& other)
const
;
53
bool
operator!=(
const
CordIterator
& other)
const
;
54
55
protected
:
56
CordIterator
(
const
Cord
& owner,
bool
end);
57
58
private
:
59
const
Cord
& cord;
60
size_t
segment;
61
size_t
index;
62
63
const
Cord::CordSegment
* segptr;
64
};
65
class
CordSegmentIterator
{
66
friend
class
Cord
;
67
68
public
:
69
CordSegmentIterator
(
const
Cord
& owner);
70
virtual
~CordSegmentIterator
();
71
72
CordSegmentIterator
&
operator++
();
73
CordSegmentIterator
&
operator--
();
74
75
const
char
* ptr()
const
;
76
size_t
length()
const
;
77
78
bool
operator==
(
const
CordSegmentIterator
& other)
const
;
79
bool
operator!=(
const
CordSegmentIterator
& other)
const
;
80
81
protected
:
82
CordSegmentIterator
(
const
Cord
& owner,
bool
end);
83
84
private
:
85
const
Cord
& cord;
86
size_t
segment;
87
};
88
89
Cord
();
90
Cord
(
const
Cord
& other);
91
virtual
~Cord
();
92
93
Cord
& operator=(
const
Cord
& s);
94
95
bool
operator==
(
const
char
* s)
const
;
96
bool
operator==
(
const
Cord
& s)
const
;
97
bool
operator==
(
const
String
& s)
const
;
98
103
void
reserve(
size_t
segments);
104
105
void
assign(
const
Cord
& other);
106
void
clear();
107
108
size_t
length()
const
;
109
110
String
toString()
const
;
111
112
char
operator[](
size_t
index)
const
;
113
114
void
append(
const
char
* s,
size_t
len = 0);
115
void
prepend(
const
char
* s,
size_t
len = 0);
116
123
void
append(
const
String
& str);
124
void
prepend(
const
String
& str);
125
126
CordIterator
begin()
const
;
127
CordIterator
end()
const
;
128
129
CordSegmentIterator
segbegin()
const
;
130
CordSegmentIterator
segend()
const
;
131
132
private
:
133
struct
CordSegment
{
134
CordSegment
() =
default
;
135
CordSegment
(
const
char
* s,
size_t
len) : ptr(s), length(len) {}
136
137
const
char
* ptr =
nullptr
;
138
size_t
length = 0;
139
};
140
141
Vector<CordSegment>
m_Segments;
142
size_t
m_Length = 0;
143
};
144
147
#endif
// KERNEL_UTILITIES_CORD_H
Cord::CordIterator
Definition
Cord.h:40
Cord::CordSegmentIterator
Definition
Cord.h:65
Cord
Definition
Cord.h:33
String
Definition
String.h:43
Vector
A vector / dynamic array.
Definition
Vector.h:33
operator--
T operator--(T &x, int)
Global postdecrement operator for types with overloaded predecrement operator.
Definition
template.h:53
operator++
T operator++(T &x, int)
Global postincrement operator for types with overloaded preincrement operator.
Definition
template.h:43
operator==
bool operator==(const Iterator< originalT, Struct, FunctionPrev, FunctionNext, T1 > &x1, const Iterator< originalT, Struct, FunctionPrev, FunctionNext, T2 > &x2)
Definition
Iterator.h:256
Cord::CordSegment
Definition
Cord.h:133
Generated on Sat Oct 3 2026 06:38:07 for The Pedigree Project by
1.9.8