A chunk of read only memory. More...
#include <TsBuffer.h>
Public Types | |
typedef ConstBuffer | self |
Self reference type. | |
typedef bool(self::* | pseudo_bool )() const |
Public Member Functions | |
ConstBuffer () | |
Default constructor (empty buffer). | |
ConstBuffer (char const *ptr, size_t n) | |
Construct from pointer and size. | |
ConstBuffer (char const *start, char const *end) | |
Construct from two pointers. | |
ConstBuffer (Buffer const &buffer) | |
Construct from writable buffer. | |
bool | operator== (self const &that) const |
Equality. | |
bool | operator== (Buffer const &that) const |
Equality. | |
bool | operator!= (self const &that) const |
Inequality. | |
bool | operator!= (Buffer const &that) const |
Inequality. | |
self & | operator= (Buffer const &that) |
Assign from non-const Buffer. | |
char | operator* () const |
self & | operator++ () |
Discard the first character in the buffer. | |
self & | operator+= (size_t n) |
Discard the first n characters. | |
bool | operator! () const |
Check for empty buffer. | |
operator pseudo_bool () const | |
Check for non-empty buffer. | |
bool | contains (char const *p) const |
self & | set (char const *ptr, size_t n=0) |
Set the chunk. | |
self & | set (char const *start, char const *end) |
Set from 2 pointers. | |
self & | reset () |
Reset to empty. | |
char const * | find (char c) const |
Find a character. | |
self | splitOn (char const *p) |
Split the buffer on the character at p. | |
self | splitOn (char c) |
Split the buffer on the character c. | |
self | after (char const *p) const |
Get a trailing segment of the buffer. | |
self | after (char c) const |
Get a trailing segment of the buffer. | |
self & | clip (char const *p) |
Remove trailing segment. | |
Accessors. | |
char const * | data () const |
Get the data in the buffer. | |
size_t | size () const |
Get the size of the buffer. | |
char | operator[] (int n) const |
Access a character (no bounds check). | |
Data Fields | |
char const * | _ptr |
Pointer to base of memory chunk. | |
size_t | _size |
Size of memory chunk. |
A chunk of read only memory.
A convenience class because we pass this kind of pair frequently.
Definition at line 131 of file TsBuffer.h.
typedef bool(self::* ts::ConstBuffer::pseudo_bool)() const |
Definition at line 133 of file TsBuffer.h.
typedef ConstBuffer ts::ConstBuffer::self |
Self reference type.
Definition at line 132 of file TsBuffer.h.
ts::ConstBuffer::ConstBuffer | ( | ) | [inline] |
Default constructor (empty buffer).
Definition at line 322 of file TsBuffer.h.
ts::ConstBuffer::ConstBuffer | ( | char const * | ptr, | |
size_t | n | |||
) | [inline] |
Construct from pointer and size.
ptr | Pointer to buffer. | |
n | Size of buffer. |
Definition at line 323 of file TsBuffer.h.
ts::ConstBuffer::ConstBuffer | ( | char const * | start, | |
char const * | end | |||
) | [inline] |
Construct from two pointers.
start | First valid character. | |
end | First invalid character. |
Definition at line 324 of file TsBuffer.h.
ts::ConstBuffer::ConstBuffer | ( | Buffer const & | buffer | ) | [inline] |
Construct from writable buffer.
buffer | Buffer to copy. |
Definition at line 325 of file TsBuffer.h.
ConstBuffer ts::ConstBuffer::after | ( | char const * | p | ) | const [inline] |
Get a trailing segment of the buffer.
Definition at line 383 of file TsBuffer.h.
References _ptr, _size, and contains().
Referenced by after(), and ats_ip_parse().
ConstBuffer ts::ConstBuffer::after | ( | char | c | ) | const [inline] |
Get a trailing segment of the buffer.
Definition at line 386 of file TsBuffer.h.
ConstBuffer & ts::ConstBuffer::clip | ( | char const * | p | ) | [inline] |
Remove trailing segment.
Data at p and beyond is removed from the buffer. If p is not in the buffer, no change is made.
Definition at line 389 of file TsBuffer.h.
References _ptr, _size, and contains().
Referenced by ats_ip_parse().
bool ts::ConstBuffer::contains | ( | char const * | p | ) | const [inline] |
true
if p points at a character in this. Definition at line 360 of file TsBuffer.h.
Referenced by after(), clip(), MIMEHdr::get_host_port_values(), and splitOn().
char const * ts::ConstBuffer::data | ( | ) | const [inline] |
Get the data in the buffer.
Definition at line 357 of file TsBuffer.h.
References _ptr.
Referenced by ats_ip_check_characters(), ats_ip_getbestaddrinfo(), ats_ip_parse(), ats_ip_pton(), Ink_Inet(), and LogHost::set_name_or_ipstr().
char const * ts::ConstBuffer::find | ( | char | c | ) | const [inline] |
Find a character.
NULL
if c is not found. Definition at line 375 of file TsBuffer.h.
Referenced by after(), ats_ip_parse(), ats_ip_pton(), and splitOn().
ts::ConstBuffer::operator pseudo_bool | ( | ) | const [inline] |
Check for non-empty buffer.
true
if the buffer has a non-zero pointer and size. Definition at line 345 of file TsBuffer.h.
bool ts::ConstBuffer::operator! | ( | ) | const [inline] |
Check for empty buffer.
true
if the buffer has a zero pointer or size. Definition at line 344 of file TsBuffer.h.
bool ts::ConstBuffer::operator!= | ( | Buffer const & | that | ) | const [inline] |
Inequality.
true
if that does not refer to the same memory as this, false
otherwise. Definition at line 336 of file TsBuffer.h.
bool ts::ConstBuffer::operator!= | ( | self const & | that | ) | const [inline] |
Inequality.
true
if that does not refer to the same memory as this, false
otherwise. Definition at line 335 of file TsBuffer.h.
char ts::ConstBuffer::operator* | ( | ) | const [inline] |
Definition at line 346 of file TsBuffer.h.
References _ptr.
ConstBuffer & ts::ConstBuffer::operator++ | ( | ) | [inline] |
Discard the first character in the buffer.
Definition at line 347 of file TsBuffer.h.
ConstBuffer & ts::ConstBuffer::operator+= | ( | size_t | n | ) | [inline] |
ConstBuffer & ts::ConstBuffer::operator= | ( | Buffer const & | that | ) | [inline] |
Assign from non-const Buffer.
that | Source buffer. |
Definition at line 340 of file TsBuffer.h.
References ts::Buffer::_ptr, _ptr, ts::Buffer::_size, and _size.
bool ts::ConstBuffer::operator== | ( | Buffer const & | that | ) | const [inline] |
Equality.
true
if that refers to the same memory as this, false
otherwise. Definition at line 341 of file TsBuffer.h.
References ts::Buffer::_ptr, _ptr, ts::Buffer::_size, and _size.
bool ts::ConstBuffer::operator== | ( | self const & | that | ) | const [inline] |
Equality.
true
if that refers to the same memory as this, false
otherwise. Definition at line 337 of file TsBuffer.h.
char ts::ConstBuffer::operator[] | ( | int | n | ) | const [inline] |
ConstBuffer & ts::ConstBuffer::reset | ( | ) | [inline] |
Reset to empty.
Definition at line 334 of file TsBuffer.h.
Referenced by ats_ip_parse(), and ts::config::Path::Parser::parse().
ConstBuffer & ts::ConstBuffer::set | ( | char const * | ptr, | |
size_t | n = 0 | |||
) | [inline] |
Set the chunk.
Any previous values are discarded.
this
object. Definition at line 326 of file TsBuffer.h.
Referenced by ats_ip_getbestaddrinfo(), ats_ip_pton(), ts::config::Path::Parser::parse(), and url_parse_internet().
ConstBuffer & ts::ConstBuffer::set | ( | char const * | start, | |
char const * | end | |||
) | [inline] |
Set from 2 pointers.
start | First valid character. | |
end | First invalid character. |
Definition at line 328 of file TsBuffer.h.
size_t ts::ConstBuffer::size | ( | void | ) | const [inline] |
Get the size of the buffer.
Definition at line 359 of file TsBuffer.h.
References _size.
Referenced by ats_ip_check_characters(), ats_ip_getbestaddrinfo(), ats_ip_pton(), Ink_Inet(), and LogHost::set_name_or_ipstr().
ConstBuffer ts::ConstBuffer::splitOn | ( | char | c | ) | [inline] |
Split the buffer on the character c.
The buffer is split in to two parts and the occurrence of c is discarded. this retains all data after c. The initial part of the buffer is returned. Neither buffer will contain the first occurrence of c.
This is convenient when tokenizing and c is the token separator.
Definition at line 379 of file TsBuffer.h.
ConstBuffer ts::ConstBuffer::splitOn | ( | char const * | p | ) | [inline] |
Split the buffer on the character at p.
The buffer is split in to two parts and the character at p is discarded. this retains all data after p. The initial part of the buffer is returned. Neither buffer will contain the character at p.
This is convenient when tokenizing and p points at the token separator.
find
and check for an empty buffer returned to detect no more separators.Definition at line 364 of file TsBuffer.h.
References _ptr, _size, and contains().
Referenced by ats_ip_parse(), MIMEHdr::get_host_port_values(), and splitOn().
char const* ts::ConstBuffer::_ptr |
Pointer to base of memory chunk.
Definition at line 135 of file TsBuffer.h.
Referenced by after(), clip(), contains(), data(), ts::config::Value::find(), find(), MIMEHdr::get_host_port_values(), ts::config::Path::Parser::hasInput(), operator pseudo_bool(), operator!(), operator*(), operator++(), operator+=(), operator<<(), operator=(), operator==(), ts::Buffer::operator==(), operator[](), reset(), set(), splitOn(), and url_parse_internet().
size_t ts::ConstBuffer::_size |
Size of memory chunk.
Definition at line 136 of file TsBuffer.h.
Referenced by after(), clip(), contains(), ts::config::Value::find(), find(), MIMEHdr::get_host_port_values(), ts::config::Path::Parser::hasInput(), operator pseudo_bool(), operator!(), operator++(), operator+=(), operator<<(), operator=(), operator==(), ts::Buffer::operator==(), ts::config::Path::Parser::parse(), reset(), set(), size(), splitOn(), and url_parse_internet().