WXP C++ Library Version 6.74.6
Loading...
Searching...
No Matches
Public Member Functions | List of all members
WXP::String Class Reference

This is a variable length string class. More...

#include "../include/String.h"

Public Member Functions

int init ()
 
int init (int length)
 
 String (int length)
 
 String ()
 
 String (const char *str)
 
 String (const String &string)
 
String operator= (const String &string)
 
 ~String ()
 
int set (const char *str)
 
int set (const String &string)
 
int reset ()
 
bool valid ()
 
bool isAlphaNum ()
 
const char * get ()
 
const char * get (int ind)
 
char getChar (int ind)
 
int length ()
 
int maxLength ()
 
int clear ()
 
int resize (int length)
 
int resize ()
 
int rewind ()
 
const char * getPtr ()
 
int scanf (const char *mess,...)
 
int scanp (const char *mess,...)
 
int printf (const char *mess,...)
 
int aprintf (const char *mess,...)
 
int replace (char tar, char rep)
 
int trimWS ()
 
int stripWS ()
 
int chop ()
 
int upCase ()
 
int lowCase ()
 
int index (char ch)
 
bool equal (const char *str)
 
bool equal (const char *str, int num)
 
bool iequal (const char *str)
 
bool iequal (const char *str, int num)
 
bool contains (const char *str)
 
int occurs (char ch)
 
int copy (const char *str)
 
int copy (String &str)
 
int copy (const char *str, int num)
 
int append (const char *str)
 
int append (String &str)
 
int append (const char *str, int num)
 
int append (char str)
 
int trunc (int ind)
 
int print ()
 

Detailed Description

This is a variable length string class.

Author
Dan Vietor

Constructor & Destructor Documentation

◆ String() [1/4]

String::String ( int  length)

Constructor of string with specified length

Parameters
lengthLength of string

References init(), and length().

◆ String() [2/4]

String::String ( )

Constructor of string. Length is 80 characters.

References init().

◆ String() [3/4]

String::String ( const char *  str)

Constructor of string based on existing string

Parameters
strString to initialize data to

◆ String() [4/4]

String::String ( const String string)

Copy constructor.

Parameters
stringsStrings class to copy from

References init(), and set().

◆ ~String()

String::~String ( )

Destructor

Member Function Documentation

◆ append() [1/4]

int String::append ( char  ch)

Appends a single character to the end of the main string

Parameters
chCharacter to append

References resize().

◆ append() [2/4]

int String::append ( const char *  str)

◆ append() [3/4]

int String::append ( const char *  str,
int  num 
)

Appends num number of characters from specified string to the end of main string

Parameters
strString to append
numNumber of characters to append

References resize().

◆ append() [4/4]

int String::append ( String str)

Appends specified string to the end of main string

Parameters
strString to append

References append(), and get().

◆ aprintf()

int String::aprintf ( const char *  fmt,
  ... 
)

Formats data into character string like sprintf, appends to end of string.

Parameters
fmtSprintf format
...Additional parameters to sprintf

Referenced by WXP::DateTool::createLabel(), WXP::SfcData::outString(), WXP::ForeTime::toString(), and WXP::Date::toText().

◆ chop()

int String::chop ( )

Chops the last character off the string

Referenced by WXP::VarFile::read().

◆ clear()

int String::clear ( )

◆ contains()

bool String::contains ( const char *  str)

Checks to see if string contains a specified string.

Parameters
strSee if this string is contained in main string

◆ copy() [1/3]

int String::copy ( const char *  str)

◆ copy() [2/3]

int String::copy ( const char *  str,
int  num 
)

Copies num number of characters from specified string into main string

Parameters
strString to copy from
numThe number of characters to copy

References resize().

◆ copy() [3/3]

int String::copy ( String str)

Copies specified string into main string

Parameters
strString class to copy from

References copy(), and get().

◆ equal() [1/2]

bool String::equal ( const char *  str)

Is the string equal to specified string

Parameters
strString to compare to
Returns
true if equal

Referenced by WXP::ContPlot::drawLine(), WXP::ContPlot::drawLineLabels(), WXP::ContPlot::drawMaxMin(), WXP::Menu::prompt(), and WXP::SatCdfFile::readHeader().

◆ equal() [2/2]

bool String::equal ( const char *  str,
int  num 
)

Is the string equal to a specified string. Only first num characters compared.

Parameters
strString to compare to
numNumber of characters to compare

◆ get() [1/2]

const char * String::get ( )

Gets the string data

Return values
strString data

Referenced by WXP::GridMath::abs(), WXP::GridMath::add(), WXP::FileTool::addOutPath(), WXP::FileTool::addPath(), WXP::FileTool::addPathDelim(), append(), WXP::Unit::change(), WXP::FileTool::checkPath(), WXP::ObjectAnal::compute(), WXP::MosRaw::compute(), WXP::SfcRaw::compute(), WXP::UpaRaw::compute(), copy(), WXP::ResrcDB::create(), WXP::DomainTool::decode(), WXP::ResrcDB::decodeProgramName(), WXP::GridMath::diff(), WXP::GridMath::div(), WXP::CityPlot::draw(), WXP::FrontPlot::draw(), WXP::GridCont::draw(), WXP::GridPlot::draw(), WXP::GridVect::draw(), WXP::HurPlot::draw(), WXP::ImagePlot::draw(), WXP::Lev2Plot::draw(), WXP::LightPlot::draw(), WXP::MapPlot::draw(), WXP::MdrPlot::draw(), WXP::MeteoPlot::draw(), WXP::MiscPlot::draw(), WXP::MosPlot::draw(), WXP::NidsPlot::draw(), WXP::ProfPlot::draw(), WXP::RadPlot::draw(), WXP::RawPlot::draw(), WXP::RcmPlot::draw(), WXP::RedbookPlot::draw(), WXP::SatPlot::draw(), WXP::SfcPlot::draw(), WXP::SoundPlot::draw(), WXP::ThermPlot::draw(), WXP::UpaPlot::draw(), WXP::UpaXSectCont::draw(), WXP::UpaXSectPlot::draw(), WXP::WarnPlot::draw(), WXP::WatchPlot::draw(), WXP::DatumPlot::draw(), WXP::VectPlot::draw(), WXP::NidsPlot::drawData(), WXP::ContPlot::drawFill(), WXP::ImagePlot::drawImage(), WXP::ContPlot::drawLabels(), WXP::VectPlot::drawLabels(), WXP::ContPlot::drawLine(), WXP::ContPlot::drawLineLabels(), WXP::ContPlot::drawMaxMin(), WXP::VectPlot::drawStreamline(), WXP::ContPlot::drawValues(), WXP::VectPlot::drawVect(), WXP::NameConv::encode(), WXP::Figure::endPlot(), WXP::GridMath::exp(), WXP::File::File(), WXP::Region::get(), WXP::ModelName::get(), WXP::ResrcEnv::get(), WXP::ResrcFile::get(), WXP::GridCont::getDomain(), WXP::GridVect::getDomain(), WXP::Filename::getHeader(), WXP::Filename::getName(), WXP::NameConv::getPath(), WXP::ResrcFile::getValid(), WXP::GridMath::inv(), WXP::Filename::listFile(), WXP::GridMath::log(), WXP::GridMath::log10(), WXP::GribFile::makeDatim(), WXP::GribFile::makeInfo(), WXP::GridMath::max(), WXP::GridMath::min(), WXP::GridMath::mod(), WXP::GridMath::mult(), WXP::Graph::open(), WXP::VarFile::open(), WXP::File::open(), WXP::BufrFile::open(), WXP::SfcWxpFile::open(), WXP::SfcXmlFile::open(), WXP::ResrcFile::open(), WXP::GridMath::pow(), WXP::Filename::print(), WXP::Grid::print(), WXP::MdrData::print(), WXP::MosData::print(), WXP::MosUData::print(), WXP::NidsPlot::print(), WXP::RcmData::print(), WXP::SfcData::print(), WXP::SfcPlot::print(), WXP::VarFileData::print(), WXP::VarSpec::print(), WXP::Message::print(), WXP::Grid::printInfo(), WXP::SfcData::printLine(), WXP::WmoIngest::printLog(), WXP::MosData::printTable(), WXP::WmoIngest::process(), WXP::ColorFile::read(), WXP::AreaFile::readData(), WXP::Unit::readFile(), WXP::ResrcFile::readFile(), WXP::SatUniFile::readHeader(), WXP::WmoIngest::readProdFile(), WXP::Prog::readResrcFile(), WXP::FileTool::remove(), WXP::CityTool::search(), WXP::VarName::searchFile(), WXP::ModelSpec::set(), WXP::Resrc::set(), WXP::Filename::set(), WXP::NameConv::set(), WXP::Grid::setDatim(), WXP::Filename::setFile(), WXP::NameConv::setFile(), WXP::GridPlot::setFilename(), WXP::NameConvFile::setFilename(), WXP::Graph::setFont(), WXP::NameConvFile::setHdrFilename(), WXP::NameConv::setLatest(), WXP::Graph::setSymbol(), WXP::RcmDecode::setup(), WXP::UpaRawinHash::setup(), WXP::CityHash::setup(), WXP::Unit::simplify(), WXP::GridMath::sqrt(), WXP::Variable::toAbbrCode(), WXP::VarSpec::toInfoLabel(), WXP::Variable::toLabel(), WXP::Variable::toString(), WXP::License::valid(), and WXP::ImgWxpFile::write().

◆ get() [2/2]

const char * String::get ( int  ind)

Returns a string starting at a specific index

Parameters
indIndex to start

◆ getChar()

char String::getChar ( int  ind)

Gets a specific character out of the string

Parameters
indIndex of character to retrieve

Referenced by WXP::FileTool::addPathDelim(), WXP::Region::get(), WXP::ResrcFile::get(), WXP::ColorFile::readFile(), WXP::RedbookFile::readHeader(), and WXP::NameConv::set().

◆ getPtr()

const char * WXP::String::getPtr ( )
inline

Returns internal data pointer

◆ iequal() [1/2]

bool String::iequal ( const char *  str)

Is the string equal to specified string (case insensitive)

Parameters
strString to compare to
Returns
true if equal

Referenced by WXP::ResrcFile::get(), WXP::Menu::prompt(), and WXP::ColorFile::readFile().

◆ iequal() [2/2]

bool String::iequal ( const char *  str,
int  num 
)

Is the string equal to a specified string. Only first num characters compared. Case insensitive.

Parameters
strString to compare to
numNumber of characters to compare

◆ index()

int String::index ( char  ch)

Returns the index of a specific character

Parameters
chThe character to search for
Returns
The index or -1

◆ init() [1/2]

int String::init ( )

◆ init() [2/2]

int String::init ( int  length)

Initializes the string data

Parameters
lengthLength of allocated string

References init(), and length().

◆ length()

int String::length ( )

◆ lowCase()

int String::lowCase ( )

Converts the string to lower case

Referenced by WXP::ResrcDB::decodeProgramName(), and WXP::ResrcFile::get().

◆ maxLength()

int String::maxLength ( )

Gets the maximum length of the allocated string

Returns
Maximum length of allocated string

◆ occurs()

int String::occurs ( char  ch)

Returns the number of times a character occurs within string

Parameters
chCharacter to search for
Returns
Number of occurrences

Referenced by WXP::Figure::endPlot(), WXP::GridPlot::getLoopType(), and WXP::GridPlot::getNumFrames().

◆ operator=()

String String::operator= ( const String string)

Assignment operator. Used to overload copying

Parameters
stringsString class to copy from

References set().

◆ print()

int String::print ( )

Prints the class values to standard output

◆ printf()

int String::printf ( const char *  fmt,
  ... 
)

◆ replace()

int String::replace ( char  tar,
char  rep 
)

Replaces characters in a string

Parameters
tarTarget character to replace
repThe character to replace with

◆ reset()

int String::reset ( )

Resets string data

◆ resize() [1/2]

int String::resize ( )

Resizes the string by doubling the size of the allocated data

References resize().

Referenced by append(), copy(), and resize().

◆ resize() [2/2]

int String::resize ( int  length)

Resizes the string by changing maximum length of allocated data

Parameters
lengthNew length of string data

References length().

◆ rewind()

int String::rewind ( )

Rewinds internal data pointer

◆ scanf()

int String::scanf ( const char *  fmt,
  ... 
)

Does a sscanf on the string

Parameters
fmtScanf format
...Additional parameters for sscanf
See also
sscanf

Referenced by WXP::Region::get(), WXP::ResrcFile::get(), WXP::Menu::prompt(), WXP::ColorFile::readFile(), and WXP::NameConv::set().

◆ scanp()

int String::scanp ( const char *  fmt,
  ... 
)

Does a parsing scan on the string

Parameters
fmtScanf format
...Additional parameters for sscanf
See also
sscanf

◆ set() [1/2]

int String::set ( const char *  str)

Sets the content of string

Parameters
strString to set content to

References copy().

Referenced by WXP::Filename::checkFile(), WXP::DateTool::createLabel(), WXP::VarName::get(), WXP::ModelName::get(), WXP::AreaFile::getComment(), WXP::GridCont::init(), WXP::GridPlot::init(), WXP::MdrPlot::init(), WXP::MeteoPlot::init(), WXP::MiscPlot::init(), WXP::NidsPlot::init(), WXP::RcmPlot::init(), WXP::ThermPlot::init(), WXP::VarName::makeLabel(), operator=(), WXP::SfcData::outString(), WXP::Unit::parse(), WXP::ResrcFile::parseName(), WXP::Menu::prompt(), WXP::Prog::prompt(), WXP::Filename::set(), WXP::Message::set(), WXP::MapPlot::setColor(), WXP::HurPlot::setColor(), WXP::LightPlot::setColor(), WXP::MdrPlot::setColor(), WXP::MosPlot::setColor(), WXP::NidsPlot::setColor(), WXP::RcmPlot::setColor(), WXP::RedbookPlot::setColor(), WXP::VectPlot::setColor(), WXP::WarnPlot::setColor(), WXP::WatchPlot::setColor(), WXP::ContPlot::setColorFill(), WXP::DatumPlot::setColorFill(), WXP::GridPlot::setColorFill(), WXP::ImagePlot::setColorFill(), WXP::Lev2Plot::setColorFill(), WXP::LightPlot::setColorFill(), WXP::MdrPlot::setColorFill(), WXP::NidsPlot::setColorFill(), WXP::RadPlot::setColorFill(), WXP::RcmPlot::setColorFill(), WXP::SatPlot::setColorFill(), WXP::VectPlot::setColorFill(), WXP::ContPlot::setColorLabel(), WXP::MapPlot::setColorLatLon(), WXP::ContPlot::setColorLine(), WXP::MapPlot::setColorLine(), WXP::ContPlot::setColorTable(), WXP::DatumPlot::setColorTable(), WXP::GridPlot::setColorTable(), WXP::HurPlot::setColorTable(), WXP::ImagePlot::setColorTable(), WXP::Lev2Plot::setColorTable(), WXP::LightPlot::setColorTable(), WXP::MapPlot::setColorTable(), WXP::MdrPlot::setColorTable(), WXP::MosPlot::setColorTable(), WXP::NidsPlot::setColorTable(), WXP::RadPlot::setColorTable(), WXP::RcmPlot::setColorTable(), WXP::RedbookPlot::setColorTable(), WXP::SatPlot::setColorTable(), WXP::VectPlot::setColorTable(), WXP::WarnPlot::setColorTable(), WXP::WatchPlot::setColorTable(), WXP::Filename::setFile(), WXP::CityPlot::setFilename(), WXP::GridPlot::setForeTime(), WXP::MosPlot::setForeTime(), WXP::MosRaw::setForeTime(), WXP::SoundPlot::setForeTime(), WXP::Filename::setHeader(), WXP::Plot::setLabelColor(), WXP::UpaPlot::setLevel(), WXP::UpaRaw::setLevel(), WXP::WmoIngest::setLogFile(), WXP::MapPlot::setMapFiles(), WXP::Filename::setName(), WXP::SfcPlot::setOutput(), WXP::Figure::setParam(), WXP::GridCont::setParam(), WXP::GridPlot::setParam(), WXP::MiscPlot::setParam(), WXP::MosPlot::setParam(), WXP::RadPlot::setParam(), WXP::SatPlot::setParam(), WXP::SfcPlot::setParam(), WXP::UpaPlot::setParam(), WXP::NameConv::setPath(), WXP::WmoIngest::setProdFile(), WXP::GridPlot::setVariable(), WXP::MdrPlot::setVariable(), WXP::MosPlot::setVariable(), WXP::MosRaw::setVariable(), WXP::NidsPlot::setVariable(), WXP::RcmPlot::setVariable(), WXP::SfcPlot::setVariable(), WXP::SfcRaw::setVariable(), WXP::UpaPlot::setVariable(), WXP::UpaRaw::setVariable(), WXP::Unit::simplify(), String(), WXP::VarSpec::toInfoLabel(), WXP::MosData::weather12(), and WXP::MosData::weather6().

◆ set() [2/2]

int String::set ( const String string)

Sets the content of string

Parameters
stringString to set content to

References copy().

◆ stripWS()

int String::stripWS ( )

Strips all white space characters from the string

Referenced by WXP::VarFile::read().

◆ trimWS()

int String::trimWS ( )

Trims whitespace characters off the end of the string

Referenced by WXP::ColorFile::readFile().

◆ trunc()

int String::trunc ( int  num)

Truncates string to num characters.

Parameters
numNumber of characters for the string to contain. If less than 0, num is offset from length of string

Referenced by WXP::ResrcDB::decodeProgramName(), and WXP::ResrcFile::get().

◆ upCase()

int String::upCase ( )

Converts the string to upper case

Referenced by WXP::ResrcEnv::get().

◆ valid()

bool String::valid ( )

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