Isis 3 Programmer Reference
|
Adds specific functionality to C++ strings. More...
#include <IString.h>
Public Member Functions | |
IString () | |
Constructs an empty IString object. More... | |
IString (const std::string &str) | |
Constructs a IString object with initial value set to the string argument. More... | |
IString (const IString &str) | |
Constructs a IString with initial value set to the IString argument. More... | |
IString (const char *str) | |
Constructs a IString with initial value set to the argument. More... | |
IString (const int &num) | |
Constructs a IString object with its initial value set to the string representation of the int argument. More... | |
IString (const double &num, const int piPrecision=14) | |
Constructs a IString object with its initial value set to the string representation of the double argument. More... | |
IString (const BigInt &num) | |
Constructs a IString object with its initial value set to the string representation of the BigInt argument. More... | |
IString (const QString &str) | |
Constructs a IString object with initial value set to the input QString. More... | |
~IString () | |
Destructor. More... | |
IString | Trim (const std::string &chars) |
Removes characters from the beginning and end of the IString. More... | |
IString | TrimHead (const std::string &chars) |
Trims The input characters from the beginning of the object IString. More... | |
IString | TrimTail (const std::string &chars) |
Trims the input characters from the end of the object IString. More... | |
IString | UpCase () |
Converst any lower case characters in the object IString with uppercase characters. More... | |
IString | DownCase () |
Converts all upper case letters in the object IString into lower case characters. More... | |
int | ToInteger () const |
Returns the object string as an integer. More... | |
BigInt | ToBigInteger () const |
Returns the BigInt representation of the object IString. More... | |
double | ToDouble () const |
Returns the floating point value the IString represents. More... | |
QString | ToQt () const |
Retuns the object string as a QString. More... | |
IString | Token (const IString &separator) |
Returns the first token in the IString. More... | |
IString | Compress (bool force=false) |
Collapses multiple spaces into single spaces. More... | |
IString | Replace (const std::string &from, const std::string &to, int maxReplaceCount=20) |
Replaces all instances of the first input string with the second input string. More... | |
IString | Replace (const std::string &from, const std::string &to, bool honorquotes) |
Replaces all instances of the first input string with the second input string. More... | |
IString | Convert (const std::string &listofchars, const char &to) |
Returns the string with all occurrences of any character in the "from" argument converted to the "to" argument. More... | |
IString | ConvertWhiteSpace () |
Returns the string with all "new lines", "carriage returns", "tabs", "form
feeds", "vertical tabs" and "back spaces" converted to single spaces. More... | |
IString | Remove (const std::string &del) |
Remove all instances of any character in the string from the IString. More... | |
operator int () const | |
Attempts to convert the stirng to a 32 bit integer and return that int. More... | |
operator BigInt () const | |
Attempts to convert the stirng to a 64 bit integer and return that int. More... | |
operator double () const | |
Attempts to convert the stirng to a 64 bit double and return that double. More... | |
IString & | operator= (const int &value) |
Attempts to convert the stirng to a QStirng (Qt) and return that IString. More... | |
IString & | operator= (const BigInt &value) |
Attempts to convert a 64 bit integer into its string representation. More... | |
IString & | operator= (const double &value) |
Attempts to convert double into its string representation. More... | |
bool | Equal (const std::string &str) const |
Compare a string to the object IString. More... | |
Static Public Member Functions | |
static std::string | Trim (const std::string &chars, const std::string &str) |
Removes all occurences of the input characters from the beginning and end of the input string. More... | |
static std::string | TrimHead (const std::string &chars, const std::string &str) |
Trims the input characters from the beginning of the input string. More... | |
static std::string | TrimTail (const std::string &chars, const std::string &str) |
Trims the input characters from the end of the input string. More... | |
static std::string | UpCase (const std::string &str) |
Converts lower case characters in the input string to upper case characters. More... | |
static std::string | DownCase (const std::string &str) |
Converts all upper case letters in the input string into lower case characters. More... | |
static int | ToInteger (const std::string &str) |
Returns the integer representation of the input string. More... | |
static BigInt | ToBigInteger (const std::string &str) |
Returns the Big Integer representation of the input string. More... | |
static double | ToDouble (const std::string &str) |
Returns the floating-point value represented by the input string. More... | |
static QString | ToQt (const std::string &str) |
Returns the input string as a QString. More... | |
static int | Split (const char separator, const std::string &instr, std::vector< std::string > &tokens, bool allowEmptyEntries=true) |
Find separators between characters and split them into strings. More... | |
static std::string | Compress (const std::string &str, bool force=false) |
Returns the input string with multiple spaces collapsed into single spaces. More... | |
static std::string | Replace (const std::string &str, const std::string &from, const std::string &to, int maxReplacementCount=20) |
Replace specified substring with replacement substring in a string. More... | |
static IString | Replace (const std::string &str, const std::string &from, const std::string &to, bool honorquotes) |
Replace specified substring with replacement substring in a string honoring quotes if requested. More... | |
static std::string | Convert (const std::string &str, const std::string &listofchars, const char &to) |
Converts all occurences in the input string of any character in the "from" string to the "to" character. More... | |
static std::string | ConvertWhiteSpace (const std::string &str) |
Converts all forms of whitespace in the input string into single spaces. More... | |
static std::string | Remove (const std::string &del, const std::string &str) |
Remove all instances of any character in the "del" argument from the input string. More... | |
static bool | Equal (const std::string &str1, const std::string &str2) |
Compare two strings, case-insensitive. More... | |
static std::string | ToStd (const QString &str) |
Converts a Qt string into a std::string. More... | |
static QStringList | ToQt (const std::vector< std::string > &sl) |
Converts a vector of strings into a QStringList. More... | |
static std::vector< std::string > | ToStd (const QStringList &sl) |
Converts a QStringList into a vector of strings. More... | |
Private Member Functions | |
void | SetDouble (const double &value, const int piPrecision=14) |
Performs the conversion necessary to represent a floating-point value as a string. More... | |
Adds specific functionality to C++ strings.
This class extends the standard C++ string class with specific functionality useable by ISIS programmers.
Isis::IString::IString | ( | ) |
Constructs an empty IString object.
Definition at line 403 of file IString.cpp.
Referenced by Replace().
Isis::IString::IString | ( | const std::string & | str | ) |
Constructs a IString object with initial value set to the string argument.
str | The initial value of the IString |
Definition at line 414 of file IString.cpp.
Isis::IString::IString | ( | const IString & | str | ) |
Constructs a IString with initial value set to the IString argument.
str | The initial value of the IString |
Definition at line 424 of file IString.cpp.
Isis::IString::IString | ( | const char * | str | ) |
Constructs a IString with initial value set to the argument.
str | The inital value of the IString |
Definition at line 434 of file IString.cpp.
Isis::IString::IString | ( | const int & | num | ) |
Constructs a IString object with its initial value set to the string representation of the int argument.
num | The initial value of the IString. The integer value is converted to a string representation and stored as the value. |
Definition at line 446 of file IString.cpp.
Isis::IString::IString | ( | const double & | num, |
const int | piPrecision = 14 |
||
) |
Constructs a IString object with its initial value set to the string representation of the double argument.
num | The initial value of the IString. The double value is converted to a string representation and stored as the value. The conversion is handled in the following manner: If (abs(num) < 0.1) it is presented in scientific notation If (abs(log10(num)) < 16) it is presented in normal notation if (abs(log10(num)) >= 16) it is presented in scientific notation Trailing zeros are removed such that 5.000 is presented as 5.0 |
Definition at line 481 of file IString.cpp.
References SetDouble().
Isis::IString::IString | ( | const BigInt & | num | ) |
Constructs a IString object with its initial value set to the string representation of the BigInt argument.
num | The initial value of the IString. The integer value is converted to a string representation and stored as the value. |
Definition at line 461 of file IString.cpp.
Isis::IString::IString | ( | const QString & | str | ) |
Constructs a IString object with initial value set to the input QString.
str |
Definition at line 504 of file IString.cpp.
Isis::IString::~IString | ( | ) |
IString Isis::IString::Compress | ( | bool | force = false | ) |
Collapses multiple spaces into single spaces.
force | Determines whether to compress inside quotes (single and double) |
Definition at line 974 of file IString.cpp.
Referenced by Isis::UserInterface::loadBatchList().
|
static |
Returns the input string with multiple spaces collapsed into single spaces.
str | The string to be compressed |
force | Determines whether to compress inside quotes |
Definition at line 990 of file IString.cpp.
IString Isis::IString::Convert | ( | const std::string & | listofchars, |
const char & | to | ||
) |
Returns the string with all occurrences of any character in the "from" argument converted to the "to" argument.
The original string is modified.
listofchars | The string of characters to be replaced. The order of the characters is not important. |
to | The single character used as the replacement. |
Definition at line 1196 of file IString.cpp.
Referenced by ConvertWhiteSpace(), Isis::ImageFileListWidget::fromPvl(), and Isis::ImageFileListWidget::toPvl().
|
static |
Converts all occurences in the input string of any character in the "from" string to the "to" character.
str | The input string |
listofchars | The string of characters to be replaced. The order of the characters is unimportant |
to | The single character used as replacement |
Definition at line 1216 of file IString.cpp.
IString Isis::IString::ConvertWhiteSpace | ( | ) |
Returns the string with all "new lines", "carriage returns", "tabs", "form feeds", "vertical tabs" and "back spaces" converted to single spaces.
All quotes are ignored. The original string is modified.
Definition at line 1238 of file IString.cpp.
Referenced by Isis::MocLabels::InitWago(), and Isis::PvlKeyword::stringEqual().
|
static |
Converts all forms of whitespace in the input string into single spaces.
str |
Definition at line 1252 of file IString.cpp.
References Convert().
IString Isis::IString::DownCase | ( | ) |
Converts all upper case letters in the object IString into lower case characters.
Definition at line 644 of file IString.cpp.
Referenced by IsisAml::CreatePVL(), Isis::CubeIoHandler::CubeIoHandler(), IsisAml::GroupIndex(), IsisAml::IsParamInPvlInclude(), Isis::TextFile::Open(), Isis::NoCaseStringCompare< K >::operator()(), Isis::ControlNetFilter::PointMeasurePropertiesFilter(), Isis::ControlNetFilter::PointPropertiesFilter(), Isis::Kernels::resolveTypeByExt(), and Isis::InfixToPostfix::tokenizeEquation().
|
static |
Converts all upper case letters in the input string into lower case characters.
str |
Definition at line 659 of file IString.cpp.
bool Isis::IString::Equal | ( | const std::string & | str | ) | const |
Compare a string to the object IString.
str | The string with which the comparison is made |
Definition at line 690 of file IString.cpp.
Referenced by Isis::DatabaseFactory::remove().
|
static |
Compare two strings, case-insensitive.
str1 | [in] The first string to compare |
str2 | [in] The second string to compare |
Definition at line 705 of file IString.cpp.
References Isis::nocase_compare().
|
inline |
Attempts to convert the stirng to a 64 bit integer and return that int.
Definition at line 251 of file IString.h.
References ToBigInteger().
|
inline |
Attempts to convert the stirng to a 64 bit double and return that double.
Definition at line 260 of file IString.h.
References ToDouble().
|
inline |
Attempts to convert the stirng to a 32 bit integer and return that int.
Definition at line 241 of file IString.h.
References ToInteger().
Attempts to convert a 64 bit integer into its string representation.
value | [in] The 64 bit integer to be converted to a string |
Definition at line 1317 of file IString.cpp.
|
inline |
Attempts to convert double into its string representation.
value | [in] The double to be converted to a string |
Definition at line 286 of file IString.h.
References SetDouble().
IString & Isis::IString::operator= | ( | const int & | value | ) |
Attempts to convert the stirng to a QStirng (Qt) and return that IString.
Attempts to convert a 32 bit integer into its string representation.
value | [in] The 32 bit integer to be converted to a string |
Definition at line 1301 of file IString.cpp.
IString Isis::IString::Remove | ( | const std::string & | del | ) |
Remove all instances of any character in the string from the IString.
del | The characters to be removed from the IString. The character is unimportant |
Definition at line 1266 of file IString.cpp.
Referenced by Isis::InfixToPostfix::convert(), Isis::MocLabels::InitWago(), and Isis::PvlKeyword::stringEqual().
|
static |
Remove all instances of any character in the "del" argument from the input string.
str | The string from which characters are to be removed |
del | The string of characters to be removed. Order is unimportant. |
Definition at line 1285 of file IString.cpp.
IString Isis::IString::Replace | ( | const std::string & | from, |
const std::string & | to, | ||
bool | honorquotes | ||
) |
Replaces all instances of the first input string with the second input string.
Honoring quotes if requested by the boolean
from | Search string that when found in str, it is replaced with to. |
to | IString that will replace every occurance of from in str. |
honorquotes | Set to true to honor quotes and not replace inside them |
Definition at line 1123 of file IString.cpp.
References Replace().
IString Isis::IString::Replace | ( | const std::string & | from, |
const std::string & | to, | ||
int | maxReplaceCount = 20 |
||
) |
Replaces all instances of the first input string with the second input string.
For more information, see IString::Replace(const string, const string, const string, int)
from | Search string that when found in str, it is replaced with to |
to | IString that will replace every occurance of from in str. |
maxReplaceCount | Maximum number of replacements to allow per call |
Definition at line 1037 of file IString.cpp.
References IString().
Referenced by Isis::UserInterface::loadBatchList(), and Replace().
|
static |
Replace specified substring with replacement substring in a string honoring quotes if requested.
This routine is case sensitive and will only replace exact matches.
str | Input string to search and replace substrings in |
from | Search string that when found in str, it is replaced with to. |
to | IString that will replace every occurance of from in str. |
honorquotes | Set to true to honor quotes and not replace inside them |
Definition at line 1147 of file IString.cpp.
|
static |
Replace specified substring with replacement substring in a string.
This method accepts a string, a target substring and a replacement substring with the intent to find all occurances of the subTarg substring in s and replace them with the substring subRep. The maxReplaceCount parameter is so that a should the replacement substring contain the target substring, an infinite loop would occur.
Note that the search for strings are implemented as a loop that always starts at the begining of s. So should the above scenario occur, it will be limited.
I have found this useful for formulating database SQL queries in a loop. The following example illustrates this usage:
This routine is case sensitive and will only replace exact matches.
To prevent infinite recursion, where the replace string contains the search string, use the maxReplaceCount to adjust appropriately.
str | Input string to search and replace substrings |
from | Search string that when found in str, it is replaced with to |
to | IString that will replace every occurance of from in str. |
maxReplaceCount | Maximum number of replacements to allow per call |
Definition at line 1091 of file IString.cpp.
|
private |
Performs the conversion necessary to represent a floating-point value as a string.
See IString (const double &num) for details
num | The input value to be stored |
Definition at line 494 of file IString.cpp.
References Isis::toString().
Referenced by IString(), and operator=().
|
static |
Find separators between characters and split them into strings.
This method will break up the input string into tokens that are separated by one or more of the specified character. If allowEmptyEntries == true, then one or separator characters are deem a single separator and the string is split into two different sections. If allowEmptyEntries == false, then should more than one separator character occur in succession, this will result in the number of separator characters less one empty strings returned to the caller.
separator | A single character that separates each substring |
str | The string to break into separate fields or tokens |
tokens | A vector of strings that will receive the tokens as separated by the separator character. |
allowEmptyEntries | If true, treat successive separator characters as a single separator. If false, successive separator characters result in empty strings/tokens. |
Definition at line 940 of file IString.cpp.
BigInt Isis::IString::ToBigInteger | ( | ) | const |
Returns the BigInt representation of the object IString.
Definition at line 758 of file IString.cpp.
Referenced by operator BigInt().
|
static |
Returns the Big Integer representation of the input string.
str | The string representing an integer value |
Definition at line 771 of file IString.cpp.
References Isis::IException::Unknown.
double Isis::IString::ToDouble | ( | ) | const |
Returns the floating point value the IString represents.
Definition at line 799 of file IString.cpp.
Referenced by Isis::ScatterPlotAlarmConfigDialog::applySettingsToScatterPlot(), Isis::MdisCamera::computeFocalLength(), Isis::ImportPdsTable::extract(), IsisAml::GetDouble(), Isis::MocLabels::InitWago(), operator double(), Isis::CubeCalculator::prepareCalculations(), Isis::iTime::Second(), and IsisAml::Verify().
|
static |
Returns the floating-point value represented by the input string.
str | The string representing the numeric value |
Definition at line 812 of file IString.cpp.
References Isis::IException::Unknown.
int Isis::IString::ToInteger | ( | ) | const |
Returns the object string as an integer.
Definition at line 718 of file IString.cpp.
Referenced by Isis::Workspace::addCubeViewport(), Isis::Workspace::addCubeViewportFromList(), Isis::iTime::Day(), Isis::iTime::DayOfYear(), Isis::ImportPdsTable::extract(), Isis::ProcessImportVicar::ExtractPvlLabel(), Isis::Kernels::getCameraVersion(), IsisAml::GetInteger(), Isis::iTime::Hour(), Isis::KernelDb::matches(), Isis::iTime::Minute(), Isis::iTime::Month(), operator int(), Isis::CubeCalculator::prepareCalculations(), Isis::ProcessImportPds::ProcessDataFilePointer(), IsisAml::Verify(), and Isis::iTime::Year().
|
static |
Returns the integer representation of the input string.
str | The string representing an integer value |
Definition at line 731 of file IString.cpp.
References Isis::IException::Unknown.
Returns the first token in the IString.
A token is defined as a string of characters from the beginning of the string to, but not including, the first character matching any character in the separator string. The token is removed from the original string along with the separator.
separator | The string of characters used to separate tokens. The order of the characters is not important. |
Definition at line 897 of file IString.cpp.
Referenced by Isis::PvlKeyword::addCommentWrapped(), Isis::InfixToPostfix::cleanSpaces(), Isis::InfixToPostfix::convert(), Isis::ProcessImportFits::extractFitsLabels(), Isis::InfixToPostfix::formatFunctionCalls(), Isis::MocLabels::InitWago(), Isis::KernelDb::matches(), Isis::CubeCalculator::prepareCalculations(), Isis::FileList::read(), Isis::CissLabels::ReadLabels(), Isis::SocketThread::run(), Isis::UserInterface::SetBatchList(), Isis::MinnaertEmpirical::SetPhotoKList(), Isis::LunarLambertEmpirical::SetPhotoLList(), Isis::LunarLambertEmpirical::SetPhotoPhaseCurveList(), Isis::MinnaertEmpirical::SetPhotoPhaseCurveList(), Isis::LunarLambertEmpirical::SetPhotoPhaseList(), and Isis::MinnaertEmpirical::SetPhotoPhaseList().
QString Isis::IString::ToQt | ( | ) | const |
Retuns the object string as a QString.
Definition at line 869 of file IString.cpp.
Referenced by Isis::ScatterPlotAlarmConfigDialog::applySettingsToScatterPlot(), Isis::InfixToPostfix::cleanSpaces(), Isis::Gruen::ConfKey(), Isis::InfixToPostfix::convert(), Isis::Kernels::examine(), Isis::SqlQuery::exec(), Isis::ImportPdsTable::extract(), Isis::ProcessImportFits::extractFitsLabels(), Isis::SqlQuery::fieldIndex(), Isis::InfixToPostfix::formatFunctionCalls(), Isis::ImageFileListWidget::fromPvl(), Isis::DatabaseFactory::getProfileList(), Isis::Kernels::getTypes(), Isis::MocLabels::InitWago(), Isis::DbProfile::key(), Isis::UserInterface::loadBatchList(), Isis::CubeManager::OpenCube(), Isis::CubeCalculator::prepareCalculations(), Isis::FileList::read(), Isis::CissLabels::ReadLabels(), Isis::ScatterPlotAlarmConfigDialog::readSettingsFromScatterPlot(), Isis::PlotWindowBestFitDialog::refreshWidgetStates(), Isis::Kernels::resolveType(), Isis::Image::save(), Isis::Shape::save(), Isis::UserInterface::SetBatchList(), Isis::InfixToPostfix::tokenizeEquation(), Isis::ImageFileListWidget::toPvl(), ToQt(), and Isis::TrackTool::updateLabels().
|
static |
Returns the input string as a QString.
s | [in] The standard string to be converted to a Qt string |
Definition at line 880 of file IString.cpp.
|
static |
Converts a vector of strings into a QStringList.
sl | STL vector of strings |
Definition at line 1346 of file IString.cpp.
References ToQt().
|
static |
Converts a Qt string into a std::string.
str | [in] The Qt string to be converted to a std::string |
Definition at line 1333 of file IString.cpp.
Referenced by Isis::SqlQuery::fieldName(), Isis::SqlQuery::fieldNameList(), Isis::SqlQuery::getQuery(), Isis::SqlQuery::tossQueryError(), and ToStd().
|
static |
Converts a QStringList into a vector of strings.
sl |
Definition at line 1363 of file IString.cpp.
References ToStd().
IString Isis::IString::Trim | ( | const std::string & | chars | ) |
Removes characters from the beginning and end of the IString.
The order of the characters makes no difference.
chars | The string of characters to be trimmed |
Definition at line 525 of file IString.cpp.
References TrimHead(), and TrimTail().
Referenced by IsisAml::CommandLine(), Isis::ImportPdsTable::extract(), Isis::Kernels::getTypes(), Isis::MocLabels::InitWago(), and Isis::Kernels::resolveType().
|
static |
Removes all occurences of the input characters from the beginning and end of the input string.
chars | The string of characters to be removed. Order makes no difference |
str | The input string to be trimmed |
Definition at line 544 of file IString.cpp.
References TrimHead(), and TrimTail().
IString Isis::IString::TrimHead | ( | const std::string & | chars | ) |
Trims The input characters from the beginning of the object IString.
chars | The string of characters to be trimmed. Order makes no difference |
Definition at line 558 of file IString.cpp.
Referenced by Isis::ProcessImportFits::extractFitsLabels(), Isis::FileList::read(), and Trim().
|
static |
Trims the input characters from the beginning of the input string.
chars | The input characters to be removed. Order makes no difference |
str | The string to be trimmed |
Definition at line 573 of file IString.cpp.
IString Isis::IString::TrimTail | ( | const std::string & | chars | ) |
Trims the input characters from the end of the object IString.
chars | The string of characters to be removed. Order is irrelevant |
Definition at line 587 of file IString.cpp.
Referenced by Isis::ProcessImportFits::extractFitsLabels(), Isis::FileList::read(), and Trim().
|
static |
Trims the input characters from the end of the input string.
chars | The characters to be removed from the input string. Order does not matter, all characters are treated individually. |
str | The string to be trimmed |
Definition at line 604 of file IString.cpp.
IString Isis::IString::UpCase | ( | ) |
Converst any lower case characters in the object IString with uppercase characters.
Definition at line 617 of file IString.cpp.
Referenced by IsisAml::CommandLine(), Isis::MdisCamera::computeFocalLength(), Isis::Kernels::examine(), Isis::AtmosModel::GenerateAhTable(), Isis::Kernels::getTypes(), Isis::TableRecord::operator[](), Isis::GridPolygonSeeder::Parse(), Isis::PvlKeyword::reform(), IsisAml::ReturnParam(), Isis::AtmosModel::SetAtmosEstTau(), Isis::AtmosModel::SetAtmosIord(), Isis::AtmosModel::SetAtmosNulneg(), Isis::Hapke::SetPhoto0B0Standard(), Isis::PvlKeyword::stringEqual(), and IsisAml::Verify().
|
static |
Converts lower case characters in the input string to upper case characters.
str | The string to be converted |
Definition at line 632 of file IString.cpp.