LRAUV  revA
Str Class Reference

Replacement for standard template class string. More...

#include <Str.h>

Inheritance diagram for Str:
Collaboration diagram for Str:

Public Member Functions

 Str (const char *str=NULL, size_t length=NO_POS)
 char* constructor Unit tests in Str_Test.testConstructorCharStar More...
 
 Str (const Str &str, const size_t offset=0, size_t count=NO_POS)
 copy constructor Unit tests in Str_Test.testCopyConstructor More...
 
 Str (const bool var)
 bool constructor Unit tests in Str_Test.testBoolConstructor More...
 
 Str (const double var, unsigned int precision=6)
 double constructor Unit tests in Str_Test.testDoubleConstructor More...
 
 Str (const int var, unsigned int radix=10, unsigned int radixOffset=0)
 int constructor Unit tests in Str_Test.testIntConstructor More...
 
 Str (const size_t var, unsigned int radix=16)
 size_t constructor Unit tests in Str_Test.testUnsignedIntConstructor More...
 
virtual ~Str ()
 destructor More...
 
Strset (const char *str=NULL, size_t length=NO_POS)
 
Stroperator= (const char *str)
 
Stroperator= (const Str &str)
 
Stroperator= (const double var)
 
Str substr (const size_t offset, size_t count=NO_POS) const
 
char operator[] (const size_t index) const
 
Stroperator+= (const bool str)
 
Stroperator+= (const unsigned char str)
 
Stroperator+= (const double str)
 
Stroperator+= (const int str)
 
Stroperator+= (const size_t str)
 
Stroperator+= (const char *str)
 
Stroperator+= (const Str &str)
 
Strappend (const Str &str)
 
Strappend (const char *str, size_t length)
 
StrpushBack (const unsigned char str)
 
Stroperator<< (const bool str)
 
Stroperator<< (const unsigned char str)
 
Stroperator<< (const double str)
 
Stroperator<< (const int str)
 
Stroperator<< (const size_t str)
 
Stroperator<< (const char *str)
 
Stroperator<< (const Str &str)
 
bool operator!= (const Str &str) const
 
bool operator!= (const char *str) const
 
int compare (const Str &str) const
 
int compare (const char *str) const
 
bool operator== (const Str &str) const
 
bool operator== (const char *str) const
 
bool operator< (const Str &str) const
 
const char * cStr () const
 
const char * data () const
 
size_t length () const
 
size_t size () const
 
size_t findLastOf (const unsigned char str) const
 returns the position of the specified character in the string, looking from the end of the string towards the beginning. More...
 
size_t findLastOf (const char *str) const
 returns the position of the specified character string in the string, looking from the end of the string towards the beginning. More...
 
size_t find (const unsigned char str, size_t offset=0) const
 
size_t find (const char *str, size_t offset=0) const
 
size_t find (const Str &str, size_t offset=0) const
 
bool startsWith (const char *str, size_t length=NO_POS) const
 
bool startsWith (const Str &str) const
 
bool endsWith (const Str &str) const
 
bool setChar (size_t index, const unsigned char theChar)
 
void replaceChar (const char replace, const char replaceWith)
 
Strsplit (int &num, const char *splitSpec, size_t length=NO_POS) const
 
Strsplit (int &num, const Str str) const
 
Str asHex () const
 Return a new Str, with a hex representation of each character of this string. More...
 

Static Public Member Functions

static size_t FindLastOf (const char *str, const unsigned char theChar, size_t length=NO_POS)
 
static size_t Find (const char *str, const unsigned char theChar, size_t length=NO_POS)
 
static unsigned int IntToAscii (int value, char *str, unsigned int base, unsigned int bufSize, unsigned int baseOffset=0)
 convert an integer to a string, returns the length of the string Unit tests in Str_Test.testIntToAscii More...
 

Static Public Attributes

static const size_t NO_POS
 static constants More...
 
static const size_t MAX_LEN
 
static const Str EMPTY_STR
 
static char NoChars_ [1] = ""
 

Protected Member Functions

virtual void intoString (const double var, unsigned int precision=10)
 
virtual void intoString (int var, unsigned int radix, unsigned int radixOffset=0)
 

Protected Attributes

size_t length_
 
char * chars_
 

Friends

Str operator+ (const char *var, const Str &str)
 
Str operator+ (const Str &var, const Str &str)
 

Detailed Description

Replacement for standard template class string.

Todo:
share strings to reduce mallocs

Constructor & Destructor Documentation

Str::Str ( const char *  str = NULL,
size_t  length = NO_POS 
)
Str::Str ( const Str str,
const size_t  offset = 0,
size_t  count = NO_POS 
)

copy constructor Unit tests in Str_Test.testCopyConstructor

References chars_, length_, and NO_POS.

Str::Str ( const bool  var)

bool constructor Unit tests in Str_Test.testBoolConstructor

References chars_.

Str::Str ( const double  var,
unsigned int  precision = 6 
)
inline

double constructor Unit tests in Str_Test.testDoubleConstructor

References intoString().

Str::Str ( const int  var,
unsigned int  radix = 10,
unsigned int  radixOffset = 0 
)
inline

int constructor Unit tests in Str_Test.testIntConstructor

References intoString().

Str::Str ( const size_t  var,
unsigned int  radix = 16 
)
inline

size_t constructor Unit tests in Str_Test.testUnsignedIntConstructor

References intoString().

Str::~Str ( )
virtual

destructor

References chars_, and NoChars_.

Member Function Documentation

Str& Str::append ( const Str str)
inline

References Str().

Referenced by TextTableLogWriter::TextTableLogWriter().

Str& Str::append ( const char *  str,
size_t  length 
)
inline

References Str().

Str Str::asHex ( ) const

Return a new Str, with a hex representation of each character of this string.

References chars_, and length_.

Referenced by Str_Test::testAsHex().

int Str::compare ( const Str str) const
int Str::compare ( const char *  str) const

References chars_, length_, and NoChars_.

const char* Str::cStr ( ) const
inline

References chars_.

Referenced by ESPComm::acceptClient(), NetCdfWriter::addDim(), NavChartDb::addEncData(), NetCdfWriter::addGroup(), NetCdfWriter::addStaticVar(), Behavior::addValueClause(), NetCdfWriter::addVar(), JsonLogWriter::addVar(), NetCdfTableLogWriter::addVar(), HDF5LogWriter::addVar(), NetCdfLogWriter::addVar(), Rowe_600::appendEnsembleToFile(), NavChartDb::appendToContour(), NavChartDb::appendToSoundings(), LuaNode::asNewDataValue(), ESPClient::checkCmdCompleteTimeout(), ESPClient::checkCmdResultTimeout(), MappedIOStream::close(), FileLogWriter::close(), CommandLine::commandBang(), CommandLine::commandConfigSet(), CommandLine::commandDo(), CommandLine::commandRestartApplication(), CommandLine::commandResume(), CommandLine::commandRetransmit(), CommandLine::commandShowComponent(), CommandLine::commandShowDependencies(), CommandLine::commandShowVariable(), EnvSimulator::configureSensors(), ESPComm::connectAsClient(), ESPClient::consumeResult(), Config::CopyFileToDir(), StrValue::copyTo(), BlobValue::copyTo(), NavChartDb::createContour(), ESPComponent::createESPComm(), NavChartDb::createSoundings(), DataOverHttps::dataRead(), DataOverHttps::dataWrite(), DataOverHttps::dataWriting(), DeviceIOStream::DeviceIOStream(), NavChartDb::doIndexing(), ScheduledItem::DoScheduled(), LzmaEncoder::encode(), ZipEncoder::encode(), FileLogReader::FileLogReader(), FileLogWriter::FileLogWriter(), MissionStateLogger::Filter(), HDF5File::finalize(), Supervisor::GenerateDataDir(), BlobValue::getBytes(), BlobValue::getElement(), DecimationLogManager::getFileWriter(), Supervisor::GetLatestLogFilename(), ESPComponent::getLine(), ESPClient::getLine(), CommandLine::getLines(), MappedIOStream::getName(), DeviceIOStream::getName(), FileInStream::getName(), FileIOStream::getName(), FileOutStream::getName(), LuaNode::getNamedNode(), Supervisor::GetToShoreFilename(), ESPClient::handleException(), HDF5Attribute::HDF5Attribute(), HDF5File::HDF5File(), NavChartDb::initDataDir(), PeakDetectHorizontal::initialize(), PeakDetectVsDepth::initialize(), MissionManager::initialize(), ReadDataComponent::initializeReaders(), Assign::Instance(), SendDataComponent::Instance(), SyslogComponent::Instance(), Config::Instance(), DefineBehavior::Instance(), ESPClient::issueCommand(), Config::LoadConfigFilesInPath(), HFRadarCompactModelForecaster::loadHistory(), SimulatorUtils::LoadInit(), ModuleLoader::loadLibraryModule(), LuaMissionAPI::loadMissionFile(), ModuleLoader::loadModules(), DataOverHttps::loadParams(), MissionManager::LoadRootNode(), MissionStateLogger::LogArgWrite(), main(), FileLogReader::matchAndOpen(), ParsedCommand::matchComponent(), ParsedCommand::matchMission(), Method::Method(), Simulator::motion(), NetCdfTableLogWriter::netCdfInitialize(), NetCdfLogWriter::netCdfInitialize(), Component::newBlobReaderFromUniversal(), LuaNode::newChildFunction(), LuaNode::newChildNode(), Component::newDataReaderFromUniversal(), LuaAPI::NewFunction(), MissionStateLogger::NewResume(), MissionStateLogger::NewRun(), Behavior::newSettingReader(), Component::newUniversalBlobWriter(), FileLogReader::nextFilename(), SplitFileLogWriter::nextFilename(), MappedIOStream::open(), LuaNode::open(), OutStream::operator<<(), ModuleLoader::PathExists(), Config::Persist(), ThreadHandler::PthreadJoinTimeout(), StrIOStream::read(), FileLogReader::read(), AbstractBlobReader::read1DArray(), AbstractBlobReader::read1DPtr(), AbstractBlobReader::read2DArray(), AbstractBlobReader::read2DPtr(), AbstractBlobReader::read3DArray(), AbstractBlobReader::read3DPtr(), BPC1::readConfig(), ESPComm::readLine(), NetCdfReader::readStr(), ValueClause::ReadStrValueUri(), FileLogWriter::resetFilename(), MissionManager::resumeLoadedMission(), NAL9602::retrieveAndQueueIncoming(), NavChartDb::run(), HFRadarModelCalc::run(), DataOverHttps::run(), Unserialize::Run(), Execute::runIfUnsatisfied(), NavChartDb::saveEncs(), EncReader::scan(), ESPComponent::scanEspServerPort(), NAL9602::sendingFillBuffer(), NAL9602::sendingVerify(), MissionStateLogger::SetActive(), NetCdfWriter::setAttValue(), BlobValue::setElement(), BlobValue::setFrom(), MissionStateLogger::SetRepeatIndex(), MultiHandler::shutdown(), SplitFileLogWriter::split(), ESPComponent::starting(), Rowe_600LCM::starting(), ESPComponent::startPPP(), startsWith(), ESPComm::submitAbort(), Logger::syslog(), DataOverHttps::tcpConnect(), Str_Test::testAsHex(), Str_Test::testBoolConstructor(), Str_Test::testConstructorCharStar(), Str_Test::testCopyConstructor(), Str_Test::testDoubleConstructor(), Str_Test::testIntConstructor(), CommandLine_Test::testParse(), FastMap_Test::testPutGetAndSizeNoDuplicatesDynamic(), CodedStr_Test::testRead(), ElementURI_Test::testRead(), StrValue_Test::testSetFrom(), Str_Test::testSizeTConstructor(), StrValue::toStream(), UartStream::uartIdToString(), UartStream::uartToDevice(), NavChartDb::updateClosest(), CodedStr::write(), MultiLogWriter::write(), TextLogWriter::write(), SplitFileLogWriter::write(), ElementURI::write(), AbstractBlobWriter::write1DArray(), AbstractBlobWriter::write1DPtr(), AbstractBlobWriter::write2DArray(), AbstractBlobWriter::write2DPtr(), AbstractBlobWriter::write3DArray(), AbstractBlobWriter::write3DPtr(), JsonLogWriter::writeData(), HDF5Dataset::writeDataValue(), KmlLogWriter::writeHeader(), NetCdfWriter::writeRecord(), KmlLogWriter::writeSyslogItems(), and NetCdfWriter::writeVarRecord().

const char* Str::data ( ) const
inline

References chars_.

Referenced by SyslogEntry::write().

bool Str::endsWith ( const Str str) const
inline

References find(), and length_.

Referenced by Unserialize::Run().

size_t Str::find ( const char *  str,
size_t  offset = 0 
) const

References chars_, length_, and NO_POS.

size_t Str::find ( const Str str,
size_t  offset = 0 
) const

References chars_, length_, and NO_POS.

size_t Str::Find ( const char *  str,
const unsigned char  theChar,
size_t  length = NO_POS 
)
static

References length(), and NO_POS.

Referenced by is_child().

size_t Str::findLastOf ( const unsigned char  str) const

returns the position of the specified character in the string, looking from the end of the string towards the beginning.

Parameters
strthe character to look for
Returns
the index of the character, or NO_POS if not found

References chars_, length_, and NO_POS.

Referenced by ZipEncoder::encode(), HDF5LogWriter::initializeHDF5LogWriter(), JsonLogWriter::initializeJsonLogWriter(), Config::Instance(), FileLogReader::matchAndOpen(), NetCdfTableLogWriter::netCdfInitialize(), NetCdfLogWriter::netCdfInitialize(), Unserialize::Run(), ValueClause::StripPastLastDot(), and Str_Test::testFindLastOf().

size_t Str::findLastOf ( const char *  str) const

returns the position of the specified character string in the string, looking from the end of the string towards the beginning.

Parameters
strthe character string to look for
Returns
the index of the character, or NO_POS if not found

References chars_, length_, and NO_POS.

size_t Str::FindLastOf ( const char *  str,
const unsigned char  theChar,
size_t  length = NO_POS 
)
static

References length(), and NO_POS.

Referenced by ParsedCommand::matchMission().

void Str::intoString ( const double  var,
unsigned int  precision = 10 
)
protectedvirtual

References chars_, length(), length_, and NoChars_.

Referenced by operator=(), and Str().

void Str::intoString ( int  var,
unsigned int  radix,
unsigned int  radixOffset = 0 
)
protectedvirtual
unsigned int Str::IntToAscii ( int  value,
char *  str,
unsigned int  base,
unsigned int  bufSize,
unsigned int  baseOffset = 0 
)
static

convert an integer to a string, returns the length of the string Unit tests in Str_Test.testIntToAscii

Referenced by intoString(), Str_Test::testIntToAscii(), Str_Test::testIntToAsciiWithOffset(), and OutStream::writeInteger().

size_t Str::length ( ) const
inline

References length_.

Referenced by NetCdfWriter::addAtt(), ElementURI::buildURI(), CommandLine::commandBang(), CommandLine::commandDo(), StrValue::copyTo(), ESPComponent::createESPComm(), DataOverHttps::dataWrite(), StrIOStream::eof(), MissionStateLogger::Filter(), Find(), FindLastOf(), Supervisor::GenerateDataDir(), BlobValue::getByteLength(), BlobValue::getElements(), Aggregate::getItemByRefId(), ESPComponent::getLine(), ESPClient::getLine(), ESPComm::hasEspServerAddressAndPort(), HDF5Attribute::HDF5Attribute(), intoString(), ESPClient::isSuccessfulSampling(), DataOverHttps::loadParams(), Config::LoadPersistedConfigSets(), MissionStateLogger::LogArgWrite(), MissionManager::LogMission(), FileLogReader::matchAndOpen(), ParsedCommand::matchComponent(), ParsedCommand::matchConfigVariable(), ParsedCommand::matchMission(), ParsedCommand::matchUnit(), ParsedCommand::matchUniversal(), ParsedCommand::matchVariable(), MissionStateLogger::NewRun(), OutStream::operator<<(), Config::Persist(), StrIOStream::read(), ESPComm::readLine(), Unserialize::Run(), Execute::runIfUnsatisfied(), NAL9602::sendingFillBuffer(), set(), MissionStateLogger::SetActive(), ESPClient::setError(), StrValue::setFrom(), MissionStateLogger::SetRepeatIndex(), split(), ESPComponent::starting(), startsWith(), ESPComm::submitAbort(), Str_Test::testAsHex(), Str_Test::testBoolConstructor(), Str_Test::testConstructorCharStar(), Str_Test::testCopyConstructor(), Str_Test::testDoubleConstructor(), Str_Test::testIntConstructor(), CommandLine_Test::testParse(), Str_Test::testSizeTConstructor(), StrValue::toStream(), BlobValue::toString(), MultiLogWriter::write(), TextLogWriter::write(), StrIOStream::write(), SyslogEntry::write(), HDF5Dataset::writeDataValue(), and KmlLogWriter::writeSyslogItems().

bool Str::operator!= ( const Str str) const
inline

References compare().

bool Str::operator!= ( const char *  str) const
inline

References compare().

Str& Str::operator+= ( const bool  str)
inline

References Str().

Str& Str::operator+= ( const unsigned char  str)
inline

References Str().

Str& Str::operator+= ( const double  str)
inline

References Str().

Str& Str::operator+= ( const int  str)
inline

References Str().

Str& Str::operator+= ( const size_t  str)
inline

References Str().

Str& Str::operator+= ( const char *  str)
inline

References Str().

Str & Str::operator+= ( const Str str)

References chars_, length_, and NoChars_.

bool Str::operator< ( const Str str) const
inline

References compare().

Str& Str::operator<< ( const bool  str)
inline
Str& Str::operator<< ( const unsigned char  str)
inline
Str& Str::operator<< ( const double  str)
inline
Str& Str::operator<< ( const int  str)
inline
Str& Str::operator<< ( const size_t  str)
inline
Str& Str::operator<< ( const char *  str)
inline
Str& Str::operator<< ( const Str str)
inline
Str & Str::operator= ( const char *  str)

References set().

Str & Str::operator= ( const Str str)

References chars_, length_, and NoChars_.

Str& Str::operator= ( const double  var)
inline

References intoString().

bool Str::operator== ( const Str str) const
inline

References compare().

bool Str::operator== ( const char *  str) const
inline

References compare().

char Str::operator[] ( const size_t  index) const

References chars_, and length_.

Str& Str::pushBack ( const unsigned char  str)
inline
Str & Str::set ( const char *  str = NULL,
size_t  length = NO_POS 
)
bool Str::setChar ( size_t  index,
const unsigned char  theChar 
)

References chars_, and length_.

size_t Str::size ( ) const
inline
Str * Str::split ( int &  num,
const char *  splitSpec,
size_t  length = NO_POS 
) const
Str* Str::split ( int &  num,
const Str  str 
) const
inline

References chars_, length_, and split().

bool Str::startsWith ( const Str str) const
inline

References cStr(), length(), and startsWith().

Friends And Related Function Documentation

Str operator+ ( const char *  var,
const Str str 
)
friend
Str operator+ ( const Str var,
const Str str 
)
friend

Member Data Documentation

const size_t Str::MAX_LEN
static
char Str::NoChars_ = ""
static

The documentation for this class was generated from the following files: