USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::IString Class Reference
[Parsing]

Adds specific functionality to C++ strings. More...

#include <IString.h>

Inherits std::string.

List of all members.

Public Member Functions

 IString ()
 Constructs an empty IString object.
 IString (const std::string &str)
 Constructs a IString object with initial value set to the string argument.
 IString (const IString &str)
 Constructs a IString with initial value set to the IString argument.
 IString (const char *str)
 Constructs a IString with initial value set to the argument.
 IString (const int &num)
 Constructs a IString object with its initial value set to the string representation of the int argument.
 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.
 IString (const BigInt &num)
 Constructs a IString object with its initial value set to the string representation of the BigInt argument.
 IString (const QString &str)
 Constructs a IString object with initial value set to the input QString.
 ~IString ()
 Destructor.
IString Trim (const std::string &chars)
 Removes characters from the beginning and end of the IString.
IString TrimHead (const std::string &chars)
 Trims The input characters from the beginning of the object IString.
IString TrimTail (const std::string &chars)
 Trims the input characters from the end of the object IString.
IString UpCase ()
 Converst any lower case characters in the object IString with uppercase characters.
IString DownCase ()
 Converts all upper case letters in the object IString into lower case characters.
int ToInteger () const
 Returns the object string as an integer.
BigInt ToBigInteger () const
 Returns the BigInt representation of the object IString.
double ToDouble () const
 Returns the floating point value the IString represents.
QString ToQt () const
 Retuns the object string as a QString.
IString Token (const IString &separator)
 Returns the first token in the IString.
IString Compress (bool force=false)
 Collapses multiple spaces into single spaces.
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.
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.
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.
IString ConvertWhiteSpace ()
 Returns the string with all "new lines", "carriage returns", "tabs", "form feeds", "vertical tabs" and "back spaces" converted to single spaces.
IString Remove (const std::string &del)
 Remove all instances of any character in the string from the IString.
 operator int () const
 Attempts to convert the stirng to a 32 bit integer and return that int.
 operator BigInt () const
 Attempts to convert the stirng to a 64 bit integer and return that int.
 operator double () const
 Attempts to convert the stirng to a 64 bit double and return that double.
 operator IString () const
 Attempts to convert the stirng to a QStirng (Qt) and return that IString.
IStringoperator= (const int &value)
 Attempts to convert a 32 bit integer into its string representation.
IStringoperator= (const BigInt &value)
 Attempts to convert a 64 bit integer into its string representation.
IStringoperator= (const double &value)
 Attempts to convert double into its string representation.
bool Equal (const std::string &str) const
 Compare a string to the object IString.

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.
static std::string TrimHead (const std::string &chars, const std::string &str)
 Trims the input characters from the beginning of the input string.
static std::string TrimTail (const std::string &chars, const std::string &str)
 Trims the input characters from the end of the input string.
static std::string UpCase (const std::string &str)
 Converts lower case characters in the input string to upper case characters.
static std::string DownCase (const std::string &str)
 Converts all upper case letters in the input string into lower case characters.
static int ToInteger (const std::string &str)
 Returns the integer representation of the input string.
static BigInt ToBigInteger (const std::string &str)
 Returns the Big Integer representation of the input string.
static double ToDouble (const std::string &str)
 Returns the floating-point value represented by the input string.
static QString ToQt (const std::string &str)
 Returns the input string as a QString.
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.
static std::string Compress (const std::string &str, bool force=false)
 Returns the input string with multiple spaces collapsed into single spaces.
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.
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.
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.
static std::string ConvertWhiteSpace (const std::string &str)
 Converts all forms of whitespace in the input string into single spaces.
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.
static bool Equal (const std::string &str1, const std::string &str2)
 Compare two strings, case-insensitive.
static std::string ToStd (const QString &str)
 Converts a Qt string into a std::string.
static QStringList ToQt (const std::vector< std::string > &sl)
 Converts a vector of strings into a QStringList.
static std::vector< std::string > ToStd (const QStringList &sl)
 Converts a QStringList into a vector of strings.

Detailed Description

Adds specific functionality to C++ strings.

This class extends the standard C++ string class with specific functionality useable by ISIS programmers.

Author:
2002-09-10 Stuart Sides

Constructor & Destructor Documentation

Isis::IString::IString (  ) 

Constructs an empty IString object.

Deprecated:

Referenced by Replace().

Isis::IString::IString ( const std::string &  str  ) 

Constructs a IString object with initial value set to the string argument.

Deprecated:
Parameters:
str The initial value of the IString
Isis::IString::IString ( const IString str  ) 

Constructs a IString with initial value set to the IString argument.

Deprecated:
Parameters:
str The initial value of the IString
Isis::IString::IString ( const char *  str  ) 

Constructs a IString with initial value set to the argument.

Deprecated:
Parameters:
str The inital value of the IString
Isis::IString::IString ( const int &  num  ) 

Constructs a IString object with its initial value set to the string representation of the int argument.

Deprecated:
Parameters:
num The initial value of the IString. The integer value is converted to a string representation and stored as the value.
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.

Deprecated:
Parameters:
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
Isis::IString::IString ( const BigInt num  ) 

Constructs a IString object with its initial value set to the string representation of the BigInt argument.

Deprecated:
Parameters:
num The initial value of the IString. The integer value is converted to a string representation and stored as the value.
Isis::IString::IString ( const QString &  str  ) 

Constructs a IString object with initial value set to the input QString.

Deprecated:
Parameters:
str 
Isis::IString::~IString (  ) 

Destructor.

Deprecated:

Member Function Documentation

std::string Isis::IString::Compress ( const std::string &  str,
bool  force = false 
) [static]

Returns the input string with multiple spaces collapsed into single spaces.

Deprecated:
Parameters:
str The string to be compressed
force Determines whether to compress inside quotes
Returns:
string The compressed version of the input string
IString Isis::IString::Compress ( bool  force = false  ) 

Collapses multiple spaces into single spaces.

Deprecated:
Parameters:
force Determines whether to compress inside quotes (single and double)
string Isis::IString::Convert ( const std::string &  str,
const std::string &  listofchars,
const char &  to 
) [static]

Converts all occurences in the input string of any character in the "from" string to the "to" character.

Deprecated:
Parameters:
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
Returns:
string The converted string (the input string is unmodified)
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.

Deprecated:
Parameters:
listofchars The string of characters to be replaced. The order of the characters is not important.
to The single character used as the replacement.
Returns:
IString

Referenced by ConvertWhiteSpace(), Isis::ImageFileListWidget::fromPvl(), and Isis::ImageFileListWidget::toPvl().

std::string Isis::IString::ConvertWhiteSpace ( const std::string &  str  )  [static]

Converts all forms of whitespace in the input string into single spaces.

Deprecated:
Parameters:
str 
Returns:
string

References Convert().

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.

Deprecated:
Returns:
IString

Referenced by Isis::PvlKeyword::stringEqual().

std::string Isis::IString::DownCase ( const std::string &  str  )  [static]

Converts all upper case letters in the input string into lower case characters.

Deprecated:
Parameters:
str 
Returns:
string
IString Isis::IString::DownCase (  ) 
bool Isis::IString::Equal ( const std::string &  str1,
const std::string &  str2 
) [static]

Compare two strings, case-insensitive.

Deprecated:
Parameters:
str1 [in] The first string to compare
str2 [in] The second string to compare
Returns:
True if the two input strings are identical otherwise false

References Isis::nocase_compare().

bool Isis::IString::Equal ( const std::string &  str  )  const

Compare a string to the object IString.

Deprecated:
Parameters:
str The string with which the comparison is made
Returns:
bool True if they are equal, false if they are not.

Referenced by Isis::DatabaseFactory::remove().

Isis::IString::operator BigInt (  )  const [inline]

Attempts to convert the stirng to a 64 bit integer and return that int.

Returns:
BigInt

References ToBigInteger().

Isis::IString::operator double (  )  const [inline]

Attempts to convert the stirng to a 64 bit double and return that double.

Returns:
double

References ToDouble().

Isis::IString::operator int (  )  const [inline]

Attempts to convert the stirng to a 32 bit integer and return that int.

Returns:
int

References ToInteger().

Isis::IString::operator IString (  )  const [inline]

Attempts to convert the stirng to a QStirng (Qt) and return that IString.

Returns:
IString

References ToQt().

IString& Isis::IString::operator= ( const double &  value  )  [inline]

Attempts to convert double into its string representation.

Parameters:
value [in] The double to be converted to a string
Returns:
The IString representation of the double
IString & Isis::IString::operator= ( const BigInt value  ) 

Attempts to convert a 64 bit integer into its string representation.

Deprecated:
Parameters:
value [in] The 64 bit integer to be converted to a string
Returns:
The Isis::IString representation of the BigInt
IString & Isis::IString::operator= ( const int &  value  ) 

Attempts to convert a 32 bit integer into its string representation.

Deprecated:
Parameters:
value [in] The 32 bit integer to be converted to a string
Returns:
The Isis::IString representation of the int
std::string Isis::IString::Remove ( const std::string &  str,
const std::string &  del 
) [static]

Remove all instances of any character in the "del" argument from the input string.

Deprecated:
Parameters:
str The string from which characters are to be removed
del The string of characters to be removed. Order is unimportant.
Returns:
string The string with the characters removed. The original string is unmodified
IString Isis::IString::Remove ( const std::string &  del  ) 

Remove all instances of any character in the string from the IString.

Deprecated:
Parameters:
del The characters to be removed from the IString. The character is unimportant
Returns:
IString

Referenced by Isis::InfixToPostfix::convert(), and Isis::PvlKeyword::stringEqual().

IString Isis::IString::Replace ( const std::string &  str,
const std::string &  from,
const std::string &  to,
bool  honorquotes 
) [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.

Deprecated:
Parameters:
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
Returns:
IString New string with subTarg replaced with subRep
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

Deprecated:
Parameters:
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
Returns:
IString New string with subTarg replaced with subRep

References Replace().

std::string Isis::IString::Replace ( const std::string &  str,
const std::string &  from,
const std::string &  to,
int  maxReplaceCount = 20 
) [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:

   string pntDist  = "distance(giscpt,UPCPoint(%longitude,%latitude))";
   string pntQuery = "SELECT pointid, latitude, longitude, radius, "
                     " %distance AS Distance FROM "  + pntTable +
                     " WHERE (%distance <= " + IString(maxDist) + ")";

 SqlQuery finder;  // Uses whatever the default database is
 while (!theEndOfTime()) {
    IString longitude(source.getLongitude());
    IString latitude(source.getLatitude());

    string qDist = StringTools::replace(pntDist,"%longitude", longitude);
    qDist = StringTools::replace(qDist,"%latitude", latitude);
    string query = StringTools::replace(pntQuery, "%distance", qDist);
    finder.exec(query);
    ... //  Do what you will with the results!
 }

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.

Deprecated:
Parameters:
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
Returns:
std::string NEw string with from replaced with to
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)

Deprecated:
Parameters:
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

References IString().

Referenced by Replace().

int Isis::IString::Split ( const char  separator,
const std::string &  str,
std::vector< std::string > &  tokens,
bool  allowEmptyEntries = true 
) [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.

Deprecated:
Parameters:
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.
Returns:
int The number of fields/tokens found in str
BigInt Isis::IString::ToBigInteger ( const std::string &  str  )  [static]

Returns the Big Integer representation of the input string.

Deprecated:
Parameters:
str The string representing an integer value
Returns:
BigInt The string as a BigInt

References _FILEINFO_, and Isis::IException::Unknown.

BigInt Isis::IString::ToBigInteger (  )  const

Returns the BigInt representation of the object IString.

Deprecated:
Returns:
BigInt The Big Integer representation of the IString

Referenced by operator BigInt().

double Isis::IString::ToDouble ( const std::string &  str  )  [static]

Returns the floating-point value represented by the input string.

Deprecated:
Parameters:
str The string representing the numeric value
Returns:
double The number the string represents

References _FILEINFO_, and Isis::IException::Unknown.

double Isis::IString::ToDouble (  )  const

Returns the floating point value the IString represents.

Deprecated:
Returns:
double The IString as a double

Referenced by IsisAml::GetDouble(), operator double(), and Isis::CubeCalculator::prepareCalculations().

int Isis::IString::ToInteger ( const std::string &  str  )  [static]

Returns the integer representation of the input string.

Deprecated:
Parameters:
str The string representing an integer value
Returns:
int The integer value represented by the string

References _FILEINFO_, and Isis::IException::Unknown.

int Isis::IString::ToInteger (  )  const

Returns the object string as an integer.

Deprecated:
Returns:
int The integer te string represents

Referenced by Isis::Workspace::addCubeViewport(), IsisAml::GetInteger(), Isis::KernelDb::matches(), and operator int().

IString Isis::IString::Token ( const IString separator  ) 

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.

Deprecated:
Parameters:
separator The string of characters used to separate tokens. The order of the characters is not important.
Returns:
IString

Referenced by Isis::PvlKeyword::addCommentWrapped(), Isis::InfixToPostfix::convert(), Isis::KernelDb::matches(), Isis::CubeCalculator::prepareCalculations(), Isis::FileList::read(), Isis::SocketThread::run(), Isis::UserInterface::SetBatchList(), Isis::MinnaertEmpirical::SetPhotoKList(), Isis::LunarLambertEmpirical::SetPhotoLList(), Isis::MinnaertEmpirical::SetPhotoPhaseCurveList(), Isis::LunarLambertEmpirical::SetPhotoPhaseCurveList(), Isis::MinnaertEmpirical::SetPhotoPhaseList(), and Isis::LunarLambertEmpirical::SetPhotoPhaseList().

QStringList Isis::IString::ToQt ( const std::vector< std::string > &  sl  )  [static]

Converts a vector of strings into a QStringList.

Deprecated:
Parameters:
sl STL vector of strings
Returns:
QStringList

References ToQt().

QString Isis::IString::ToQt ( const std::string &  s  )  [static]

Returns the input string as a QString.

Deprecated:
Parameters:
s [in] The standard string to be converted to a Qt string
QString Isis::IString::ToQt (  )  const
std::vector< std::string > Isis::IString::ToStd ( const QStringList sl  )  [static]

Converts a QStringList into a vector of strings.

Deprecated:
Parameters:
sl 
Returns:
vector<string>

References ToStd().

std::string Isis::IString::ToStd ( const QString &  str  )  [static]

Converts a Qt string into a std::string.

Deprecated:
Parameters:
str [in] The Qt string to be converted to a std::string
Returns:
The std::string representation of the Qt string

Referenced by Isis::SqlQuery::fieldName(), Isis::SqlQuery::fieldNameList(), Isis::SqlQuery::getQuery(), and ToStd().

std::string Isis::IString::Trim ( const std::string &  chars,
const std::string &  str 
) [static]

Removes all occurences of the input characters from the beginning and end of the input string.

Deprecated:
Parameters:
chars The string of characters to be removed. Order makes no difference
str The input string to be trimmed
Returns:
string The result of the trimming operation

References TrimHead(), and TrimTail().

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.

Deprecated:
Parameters:
chars The string of characters to be trimmed
Returns:
IString

References TrimHead(), and TrimTail().

Referenced by IsisAml::CommandLine().

std::string Isis::IString::TrimHead ( const std::string &  chars,
const std::string &  str 
) [static]

Trims the input characters from the beginning of the input string.

Deprecated:
Parameters:
chars The input characters to be removed. Order makes no difference
str The string to be trimmed
Returns:
string The resulting string
IString Isis::IString::TrimHead ( const std::string &  chars  ) 

Trims The input characters from the beginning of the object IString.

Deprecated:
Parameters:
chars The string of characters to be trimmed. Order makes no difference

Referenced by Isis::FileList::read(), and Trim().

std::string Isis::IString::TrimTail ( const std::string &  chars,
const std::string &  str 
) [static]

Trims the input characters from the end of the input string.

Deprecated:
Parameters:
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
Returns:
string The result of the trimming
IString Isis::IString::TrimTail ( const std::string &  chars  ) 

Trims the input characters from the end of the object IString.

Deprecated:
Parameters:
chars The string of characters to be removed. Order is irrelevant

Referenced by Isis::FileList::read(), and Trim().

std::string Isis::IString::UpCase ( const std::string &  str  )  [static]

Converts lower case characters in the input string to upper case characters.

Deprecated:
Parameters:
str The string to be converted
Returns:
string The result of the conversion
IString Isis::IString::UpCase (  ) 

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