#include <StringBuffer.h>
The initial size of the buffer is 256 bytes, but can be overridden at the constructor and/or through the reserve() function call.
Definition at line 38 of file StringBuffer.h.
Public Member Functions | ||||
StringBuffer (size_t initsz=256, const char *initstr=0) | ||||
StringBuffer (const char *fmt,...) | ||||
| ||||
~StringBuffer () | ||||
ExpandableBuffer * | expandable_buf () | |||
| ||||
const char * | data () const | |||
| ||||
char * | data () | |||
| ||||
size_t | length () const | |||
| ||||
const char * | c_str () const | |||
| ||||
size_t | append (const char *str, size_t len=0) | |||
Append the string to the tail of the buffer. | ||||
size_t | append (const std::string &str) | |||
Append the string to the tail of the buffer. | ||||
size_t | append (char c) | |||
Append the character to the tail of the buffer. | ||||
size_t | appendf (const char *fmt,...) | |||
Formatting append function. | ||||
size_t | vappendf (const char *fmt, size_t *lenp, va_list ap) | |||
Formatting append function. | ||||
size_t | append_int (u_int32_t val, int base) | |||
Append an ascii representation of the given integer. | ||||
size_t | append_int (u_int64_t val, int base) | |||
Append an ascii representation of the given integer. | ||||
void | trim (size_t cnt) | |||
Trim cnt characters from the tail of the string. | ||||
void | set_length (size_t len) | |||
Forcibly set the buffer length to len. | ||||
StringBuffer (ExpandableBuffer *buffer, bool own_buf) | ||||
Create a string buffer with an expandable buffer. | ||||
Private Attributes | ||||
ExpandableBuffer * | buf_ | |||
bool | own_buf_ |
oasys::StringBuffer::StringBuffer | ( | size_t | initsz = 256 , |
|
const char * | initstr = 0 | |||
) |
initsz | the initial buffer size | |
initstr | the initial buffer contents |
Definition at line 28 of file StringBuffer.cc.
References append(), ASSERT, buf_, and oasys::ExpandableBuffer::reserve().
oasys::StringBuffer::StringBuffer | ( | const char * | fmt, | |
... | ||||
) |
fmt | the initial buffer contents |
Definition at line 42 of file StringBuffer.cc.
References ASSERT, buf_, oasys::ExpandableBuffer::reserve(), and STRINGBUFFER_VAPPENDF.
oasys::StringBuffer::StringBuffer | ( | ExpandableBuffer * | buffer, | |
bool | own_buf | |||
) |
Create a string buffer with an expandable buffer.
Definition at line 55 of file StringBuffer.cc.
References ASSERT, buf_, and oasys::ExpandableBuffer::reserve().
oasys::StringBuffer::~StringBuffer | ( | ) |
ExpandableBuffer* oasys::StringBuffer::expandable_buf | ( | ) | [inline] |
Definition at line 58 of file StringBuffer.h.
References buf_.
Referenced by oasys::TextMarshal::process().
const char* oasys::StringBuffer::data | ( | ) | const [inline] |
Definition at line 63 of file StringBuffer.h.
References buf_, and oasys::ExpandableBuffer::raw_buf().
Referenced by oasys::SQLTableFormat::append(), c_str(), oasys::MemoryTable::del(), dtn::LinkStateRouter::LSRegistration::deliver_bundle(), oasys::SQLTableFormat::end_action(), oasys::SQLUpdate::end_action(), oasys::SQLInsert::end_action(), dtn::BundleCommand::exec(), oasys::URL::format(), oasys::MemoryTable::get(), dtn::APIClient::handle_send(), oasys::HexDumpBuffer::hexify(), oasys::XMLMarshal::process(), and oasys::MemoryTable::put().
char* oasys::StringBuffer::data | ( | ) | [inline] |
Definition at line 68 of file StringBuffer.h.
References buf_, and oasys::ExpandableBuffer::raw_buf().
size_t oasys::StringBuffer::length | ( | ) | const [inline] |
Definition at line 74 of file StringBuffer.h.
References buf_, and oasys::ExpandableBuffer::len().
Referenced by oasys::SQLTableFormat::append(), oasys::MemoryTable::del(), oasys::StringSerialize::end_action(), oasys::SQLTableFormat::end_action(), oasys::SQLUpdate::end_action(), oasys::SQLInsert::end_action(), oasys::URL::format(), oasys::MemoryTable::get(), oasys::HexDumpBuffer::hexify(), oasys::SQLTableFormat::process(), and oasys::MemoryTable::put().
const char * oasys::StringBuffer::c_str | ( | ) | const |
Definition at line 69 of file StringBuffer.cc.
References oasys::ExpandableBuffer::at(), buf_, data(), oasys::ExpandableBuffer::end(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::nfree(), and oasys::ExpandableBuffer::reserve().
Referenced by dtn::IPDiscovery::configure(), dtn::IPAnnounce::configure(), dtn::PrimaryBlockProcessor::debug_dump_dictionary(), dtn::LoggingRegistration::deliver_bundle(), dtn::RouteCommand::exec(), dtn::RegistrationCommand::exec(), oasys::LogCommand::exec(), dtn::LinkCommand::exec(), dtn::InterfaceCommand::exec(), oasys::HelpCommand::exec(), dtn::DiscoveryCommand::exec(), dtn::BundleCommand::exec(), oasys::InlineFormatter< _T >::format(), dtn::BundleDaemon::handle_bundle_received(), dtn::ProphetEncounter::handle_prophet_tlv(), oasys::TclCommand::help_string(), oasys::PrettyPrintBuf::next_str(), dtn::IPDiscovery::parse_advertisement(), oasys::IO::poll_with_notifier(), oasys::SQLQuery::query(), dtn::ProphetEncounter::send_prophet_tlv(), dtnsim::Connectivity::set_state(), oasys::TclCommandInterp::shutdown(), and oasys::BerkeleyDBStore::~BerkeleyDBStore().
size_t oasys::StringBuffer::append | ( | const char * | str, | |
size_t | len = 0 | |||
) |
Append the string to the tail of the buffer.
str | string data | |
len | string length (if unspecified, will call strlen()) |
Definition at line 86 of file StringBuffer.cc.
References ASSERT, buf_, oasys::ExpandableBuffer::end(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::reserve(), and oasys::ExpandableBuffer::set_len().
Referenced by oasys::TextMarshal::add_indent(), oasys::StringSerialize::add_preamble(), oasys::TclCommand::add_to_help(), oasys::TextCode::append(), append(), dtn::DiscoveryTable::dump(), dtn::ContactManager::dump(), oasys::HelpCommand::exec(), dtn::BundleCommand::exec(), oasys::URL::format(), oasys::InlineFormatter< _T >::format(), oasys::EnumOpt::get(), dtn::EndpointIDOpt::get(), dtn::APIEndpointIDOpt::get(), dtn::TableBasedRouter::get_routing_state(), oasys::HexDumpBuffer::hexify(), dtn::InterfaceTable::list(), oasys::PrettyPrintBuf::next_str(), oasys::StringSerialize::process(), oasys::SQLInsert::process(), StringBuffer(), oasys::TextCode::textcodify(), oasys::TextMarshal::TextMarshal(), oasys::TextUncode::textuncodify(), oasys::XMLObject::to_string(), oasys::XMLDocument::to_string(), and oasys::BerkeleyDBStore::~BerkeleyDBStore().
size_t oasys::StringBuffer::append | ( | const std::string & | str | ) | [inline] |
Append the string to the tail of the buffer.
str | string data |
Definition at line 96 of file StringBuffer.h.
References append().
size_t oasys::StringBuffer::append | ( | char | c | ) |
Append the character to the tail of the buffer.
c | the character |
Definition at line 108 of file StringBuffer.cc.
References buf_, oasys::ExpandableBuffer::end(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::reserve(), and oasys::ExpandableBuffer::set_len().
size_t oasys::StringBuffer::appendf | ( | const char * | fmt, | |
... | ||||
) |
Formatting append function.
fmt | the format string |
Definition at line 172 of file StringBuffer.cc.
References buf_, oasys::ExpandableBuffer::len(), and STRINGBUFFER_VAPPENDF.
Referenced by oasys::TclCommand::add_to_help(), oasys::TextCode::append(), oasys::SQLTableFormat::append(), oasys::SQLTableFormat::begin_action(), oasys::SQLUpdate::begin_action(), oasys::SQLInsert::begin_action(), dtn::PrimaryBlockProcessor::debug_dump_dictionary(), dtn::RouteEntry::dump(), dtn::RegistrationTable::dump(), dtn::ProphetTLV::dump(), dtn::BundleTLV::dump(), dtn::RIBTLV::dump(), dtn::RIBDTLV::dump(), dtn::HelloTLV::dump(), dtn::BaseTLV::dump(), dtn::BundleOffer::dump(), dtn::ProphetNode::dump(), dtn::RIBNode::dump(), dtn::ProphetDictionary::dump(), dtn::Link::dump(), dtn::ForwardingLog::dump(), dtn::DiscoveryTable::dump(), dtn::Discovery::dump(), dtn::ContactManager::dump(), dtn::RouteEntry::dump_header(), dtn::UDPConvergenceLayer::dump_interface(), dtn::TCPConvergenceLayer::dump_interface(), dtn::BluetoothConvergenceLayer::dump_interface(), dtn::UDPConvergenceLayer::dump_link(), dtn::TCPConvergenceLayer::dump_link(), dtn::StreamConvergenceLayer::dump_link(), dtn::ConnectionConvergenceLayer::dump_link(), dtn::BluetoothConvergenceLayer::dump_link(), oasys::Log::dump_rules(), dtn::ProphetEncounter::dump_state(), dtn::ProphetController::dump_state(), dtn::Link::dump_stats(), dtn::LinkStateGraph::dumpGraph(), oasys::HelpCommand::exec(), dtn::BundleCommand::exec(), oasys::TclCommandInterp::exec_file(), oasys::URL::format(), oasys::InlineFormatter< _T >::format(), dtn::Bundle::format_verbose(), oasys::BdAddrOpt::get(), oasys::InAddrOpt::get(), oasys::CharBufOpt::get(), oasys::StringOpt::get(), oasys::DoubleOpt::get(), oasys::UInt8Opt::get(), oasys::UInt16Opt::get(), oasys::UInt64Opt::get(), oasys::UIntOpt::get(), oasys::IntOpt::get(), oasys::BoolOpt::get(), dtn::BundleDaemon::get_bundle_stats(), dtn::BundleDaemon::get_daemon_stats(), dtn::TableBasedRouter::get_routing_state(), dtn::BundleDaemon::handle_bundle_received(), oasys::HexDumpBuffer::hexify(), dtn::InterfaceTable::list(), oasys::IO::poll_with_notifier(), oasys::XMLMarshal::process(), oasys::TextMarshal::process(), oasys::SQLTableFormat::process(), oasys::SQLUpdate::process(), oasys::SQLInsert::process(), oasys::XMLObject::to_string(), dtn::Bundle::validate(), and oasys::BerkeleyDBStore::~BerkeleyDBStore().
size_t oasys::StringBuffer::vappendf | ( | const char * | fmt, | |
size_t * | lenp, | |||
va_list | ap | |||
) |
Formatting append function.
Note that this may not actually format the full string if there's not enough space in the buffer, so the STRINGBUFFER_VAPPENDF macro below should be used in most cases instead.
The lenp parameter can be used to pass in the length that the buffer should be set to (if known) and returns the length of the buffer after formatting. If *lenp is less than the return value, the format string was truncated.
fmt | the format string | |
lenp | length of the underlying buffer | |
ap | the format argument list |
Definition at line 148 of file StringBuffer.cc.
References ASSERT, buf_, oasys::ExpandableBuffer::buf_len(), oasys::ExpandableBuffer::end(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::nfree(), oasys::ExpandableBuffer::reserve(), oasys::ExpandableBuffer::set_len(), and vsnprintf().
size_t oasys::StringBuffer::append_int | ( | u_int32_t | val, | |
int | base | |||
) |
Append an ascii representation of the given integer.
This is the same as calling appendf("%d", val), only faster.
Definition at line 118 of file StringBuffer.cc.
References ASSERT, buf_, oasys::ExpandableBuffer::end(), oasys::fast_ultoa(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::reserve(), and oasys::ExpandableBuffer::set_len().
Referenced by oasys::StringSerialize::process().
size_t oasys::StringBuffer::append_int | ( | u_int64_t | val, | |
int | base | |||
) |
Append an ascii representation of the given integer.
This is the same as calling appendf("%d", val), only faster.
Definition at line 133 of file StringBuffer.cc.
References ASSERT, buf_, oasys::ExpandableBuffer::end(), oasys::fast_ultoa(), oasys::ExpandableBuffer::len(), oasys::ExpandableBuffer::reserve(), and oasys::ExpandableBuffer::set_len().
void oasys::StringBuffer::trim | ( | size_t | cnt | ) | [inline] |
Trim cnt characters from the tail of the string.
Definition at line 154 of file StringBuffer.h.
References ASSERT, buf_, oasys::ExpandableBuffer::len(), and oasys::ExpandableBuffer::set_len().
Referenced by oasys::StringSerialize::end_action(), oasys::HexDumpBuffer::hexify(), and oasys::SQLTableFormat::process().
void oasys::StringBuffer::set_length | ( | size_t | len | ) | [inline] |
Forcibly set the buffer length to len.
Definition at line 163 of file StringBuffer.h.
References ASSERT, buf_, oasys::ExpandableBuffer::buf_len(), and oasys::ExpandableBuffer::set_len().
ExpandableBuffer* oasys::StringBuffer::buf_ [mutable, private] |
Definition at line 170 of file StringBuffer.h.
Referenced by append(), append_int(), appendf(), c_str(), data(), expandable_buf(), length(), set_length(), StringBuffer(), trim(), vappendf(), and ~StringBuffer().
bool oasys::StringBuffer::own_buf_ [private] |