ders::text Class Reference
Represents text or string as sequence of arbitrary characters.
More...
#include <text.hpp>
List of all members.
Detailed Description
Represents text or string as sequence of arbitrary characters.
Definition at line 62 of file text.hpp.
Constructor & Destructor Documentation
ders::text::text |
( |
mem_pool & |
m |
) |
[inline, explicit] |
Definition at line 71 of file text.hpp.
00071 : mp(m) { init(ch_rng(0, 0)); }
Definition at line 72 of file text.hpp.
00072 : mp(m) { init(r); }
ders::text::text |
( |
const text & |
t |
) |
[inline] |
Definition at line 73 of file text.hpp.
00073 : mp(t.mp) { init(ch_rng(t)); }
ders::text::~text |
( |
|
) |
[inline] |
Definition at line 74 of file text.hpp.
00074 { mp.deallocate(buf, resd); }
Member Function Documentation
text& ders::text::operator= |
( |
const text & |
t |
) |
[inline] |
Definition at line 76 of file text.hpp.
00076 { return *this=ch_rng(t); }
Definition at line 63 of file text.cpp.
00064 {
00065 int sz=r.size();
00066 reserve(sz);
00067
00068 memcpy(buf, r.beg, sz);
00069 used=sz;
00070
00071 return *this;
00072 }
Definition at line 74 of file text.cpp.
00075 {
00076 int sz=r.size(), newsz=used+sz;
00077 reserve(newsz);
00078
00079 memcpy(buf+used, r.beg, sz);
00080 used=newsz;
00081
00082 return *this;
00083 }
text & ders::text::append |
( |
char |
byte |
) |
|
Definition at line 85 of file text.cpp.
00086 {
00087 reserve(used+1);
00088 buf[used++]=byte;
00089
00090 return *this;
00091 }
int ders::text::size |
( |
|
) |
const [inline] |
int ders::text::capacity |
( |
|
) |
const [inline] |
void ders::text::reserve |
( |
int |
sz |
) |
|
Definition at line 93 of file text.cpp.
00094 {
00095 assert(sz>=0);
00096
00097 sz++;
00098 if (sz<=resd) return;
00099 if (resd*2>sz) sz=resd*2;
00100
00101 char* newbuf=static_cast<char*>(mp.allocate(sz));
00102 memcpy(newbuf, buf, used);
00103
00104 mp.deallocate(buf, resd);
00105 buf=newbuf;
00106 resd=sz;
00107 }
void ders::text::clear |
( |
|
) |
[inline] |
void ders::text::uninitialized_resize |
( |
int |
sz |
) |
|
Definition at line 109 of file text.cpp.
00110 {
00111 assert(sz>=0);
00112
00113 reserve(sz);
00114 used=sz;
00115 }
char* ders::text::begin |
( |
|
) |
[inline] |
const char* ders::text::begin |
( |
|
) |
const [inline] |
char* ders::text::end |
( |
|
) |
[inline] |
Definition at line 91 of file text.hpp.
00091 { return buf+used; }
const char* ders::text::end |
( |
|
) |
const [inline] |
Definition at line 92 of file text.hpp.
00092 { return buf+used; }
const char * ders::text::c_str |
( |
|
) |
const |
Definition at line 117 of file text.cpp.
00118 {
00119 assert(resd>used);
00120 buf[used]=0;
00121
00122 return buf;
00123 }
char& ders::text::front |
( |
|
) |
[inline] |
char ders::text::front |
( |
|
) |
const [inline] |
char& ders::text::back |
( |
|
) |
[inline] |
Definition at line 98 of file text.hpp.
00098 { return *(end()-1); }
char ders::text::back |
( |
|
) |
const [inline] |
Definition at line 99 of file text.hpp.
00099 { return *(end()-1); }
char * ders::text::find |
( |
char |
ch |
) |
|
const char * ders::text::find |
( |
char |
ch |
) |
const [inline] |
char * ders::text::rfind |
( |
char |
ch |
) |
|
const char * ders::text::rfind |
( |
char |
ch |
) |
const [inline] |
char * ders::text::find |
( |
const ch_rng & |
r |
) |
|
Definition at line 137 of file text.cpp.
00138 {
00139 char* ptr=(char*)mem_find(begin(), size(), r.beg, r.size());
00140 return ptr ? ptr : end();
00141 }
const char * ders::text::find |
( |
const ch_rng & |
r |
) |
const [inline] |
char * ders::text::rfind |
( |
const ch_rng & |
r |
) |
|
const char * ders::text::rfind |
( |
const ch_rng & |
r |
) |
const [inline] |
bool ders::text::starts |
( |
const ch_rng & |
r |
) |
const |
Definition at line 149 of file text.cpp.
00150 {
00151 int sz=r.size();
00152 return size()>=sz && memcmp(begin(), r.beg, sz)==0;
00153 }
bool ders::text::ends |
( |
const ch_rng & |
r |
) |
const |
Definition at line 155 of file text.cpp.
00156 {
00157 int sz=r.size();
00158 return size()>=sz && memcmp(end()-sz, r.beg, sz)==0;
00159 }
The documentation for this class was generated from the following files: