63     falses.append(
"false");
 
   71     bool foundMatch = 
false;
 
   73     QListIterator<QString> truesIterator(trues);
 
   74     while (!foundMatch && truesIterator.hasNext()) {
 
   75       foundMatch = (
string.compare(truesIterator.next(), Qt::CaseInsensitive) == 0);
 
   81       QListIterator<QString> falsesIterator(falses);
 
   82       while (!foundMatch && falsesIterator.hasNext()) {
 
   83         foundMatch = (
string.compare(falsesIterator.next(), Qt::CaseInsensitive) == 0);
 
   90       QString message = QObject::tr(
"Failed to convert string [%1] to a boolean. " 
   91           "Please specify one of [%2] for true, or one of [%3] for false.")
 
   92             .arg(
string).arg(trues.join(
", ")).arg(falses.join(
", "));
 
  111     int result = 
string.toInt(&ok);
 
  114       QString message = QObject::tr(
"Failed to convert string [%1] to an integer").arg(
string);
 
  135       s << 
string.toStdString();            
 
  136       s.seekg(0, std::ios::beg);     
 
  138       std::ios::iostate state = s.rdstate();
 
  139       if((state & std::ios::failbit) || (state & std::ios::badbit) ||
 
  140           (!(state & std::ios::eofbit))) {  
 
  145       QString message = QObject::tr(
"Failed to convert string [%1] to a big integer").arg(
string);
 
  167     if (
string.startsWith(
"16#") && 
string.endsWith(
"#")) {
 
  170         s << 
string.mid(3, 
string.size() - 3);
 
  171         s.seekg(0, ios::beg);
 
  174           unsigned int intData;
 
  178         s >> hex >> raw.intData;
 
  180         ios::iostate state = s.rdstate();
 
  181         if((state & ios::failbit) || (state & ios::badbit)) {
 
  185         result = raw.floatData;
 
  188         QString message = QObject::tr(
"Failed to convert HEX string [%1] to a " 
  189                             "double").arg(
string);
 
  195       if (knownStrings.isEmpty()) {
 
  197         knownStrings[
"1.79769313486232e+308"]  = DBL_MAX;
 
  198         knownStrings[
"-1.79769313486232e+308"] = -DBL_MAX;
 
  202       if (!knownStrings.contains(
string)) {
 
  203         result = 
string.toDouble(&ok);
 
  206         result = knownStrings[string];
 
  210         QString message = QObject::tr(
"Failed to convert string [%1] to a double").arg(
string);
 
  227     return boolToConvert? 
"Yes" : 
"No";
 
  241     result += QChar(charToConvert);
 
  253     return QString::number(intToConvert);
 
  263   QString 
toString(
const unsigned int &intToConvert) {
 
  264     return QString::number(intToConvert);
 
  275     return QString::number(intToConvert);
 
  292   QString 
toString(
double doubleToConvert, 
int precision) {
 
  297     if(doubleToConvert == 0.0) {
 
  300     else if(isnan(doubleToConvert)) {
 
  304     if(doubleToConvert > DBL_MAX) {
 
  305       doubleToConvert = DBL_MAX;
 
  308     if(doubleToConvert < -DBL_MAX) {
 
  309       doubleToConvert = -DBL_MAX;
 
  318       double temp = qAbs(doubleToConvert);
 
  319       int pre = (int)(log10(temp)) + 1;
 
  334       char doubleString[23];
 
  336       if((log10(temp) > 13.0) || (log10(temp) < -3.0)) {
 
  337         char format[8], buffer[8];
 
  338         snprintf(buffer, 8, 
"%de", precision);
 
  339         strcpy(format, 
"%21.");
 
  340         strcat(format, buffer);
 
  341         snprintf(doubleString, 23, format, doubleToConvert);
 
  343         char *e = strchr(doubleString, 
'e');
 
  346         while(*sptr == 
'0') {
 
  359         e = strchr(doubleString, 
'e');
 
  362         for(sptr = e + 2; *sptr; sptr++) {
 
  381         int post = precision - pre;
 
  383         char tempStr[3], format[8];
 
  384         strcpy(format, 
"%17.");
 
  385         snprintf(tempStr, 3, 
"%d", post);
 
  386         strcat(format, tempStr);
 
  389         snprintf(doubleString, 23, format, doubleToConvert);
 
  392           char *sptr = doubleString + strlen(doubleString) - 1;
 
  393           while((*sptr == 
'0') && (*(sptr - 1) != 
'.')) {
 
  400       while(doubleString[0] == 
' ') {
 
  401         for(
unsigned int i = 0; i < strlen(doubleString); i++) {
 
  402           doubleString[i] = doubleString[i + 1];
 
  406       result = QString(doubleString);
 
  418   IString::IString() : string() {
 
  510     *
this = 
toString(num, piPrecision).toStdString();
 
  520     assign(str.toStdString());
 
  559   std::string 
IString::Trim(
const std::string &chars, 
const std::string &str) {
 
  574     *
this = replace(0, find_first_not_of(chars), 
"");
 
  590     result.replace(0, str.find_first_not_of(chars), 
"");
 
  603     *
this = erase(find_last_not_of(chars) + 1);
 
  621     result.erase(str.find_last_not_of(chars) + 1);
 
  649     transform(str.begin(), str.end(), sOut.begin(), (int ( *)(int)) toupper);
 
  676     transform(str.begin(), str.end(), sOut.begin(), (int ( *)(int))tolower);
 
  693     return(toupper(c1) == toupper(c2));
 
  707     return Equal(str, temp);
 
  721     if(str1.size() != str2.size()) 
return(
false);
 
  722     return(std::equal(str1.begin(), str1.end(), str2.begin(), 
nocase_compare));
 
  751       s.seekg(0, ios::beg);     
 
  753       ios::iostate state = s.rdstate();
 
  754       if((state & ios::failbit) || (state & ios::badbit) ||
 
  755           (!(state & ios::eofbit))) {  
 
  760       string message = 
"Failed to convert string [" + str + 
"] to an integer";
 
  791       s.seekg(0, ios::beg);     
 
  793       ios::iostate state = s.rdstate();
 
  794       if((state & ios::failbit) || (state & ios::badbit) ||
 
  795           (!(state & ios::eofbit))) {  
 
  800       string message = 
"Failed to convert string [" + str + 
"] to a big " 
  832     if(str.substr(0, 3) == 
"16#" && str.substr(str.length() - 1, 1) == 
"#") {
 
  835         s << str.substr(3, str.find_last_of(
"#") - 3);
 
  836         s.seekg(0, ios::beg);
 
  845         ios::iostate state = s.rdstate();
 
  846         if((state & ios::failbit) || (state & ios::badbit)) {
 
  852         string message = 
"Failed to convert HEX string [" + str + 
"] to a " 
  862         s.seekg(0, ios::beg);     
 
  864         ios::iostate state = s.rdstate();
 
  865         if((state & ios::failbit) || (state & ios::badbit) ||
 
  866             (!(state & ios::eofbit))) {  
 
  871         string message = 
"Failed to convert string [" + str + 
"] to a double";
 
  885     return QString::fromStdString(*
this);
 
  896     return(QString::fromStdString(s));
 
  915     for(
unsigned int i = 0; i < size(); i++) {
 
  916       for(
unsigned int sep = 0; sep < separator.size(); sep++) {
 
  917         if(separator[sep] == at(i)) {
 
  918           retstr = substr(0, i);
 
  919           replace(0, i + 1, 
"");
 
  927       replace(0, size(), 
"");
 
  956                      std::vector<std::string> &tokens,
 
  957                      bool allowEmptyEntries) {
 
  958     string::size_type idx(0), idx2(0);
 
  959     unsigned int ksize = str.size();
 
  963       if(str[idx] == separator) idx++;
 
  964       while((idx2 = str.find(separator, idx)) != string::npos) {
 
  966           if(allowEmptyEntries) tokens.push_back(
"");
 
  969           string::size_type len(idx2 - idx);
 
  970           tokens.push_back(str.substr(idx, len));
 
  974       if(idx < ksize) tokens.push_back(str.substr(idx));
 
  976     return(tokens.size());
 
  990     *
this =  
Compress((
string) * 
this, force);
 
 1007     if(force == 
false) {
 
 1009       int leftquote = result.find_first_of(
"\"\'");
 
 1010       while((spaces = result.find(
"  ", spaces)) >= 0) {
 
 1011         int rightquote = result.find_first_of(
"\"\'", leftquote + 1);
 
 1012         if(spaces < leftquote) { 
 
 1013           result.erase(spaces, 1);
 
 1014           leftquote = result.find_first_of(
"\"\'", spaces);
 
 1016         else if((spaces > leftquote) && (spaces < rightquote)) {   
 
 1017           spaces = rightquote + 1;
 
 1018           leftquote = result.find_first_of(
"\"\'", rightquote + 1);
 
 1020         else if(leftquote == (
int)npos) {   
 
 1021           result.erase(spaces, 1);
 
 1024           leftquote = result.find_first_of(
"\"\'", rightquote + 1);
 
 1031       while((spaces = result.find(
"  ", spaces)) >= 0) {
 
 1032         result.erase(spaces, 1);
 
 1053                            int maxReplaceCount) {
 
 1054     *
this = 
IString(
Replace((
string) * 
this, from, to, maxReplaceCount));
 
 1107                                const std::string &to, 
int maxReplaceCount) {
 
 1108     if(str.empty()) 
return(str);
 
 1109     if(from.empty()) 
return(str);
 
 1111     string::size_type pos;
 
 1113     while((nReplaced < maxReplaceCount) &&
 
 1114           (pos = sRet.find(from)) != string::npos) {
 
 1115       sRet.replace(pos, from.size(), to);
 
 1140     *
this = 
Replace((
string) * 
this, from, to, honorquotes);
 
 1163                            const std::string &to , 
bool honorquotes) {
 
 1165     string result = str;
 
 1166     if(honorquotes == 
true) {
 
 1168       int quote = result.find_first_of(
"\"\'");
 
 1169       while((instances = result.find(from, instances)) >= 0) {
 
 1171         int nextquote = result.find_first_of(
"\"\'", quote + 1);
 
 1172         if(instances < quote) {
 
 1173           result.replace(instances, from.length(), to);
 
 1174           quote = result.find_first_of(
"\"\'", instances);
 
 1176         else if((instances > quote) && (instances < nextquote)) {
 
 1177           instances = nextquote + 1;
 
 1178           quote = result.find_first_of(
"\"\'", nextquote);
 
 1180         else if(quote == (
int)npos) {
 
 1181           result.replace(instances, from.length(), to);
 
 1184           quote = result.find_first_of(
"\"\'", nextquote);
 
 1191       while((instances = result.find(from, instances)) >= 0) {
 
 1192         result.replace(instances, from.length(), to);
 
 1212     *
this = 
Convert((
string) * 
this, listofchars, to);
 
 1233     std::string::size_type pos = 0;
 
 1234     string result = str;
 
 1237     while((pos = result.find_first_of(listofchars, pos)) != npos) {
 
 1238       result.replace(pos, 1, tmp);
 
 1268     return Convert(str, 
"\n\r\t\f\v\b", 
' ');
 
 1282     std::string::size_type pos;
 
 1283     while((pos = find_first_of(del)) != npos) this->erase(pos, 1);
 
 1301     string::size_type pos;
 
 1303     while((pos = result.find_first_of(del)) != npos) result.erase(pos, 1);
 
 1349     return(str.toStdString());
 
 1363     for(
unsigned int i = 0 ; i < sl.size() ; i++) {
 
 1379     std::vector<std::string> Stdsl;
 
 1380     for(
int i = 0 ; i < sl.size() ; i++) {
 
 1381       Stdsl.push_back(
ToStd(sl.at(i)));
 
 1399   std::ostream &
operator<<(std::ostream &outputStream, 
const QString &
string) {
 
 1400     return (outputStream << 
string.toLatin1().data());
 
 1415   std::ostream &
operator<<(std::ostream &outputStream, 
const QStringRef &
string) {
 
 1416     return (outputStream << 
string.
toString().toLatin1().data());
 
IString()
Constructs an empty IString object. 
 
BigInt ToBigInteger() const 
Returns the BigInt representation of the object IString. 
 
QString ToQt() const 
Retuns the object string as a QString. 
 
bool Equal(const std::string &str) const 
Compare a string to the object IString. 
 
double ToDouble() const 
Returns the floating point value the IString represents. 
 
static std::string ToStd(const QString &str)
Converts a Qt string into a std::string. 
 
int toInt(const QString &string)
Global function to convert from a string to an integer. 
 
IString & operator=(const int &value)
Attempts to convert the stirng to a QStirng (Qt) and return that IString. 
 
IString TrimHead(const std::string &chars)
Trims The input characters from the beginning of the object IString. 
 
int ToInteger() const 
Returns the object string as an integer. 
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string. 
 
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. 
 
BigInt toBigInt(const QString &string)
Global function to convert from a string to a "big" integer. 
 
double toDouble(const QString &string)
Global function to convert from a string to a double. 
 
static bool nocase_compare(const char c1, const char c2)
Compare two characters without regard to case. 
 
IString Compress(bool force=false)
Collapses multiple spaces into single spaces. 
 
IString Token(const IString &separator)
Returns the first token in the IString. 
 
#define _FILEINFO_
Macro for the filename and line number. 
 
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"...
 
A type of error that cannot be classified as any of the other error types. 
 
IString Remove(const std::string &del)
Remove all instances of any character in the string from the IString. 
 
IString DownCase()
Converts all upper case letters in the object IString into lower case characters. ...
 
void SetDouble(const double &value, const int piPrecision=14)
Performs the conversion necessary to represent a floating-point value as a string. 
 
bool toBool(const QString &string)
Global function to convert from a string to a boolean. 
 
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. 
 
Adds specific functionality to C++ strings. 
 
IString ConvertWhiteSpace()
Returns the string with all "new lines", "carriage returns", "tabs", "form feeds", "vertical tabs" and "back spaces" converted to single spaces. 
 
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object. 
 
IString UpCase()
Converst any lower case characters in the object IString with uppercase characters. 
 
IString TrimTail(const std::string &chars)
Trims the input characters from the end of the object IString. 
 
IString Trim(const std::string &chars)
Removes characters from the beginning and end of the IString.