WXP::String Class Reference

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

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

List of all members.

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::String ( int  length  ) 

Constructor of string with specified length

Parameters:
length Length of string

References init().

String::String (  ) 

Constructor of string. Length is 80 characters.

References init().

String::String ( const char *  str  ) 

Constructor of string based on existing string

Parameters:
str String to initialize data to
String::String ( const String string  ) 

Copy constructor.

Parameters:
strings Strings class to copy from

References init().

String::~String (  ) 

Destructor


Member Function Documentation

int String::append ( char  ch  ) 

Appends a single character to the end of the main string

Parameters:
ch Character to append

References resize().

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

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

Parameters:
str String to append
num Number of characters to append

References resize().

int String::append ( String str  ) 

Appends specified string to the end of main string

Parameters:
str String to append

References append(), and get().

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

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

Parameters:
fmt Sprintf format
... Additional parameters to sprintf

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

int String::chop (  ) 

Chops the last character off the string

int String::clear (  ) 
bool String::contains ( const char *  str  ) 

Checks to see if string contains a specified string.

Parameters:
str See if this string is contained in main string
int String::copy ( const char *  str,
int  num 
)

Copies num number of characters from specified string into main string

Parameters:
str String to copy from
num The number of characters to copy

References resize().

int String::copy ( String str  ) 

Copies specified string into main string

Parameters:
str String class to copy from

References copy(), and get().

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

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

Parameters:
str String to compare to
num Number of characters to compare
bool String::equal ( const char *  str  ) 

Is the string equal to specified string

Parameters:
str String to compare to
Returns:
true if equal

Referenced by WXP::Menu::prompt(), and WXP::Filename::setFilePrompt().

const char * String::get ( int  ind  ) 

Returns a string starting at a specific index

Parameters:
ind Index to start
const char * String::get (  ) 

Gets the string data

Return values:
str String data

Referenced by WXP::GridMath::add(), WXP::FileTool::addOutPath(), WXP::FileTool::addPath(), WXP::FileTool::addPathDelim(), append(), WXP::Unit::change(), WXP::FileTool::checkPath(), WXP::UpaRaw::compute(), WXP::SfcRaw::compute(), WXP::ObjectAnal::compute(), WXP::MosRaw::compute(), copy(), WXP::ResrcDB::create(), WXP::DomainTool::decode(), WXP::ResrcDB::decodeProgramName(), WXP::GridMath::diff(), WXP::GridMath::div(), WXP::UpaXSectPlot::draw(), WXP::UpaXSectCont::draw(), WXP::UpaPlot::draw(), WXP::SfcPlot::draw(), WXP::SatPlot::draw(), WXP::RedbookPlot::draw(), WXP::RcmPlot::draw(), WXP::RawPlot::draw(), WXP::NidsPlot::draw(), WXP::MosPlot::draw(), WXP::MiscPlot::draw(), WXP::MeteoPlot::draw(), WXP::MdrPlot::draw(), WXP::MapPlot::draw(), WXP::LightPlot::draw(), WXP::Lev2Plot::draw(), WXP::GridPlot::draw(), WXP::GridCont::draw(), WXP::FrontPlot::draw(), WXP::CityPlot::draw(), WXP::NidsPlot::drawData(), WXP::ImagePlot::drawImage(), WXP::NameConv::encode(), WXP::Figure::endPlot(), WXP::File::File(), WXP::ResrcFile::get(), WXP::ResrcEnv::get(), WXP::Region::get(), WXP::ModelName::get(), WXP::GridCont::getDomain(), WXP::Filename::getHeader(), WXP::Filename::getName(), WXP::NameConv::getPath(), WXP::ResrcFile::getValid(), WXP::Filename::listFile(), WXP::GribFile::makeDatim(), WXP::GribFile::makeInfo(), WXP::GridMath::mult(), WXP::SfcXmlFile::open(), WXP::SfcWxpFile::open(), WXP::ResrcFile::open(), WXP::Graph::open(), WXP::File::open(), WXP::BufrFile::open(), WXP::VarSpec::print(), WXP::SfcPlot::print(), WXP::SfcData::print(), WXP::NidsPlot::print(), WXP::MosUData::print(), WXP::MosData::print(), WXP::Message::print(), WXP::Grid::print(), WXP::Filename::print(), WXP::Grid::printInfo(), WXP::SfcData::printLine(), WXP::MosData::printTable(), WXP::ColorFile::read(), WXP::Unit::readFile(), WXP::ResrcFile::readFile(), WXP::SatUniFile::readHeader(), WXP::Prog::readResrcFile(), WXP::FileTool::remove(), WXP::CityTool::search(), WXP::Resrc::set(), WXP::NameConv::set(), WXP::ModelSpec::set(), WXP::Filename::set(), WXP::CityHash::set(), WXP::Filename::setDate(), WXP::NameConv::setFile(), WXP::NameConvFile::setFilename(), WXP::Filename::setFilePrompt(), WXP::Graph::setFont(), WXP::NameConvFile::setHdrFilename(), WXP::NameConv::setLatest(), WXP::Graph::setSymbol(), WXP::RcmDecode::setup(), WXP::VarSpec::toInfoLabel(), WXP::Variable::toLabel(), WXP::Variable::toString(), and WXP::ImgWxpFile::write().

char String::getChar ( int  ind  ) 

Gets a specific character out of the string

Parameters:
ind Index of character to retrieve

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

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

Returns internal data pointer

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

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

Parameters:
str String to compare to
num Number of characters to compare
bool String::iequal ( const char *  str  ) 

Is the string equal to specified string (case insensitive)

Parameters:
str String to compare to
Returns:
true if equal

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

int String::index ( char  ch  ) 

Returns the index of a specific character

Parameters:
ch The character to search for
Returns:
The index or -1
int String::init ( int  length  ) 

Initializes the string data

Parameters:
length Length of allocated string

References init().

int String::init (  ) 
int String::length (  ) 
int String::lowCase (  ) 

Converts the string to lower case

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

int String::maxLength (  ) 

Gets the maximum length of the allocated string

Returns:
Maximum length of allocated string
int String::occurs ( char  ch  ) 

Returns the number of times a character occurs within string

Parameters:
ch Character to search for
Returns:
Number of occurrences

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

String String::operator= ( const String string  ) 

Assignment operator. Used to overload copying

Parameters:
strings String class to copy from
int String::print (  ) 

Prints the class values to standard output

References printf().

Referenced by WXP::UpaXSectPlot::draw().

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

Replaces characters in a string

Parameters:
tar Target character to replace
rep The character to replace with
int String::reset (  ) 

Resets string data

int String::resize (  ) 

Resizes the string by doubling the size of the allocated data

Referenced by append(), and copy().

int String::resize ( int  length  ) 

Resizes the string by changing maximum length of allocated data

Parameters:
length New length of string data
int String::rewind (  ) 

Rewinds internal data pointer

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

Does a sscanf on the string

Parameters:
fmt Scanf format
... Additional parameters for sscanf
See also:
sscanf

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

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

Does a parsing scan on the string

Parameters:
fmt Scanf format
... Additional parameters for sscanf
See also:
sscanf
int String::set ( const String string  ) 

Sets the content of string

Parameters:
string String to set content to

References copy().

int String::set ( const char *  str  ) 

Sets the content of string

Parameters:
str String to set content to

References copy().

Referenced by WXP::Filename::checkFile(), WXP::DateTool::createLabel(), WXP::ModelName::get(), WXP::AreaFile::getComment(), WXP::SfcData::outString(), WXP::Unit::parse(), WXP::ResrcFile::parseName(), WXP::Menu::prompt(), WXP::Message::set(), WXP::Filename::set(), WXP::UpaPlot::setColor(), WXP::SfcPlot::setColor(), WXP::RcmPlot::setColor(), WXP::NidsPlot::setColor(), WXP::MosPlot::setColor(), WXP::MdrPlot::setColor(), WXP::LightPlot::setColor(), WXP::VectPlot::setColorFill(), WXP::SatPlot::setColorFill(), WXP::RcmPlot::setColorFill(), WXP::RadPlot::setColorFill(), WXP::NidsPlot::setColorFill(), WXP::MdrPlot::setColorFill(), WXP::Lev2Plot::setColorFill(), WXP::ImagePlot::setColorFill(), WXP::GridPlot::setColorFill(), WXP::DatumPlot::setColorFill(), WXP::Contour::setColorFill(), WXP::Contour::setColorLabel(), WXP::VectPlot::setColorLine(), WXP::Contour::setColorLine(), WXP::VectPlot::setColorTable(), WXP::UpaPlot::setColorTable(), WXP::SfcPlot::setColorTable(), WXP::SatPlot::setColorTable(), WXP::RcmPlot::setColorTable(), WXP::RadPlot::setColorTable(), WXP::NidsPlot::setColorTable(), WXP::MosPlot::setColorTable(), WXP::MdrPlot::setColorTable(), WXP::Lev2Plot::setColorTable(), WXP::ImagePlot::setColorTable(), WXP::GridPlot::setColorTable(), WXP::DatumPlot::setColorTable(), WXP::Contour::setColorTable(), WXP::Filename::setDate(), WXP::Filename::setFile(), WXP::CityPlot::setFilename(), WXP::Filename::setFilePrompt(), WXP::MosRaw::setForeTime(), WXP::MosPlot::setForeTime(), WXP::GridPlot::setForeTime(), WXP::Filename::setHeader(), WXP::Plot::setLabelColor(), WXP::UpaRaw::setLevel(), WXP::UpaPlot::setLevel(), WXP::Filename::setName(), WXP::UpaPlot::setParam(), WXP::SfcPlot::setParam(), WXP::SatPlot::setParam(), WXP::RawPlot::setParam(), WXP::RadPlot::setParam(), WXP::MosPlot::setParam(), WXP::MiscPlot::setParam(), WXP::MapPlot::setParam(), WXP::LightPlot::setParam(), WXP::GridPlot::setParam(), WXP::GridCont::setParam(), WXP::Figure::setParam(), WXP::NameConv::setPath(), WXP::UpaRaw::setVariable(), WXP::UpaPlot::setVariable(), WXP::SfcRaw::setVariable(), WXP::SfcPlot::setVariable(), WXP::RcmPlot::setVariable(), WXP::NidsPlot::setVariable(), WXP::MosRaw::setVariable(), WXP::MosPlot::setVariable(), WXP::MdrPlot::setVariable(), WXP::GridPlot::setVariable(), WXP::VarSpec::toInfoLabel(), WXP::MosData::weather12(), and WXP::MosData::weather6().

int String::stripWS (  ) 

Strips all white space characters from the string

int String::trimWS (  ) 

Trims whitespace characters off the end of the string

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

int String::trunc ( int  num  ) 

Truncates string to num characters.

Parameters:
num Number 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().

int String::upCase (  ) 

Converts the string to upper case

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

bool String::valid (  ) 

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

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1