WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
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().

Referenced by append(), copy(), operator=(), set(), and String().

◆ 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(), set(), and String().

◆ ~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]

◆ 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(), get(), and String().

◆ 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()

◆ 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]

◆ 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(), get(), and String().

◆ 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::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::MosRaw::compute(), WXP::ObjectAnal::compute(), WXP::SfcRaw::compute(), WXP::UpaRaw::compute(), copy(), WXP::ResrcDB::create(), WXP::DomainTool::decode(), WXP::ResrcDB::decodeProgramName(), WXP::GridMath::diff(), WXP::GridMath::div(), WXP::FrontPlot::draw(), WXP::GridPlot::draw(), WXP::Lev2Plot::draw(), WXP::LightPlot::draw(), WXP::MapPlot::draw(), WXP::MdrPlot::draw(), WXP::MeteoPlot::draw(), WXP::MosPlot::draw(), WXP::ProfPlot::draw(), WXP::RawPlot::draw(), WXP::RcmPlot::draw(), WXP::RedbookPlot::draw(), WXP::SfcPlot::draw(), WXP::UpaPlot::draw(), WXP::UpaXSectCont::draw(), WXP::UpaXSectPlot::draw(), WXP::NidsPlot::drawData(), WXP::ContPlot::drawLabels(), WXP::VectPlot::drawLabels(), WXP::ContPlot::drawLineLabels(), WXP::ContPlot::drawMaxMin(), WXP::ContPlot::drawValues(), WXP::VectPlot::drawVect(), WXP::NameConv::encode(), WXP::GridMath::exp(), WXP::File::File(), WXP::ModelName::get(), WXP::ModelName::get(), WXP::Region::get(), WXP::ResrcEnv::get(), WXP::ResrcFile::get(), WXP::GridCont::getDomain(), WXP::GridVect::getDomain(), 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::BufrFile::open(), WXP::File::open(), WXP::File::open(), WXP::Graph::open(), WXP::ResrcFile::open(), WXP::SfcWxpFile::open(), WXP::SfcXmlFile::open(), WXP::VarFile::open(), WXP::GridMath::pow(), WXP::Grid::print(), WXP::MdrData::print(), WXP::Message::print(), WXP::MosData::print(), WXP::MosUData::print(), WXP::RcmData::print(), WXP::SfcData::print(), WXP::VarSpec::print(), WXP::Grid::printInfo(), WXP::SfcData::printLine(), WXP::WmoIngest::printLog(), WXP::MosData::printTable(), WXP::ColorFile::read(), WXP::ResrcFile::readFile(), WXP::Unit::readFile(), WXP::WmoIngest::readProdFile(), WXP::Prog::readResrcFile(), WXP::FileTool::remove(), WXP::CityTool::search(), WXP::VarName::searchFile(), WXP::VarName::searchFile(), WXP::ModelSpec::set(), WXP::NameConv::set(), WXP::Resrc::set(), WXP::Grid::setDatim(), WXP::NameConv::setFile(), WXP::NameConvFile::setFilename(), WXP::Graph::setFont(), WXP::NameConvFile::setHdrFilename(), WXP::NameConv::setLatest(), WXP::Graph::setSymbol(), WXP::CityHash::setup(), WXP::CityHash::setup(), WXP::RcmDecode::setup(), WXP::UpaRawinHash::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 ( )

Initializes the string data

Referenced by init(), WXP::ShapeFile::open(), WXP::NameConv::setLatest(), String(), String(), and String().

◆ init() [2/2]

int String::init ( int length)

Initializes the string data

Parameters
lengthLength of allocated string

References init(), and length().

◆ 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

◆ operator=()

String String::operator= ( const String & string)

Assignment operator. Used to overload copying

Parameters
stringsString class to copy from

References set(), and String().

◆ print()

int String::print ( )

Prints the class values to standard output

◆ printf()

◆ 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(), append(), append(), copy(), 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]

◆ set() [2/2]

int String::set ( const String & string)

Sets the content of string

Parameters
stringString to set content to

References copy(), and String().

◆ 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 ( )

Does the string contain data (length > 0)

Returns
true if contains data

Referenced by WXP::VectPlot::drawLabels(), WXP::GribFile::makeInfo(), and WXP::VarSpec::toInfoLabel().


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