blob: d04010e9353c20a9cf4bac6b386c915df6ea9bcb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
\hypertarget{classString}{}\doxysection{String Class Reference}
\label{classString}\index{String@{String}}
A dynamically-\/allocated C-\/style string with extra features.
{\ttfamily \#include $<$String.\+h$>$}
\doxysubsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item
\mbox{\hyperlink{classString_ad3d65397e27bb3c4db1295208cfb1559}{String}} (unsigned length)
\begin{DoxyCompactList}\small\item\em The underlying array is allocated with length (+ 1) size. \end{DoxyCompactList}\item
\mbox{\hyperlink{classString_a3fba40cf6cb11735ffddc355a5ff68f4}{String}} (const char $\ast$str)
\begin{DoxyCompactList}\small\item\em Copies str. \end{DoxyCompactList}\item
\mbox{\Hypertarget{classString_a3d7f953737f3d4dca72d1cc4836f7dcc}\label{classString_a3d7f953737f3d4dca72d1cc4836f7dcc}}
const char $\ast$ {\bfseries get\+\_\+cstr} () const
\begin{DoxyCompactList}\small\item\em Returns internal C-\/style string. \end{DoxyCompactList}\item
\mbox{\Hypertarget{classString_a7793a7e9a7601d4c724dcc85566259bf}\label{classString_a7793a7e9a7601d4c724dcc85566259bf}}
unsigned {\bfseries get\+\_\+length} () const
\begin{DoxyCompactList}\small\item\em Returns number of characters in string. \end{DoxyCompactList}\item
\mbox{\Hypertarget{classString_a5d3b77a51619a8580a373d2cd1092a54}\label{classString_a5d3b77a51619a8580a373d2cd1092a54}}
char \& {\bfseries operator\mbox{[}$\,$\mbox{]}} (unsigned index)
\begin{DoxyCompactList}\small\item\em Returns a character reference (from the underlying C-\/style string) at the given index. \end{DoxyCompactList}\item
\mbox{\hyperlink{classString}{String}} \& \mbox{\hyperlink{classString_a64de9ab1af5df9397f8fbd8c79d5f4b6}{operator+=}} (const char $\ast$str)
\begin{DoxyCompactList}\small\item\em Appends a C-\/style string. \end{DoxyCompactList}\item
\mbox{\hyperlink{classString}{String}} \& \mbox{\hyperlink{classString_a0a96f034ca01cc9fbb27e17330c66ca1}{operator+=}} (int number)
\begin{DoxyCompactList}\small\item\em Appends a number. \end{DoxyCompactList}\item
\mbox{\hyperlink{classString}{String}} \& \mbox{\hyperlink{classString_aed8480111703abc1f281148c778b0445}{operator+=}} (unsigned number)
\begin{DoxyCompactList}\small\item\em Appends a number. \end{DoxyCompactList}\item
\mbox{\hyperlink{classString}{String}} \& \mbox{\hyperlink{classString_a2e4c8591498da08d8ffe206fc45f62a5}{operator+=}} (double number)
\begin{DoxyCompactList}\small\item\em Appends a number. \end{DoxyCompactList}\item
\mbox{\Hypertarget{classString_afc158dffcdf56e601bd640cbacdfcd3c}\label{classString_afc158dffcdf56e601bd640cbacdfcd3c}}
{\bfseries String} (const \mbox{\hyperlink{classString}{String}} \&other)
\item
\mbox{\Hypertarget{classString_a734f34a0b7a42bcad30c368d6e8c5469}\label{classString_a734f34a0b7a42bcad30c368d6e8c5469}}
\mbox{\hyperlink{classString}{String}} \& {\bfseries operator=} (const \mbox{\hyperlink{classString}{String}} \&other)
\item
\mbox{\Hypertarget{classString_a553fcc11563b3d0f5c020309e8b68843}\label{classString_a553fcc11563b3d0f5c020309e8b68843}}
{\bfseries String} (\mbox{\hyperlink{classString}{String}} \&\&other)
\item
\mbox{\Hypertarget{classString_a3c0ede83ee25c89959a0c4369166d98a}\label{classString_a3c0ede83ee25c89959a0c4369166d98a}}
\mbox{\hyperlink{classString}{String}} \& {\bfseries operator=} (\mbox{\hyperlink{classString}{String}} \&\&other)
\item
void \mbox{\hyperlink{classString_ad76bb9eca15651c67332808cdaad6344}{read}} (std\+::istream \&istr)
\begin{DoxyCompactList}\small\item\em Reads \mbox{\hyperlink{classString}{String}} from stream. \end{DoxyCompactList}\item
void \mbox{\hyperlink{classString_a7b0ea809587c21bc1d2b87bfee53e628}{write}} (std\+::ostream \&ostr) const
\begin{DoxyCompactList}\small\item\em Writes \mbox{\hyperlink{classString}{String}} to stream. \end{DoxyCompactList}\item
int \mbox{\hyperlink{classString_a3f420d69fbe3de91711dc69148d23cc7}{compare}} (const \mbox{\hyperlink{classString}{String}} \&other) const
\begin{DoxyCompactList}\small\item\em Compares two strings. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Friends}
\begin{DoxyCompactItemize}
\item
std\+::istream \& \mbox{\hyperlink{classString_a145347940875a9da605f74c2138be157}{operator$>$$>$}} (std\+::istream \&istr, \mbox{\hyperlink{classString}{String}} \&str)
\begin{DoxyCompactList}\small\item\em Reads \mbox{\hyperlink{classString}{String}} from stream with \texorpdfstring{$>$}{>}\texorpdfstring{$>$}{>} operator. \end{DoxyCompactList}\item
std\+::ostream \& \mbox{\hyperlink{classString_aaf68eeb5ffc0983ecc68d49085e33102}{operator$<$$<$}} (std\+::ostream \&ostr, const \mbox{\hyperlink{classString}{String}} \&str)
\begin{DoxyCompactList}\small\item\em Writes \mbox{\hyperlink{classString}{String}} to stream with \texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} operator. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection{Detailed Description}
A dynamically-\/allocated C-\/style string with extra features.
\begin{DoxyRemark}{Remarks}
There is no buffer allocation, meaning each \mbox{\hyperlink{classString}{String}} takes only the amount of memory it needs and every append operation juggles around memory.
\end{DoxyRemark}
\doxysubsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{classString_ad3d65397e27bb3c4db1295208cfb1559}\label{classString_ad3d65397e27bb3c4db1295208cfb1559}}
\index{String@{String}!String@{String}}
\index{String@{String}!String@{String}}
\doxysubsubsection{\texorpdfstring{String()}{String()}\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily String\+::\+String (\begin{DoxyParamCaption}\item[{unsigned}]{length }\end{DoxyParamCaption})}
The underlying array is allocated with length (+ 1) size.
Allocated with length + 1 size, so there is a terminating zero at the end. \mbox{\Hypertarget{classString_a3fba40cf6cb11735ffddc355a5ff68f4}\label{classString_a3fba40cf6cb11735ffddc355a5ff68f4}}
\index{String@{String}!String@{String}}
\index{String@{String}!String@{String}}
\doxysubsubsection{\texorpdfstring{String()}{String()}\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily String\+::\+String (\begin{DoxyParamCaption}\item[{const char $\ast$}]{str }\end{DoxyParamCaption})}
Copies str.
\textbackslash{}params str C-\/style string
\doxysubsection{Member Function Documentation}
\mbox{\Hypertarget{classString_a3f420d69fbe3de91711dc69148d23cc7}\label{classString_a3f420d69fbe3de91711dc69148d23cc7}}
\index{String@{String}!compare@{compare}}
\index{compare@{compare}!String@{String}}
\doxysubsubsection{\texorpdfstring{compare()}{compare()}}
{\footnotesize\ttfamily int String\+::compare (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{classString}{String}} \&}]{other }\end{DoxyParamCaption}) const}
Compares two strings.
\textbackslash{}params other C-\/style string \begin{DoxyReturn}{Returns}
strcmp between underlying C-\/style string and \char`\"{}other\char`\"{}
\end{DoxyReturn}
\mbox{\Hypertarget{classString_a64de9ab1af5df9397f8fbd8c79d5f4b6}\label{classString_a64de9ab1af5df9397f8fbd8c79d5f4b6}}
\index{String@{String}!operator+=@{operator+=}}
\index{operator+=@{operator+=}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator+=()}{operator+=()}\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classString}{String}} \& String\+::operator+= (\begin{DoxyParamCaption}\item[{const char $\ast$}]{str }\end{DoxyParamCaption})}
Appends a C-\/style string.
\textbackslash{}params str C-\/style string \mbox{\Hypertarget{classString_a2e4c8591498da08d8ffe206fc45f62a5}\label{classString_a2e4c8591498da08d8ffe206fc45f62a5}}
\index{String@{String}!operator+=@{operator+=}}
\index{operator+=@{operator+=}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator+=()}{operator+=()}\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classString}{String}} \& String\+::operator+= (\begin{DoxyParamCaption}\item[{double}]{number }\end{DoxyParamCaption})}
Appends a number.
Converts the number to a C-\/style string and then uses += to append it. \mbox{\Hypertarget{classString_a0a96f034ca01cc9fbb27e17330c66ca1}\label{classString_a0a96f034ca01cc9fbb27e17330c66ca1}}
\index{String@{String}!operator+=@{operator+=}}
\index{operator+=@{operator+=}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator+=()}{operator+=()}\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classString}{String}} \& String\+::operator+= (\begin{DoxyParamCaption}\item[{int}]{number }\end{DoxyParamCaption})}
Appends a number.
Converts the number to a C-\/style string and then uses += to append it. \mbox{\Hypertarget{classString_aed8480111703abc1f281148c778b0445}\label{classString_aed8480111703abc1f281148c778b0445}}
\index{String@{String}!operator+=@{operator+=}}
\index{operator+=@{operator+=}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator+=()}{operator+=()}\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily \mbox{\hyperlink{classString}{String}} \& String\+::operator+= (\begin{DoxyParamCaption}\item[{unsigned}]{number }\end{DoxyParamCaption})}
Appends a number.
Converts the number to a C-\/style string and then uses += to append it. \mbox{\Hypertarget{classString_ad76bb9eca15651c67332808cdaad6344}\label{classString_ad76bb9eca15651c67332808cdaad6344}}
\index{String@{String}!read@{read}}
\index{read@{read}!String@{String}}
\doxysubsubsection{\texorpdfstring{read()}{read()}}
{\footnotesize\ttfamily void String\+::read (\begin{DoxyParamCaption}\item[{std\+::istream \&}]{istr }\end{DoxyParamCaption})}
Reads \mbox{\hyperlink{classString}{String}} from stream.
\begin{DoxyParams}{Parameters}
{\em istr} & An input stream\\
\hline
\end{DoxyParams}
Directly reads bytes from stream (calls \mbox{\hyperlink{classString_ad76bb9eca15651c67332808cdaad6344}{read()}} function). First reads the string length, then the underlying C-\/style string (including terminating zero).
\begin{DoxyRemark}{Remarks}
Doesn\textquotesingle{}t alter the stream in any other way.
\end{DoxyRemark}
\begin{DoxyNote}{Note}
Best used with binary ifstream
\end{DoxyNote}
\mbox{\Hypertarget{classString_a7b0ea809587c21bc1d2b87bfee53e628}\label{classString_a7b0ea809587c21bc1d2b87bfee53e628}}
\index{String@{String}!write@{write}}
\index{write@{write}!String@{String}}
\doxysubsubsection{\texorpdfstring{write()}{write()}}
{\footnotesize\ttfamily void String\+::write (\begin{DoxyParamCaption}\item[{std\+::ostream \&}]{ostr }\end{DoxyParamCaption}) const}
Writes \mbox{\hyperlink{classString}{String}} to stream.
\begin{DoxyParams}{Parameters}
{\em ostr} & An output stream\\
\hline
\end{DoxyParams}
Directly writes bytes to stream (calls \mbox{\hyperlink{classString_a7b0ea809587c21bc1d2b87bfee53e628}{write()}} function). First writes the string length, then the underlying C-\/style string (including terminating zero).
\begin{DoxyRemark}{Remarks}
Doesn\textquotesingle{}t alter the stream in any other way.
\end{DoxyRemark}
\begin{DoxyNote}{Note}
Best used with binary ofstream
\end{DoxyNote}
\doxysubsection{Friends And Related Function Documentation}
\mbox{\Hypertarget{classString_aaf68eeb5ffc0983ecc68d49085e33102}\label{classString_aaf68eeb5ffc0983ecc68d49085e33102}}
\index{String@{String}!operator$<$$<$@{operator$<$$<$}}
\index{operator$<$$<$@{operator$<$$<$}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator$<$$<$}{operator<<}}
{\footnotesize\ttfamily std\+::ostream \& operator$<$$<$ (\begin{DoxyParamCaption}\item[{std\+::ostream \&}]{ostr, }\item[{const \mbox{\hyperlink{classString}{String}} \&}]{str }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}
Writes \mbox{\hyperlink{classString}{String}} to stream with \texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} operator.
Uses the stream\textquotesingle{}s \texorpdfstring{$<$}{<}\texorpdfstring{$<$}{<} operator to write the underlying C-\/style string
\begin{DoxyNote}{Note}
Best used with std\+::cout or text std\+::ofstream
\end{DoxyNote}
\mbox{\Hypertarget{classString_a145347940875a9da605f74c2138be157}\label{classString_a145347940875a9da605f74c2138be157}}
\index{String@{String}!operator$>$$>$@{operator$>$$>$}}
\index{operator$>$$>$@{operator$>$$>$}!String@{String}}
\doxysubsubsection{\texorpdfstring{operator$>$$>$}{operator>>}}
{\footnotesize\ttfamily std\+::istream \& operator$>$$>$ (\begin{DoxyParamCaption}\item[{std\+::istream \&}]{istr, }\item[{\mbox{\hyperlink{classString}{String}} \&}]{str }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [friend]}}
Reads \mbox{\hyperlink{classString}{String}} from stream with \texorpdfstring{$>$}{>}\texorpdfstring{$>$}{>} operator.
Uses the stream\textquotesingle{}s getline function to read the data.
\begin{DoxyWarning}{Warning}
It takes at most 1024 characters from the stream!
\end{DoxyWarning}
\begin{DoxyNote}{Note}
Best used with std\+::cin or text std\+::ifstream
\end{DoxyNote}
The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item
src/\+Generic/\+String/\mbox{\hyperlink{String_8h}{String.\+h}}\item
src/\+Generic/\+String/String.\+cpp\end{DoxyCompactItemize}
|