28 static ossimTrace traceDebug(
"ossimString:debug");
30 #ifdef OSSIM_ID_ENABLED 31 static char OSSIM_ID[] =
"$Id: ossimString.cpp 22160 2013-02-25 12:09:35Z gpotts $";
36 std::string s = aString.
string();
38 std::string::iterator eachCharacter = s.begin();
39 while(eachCharacter != s.end())
41 *eachCharacter = toupper(*eachCharacter);
50 std::string s = aString.
m_str;
52 std::string::iterator eachCharacter = s.begin();
53 while(eachCharacter != s.end())
55 *eachCharacter = tolower(*eachCharacter);
64 std::string::iterator eachCharacter =
m_str.begin();
65 while(eachCharacter !=
m_str.end())
67 *eachCharacter = toupper(*eachCharacter);
83 std::string::iterator eachCharacter =
m_str.begin();
84 while(eachCharacter !=
m_str.end())
86 *eachCharacter = tolower(*eachCharacter);
106 result =
new char[1];
113 result =
new char[len+1];
114 const char* sourceString =
m_str.c_str();
118 result[index] = sourceString[index];
131 while((*stringIter == characterToStrip)&&(stringIter!=value.
m_str.end()))
136 while(stringIter != value.
m_str.end())
147 bool replaceAll)
const 149 std::string result =
m_str;
153 if (pos == std::string::npos)
return result;
157 while(pos != std::string::npos)
159 result.replace(pos, searchKey.
m_str.size(), replacementValue.
m_str.c_str());
160 pos = result.find(searchKey.
m_str, pos+replacementValue.
m_str.size());
165 result.replace(pos, searchKey.
m_str.size(), replacementValue.
m_str.c_str());
177 if (pos == std::string::npos)
return *
this;
181 while(pos <
m_str.size())
183 m_str.replace(pos, searchKey.
m_str.size(), replacementValue.
m_str.c_str());
189 m_str.replace(pos, searchKey.
m_str.size(), replacementValue.
m_str.c_str());
199 return tempString.
trim(valueToTrim);
204 if(
m_str.size() == 0)
return *
this;
205 if(valueToTrim.
empty())
return *
this;
207 iterator endPos = (*this).begin() + ((*this).size()-1);
209 while( ( startPos != (*this).end() ) &&
210 (std::find(valueToTrim.
begin(),
212 *startPos)!=valueToTrim.
end()) ) ++startPos;
214 if(startPos == (*this).end())
220 while( (endPos!=startPos)&& (std::find(valueToTrim.
begin(),
222 *endPos)!=valueToTrim.
end())) --endPos;
240 result.
erase(0, pos+1);
254 std::vector<ossimString> result;
255 char* tokenPtr = strtok((
char*)exp_str.
c_str(), (
char*)delimeter.
c_str());
257 while(tokenPtr != NULL)
260 tokenPtr = strtok(NULL, delimeter.
c_str());
269 std::stack<ossim_uint32> startChars;
274 startChars.push(regExpStart.
start());
275 while(!startChars.empty())
281 if(regExpStart.
find(result.
c_str()+offset))
284 startChars.push(regExpStart.
start()+offset);
290 if(regExpEnd.
find(result.
c_str()+startChars.top()))
293 result.
begin()+startChars.top()+regExpEnd.
start());
294 const char* lookup = getenv( envVarStr.c_str() );
298 result.
begin()+startChars.top()+regExpEnd.
start()+1,
306 <<
"In member function ossimString::expandEnvironmentVariable() " 307 <<
"\n\tERROR: Environment variable(" 313 result.
begin()+startChars.top()+regExpEnd.
start()+1,
334 anExpression.
compile(regularExpressionPattern);
338 if (anExpression.
start() > 0)
351 anExpression.
compile(regularExpressionPattern);
368 anExpression.
compile(regularExpressionPattern);
372 if (anExpression.
end() <
size())
385 anExpression.
compile(regularExpressionPattern);
387 if((anExpression.
find(this->c_str())) &&
388 (anExpression.
start() !=anExpression.
end()))
391 anExpression.
end() - anExpression.
start() );
399 const char *value)
const 403 std::string::size_type offset = 0;
404 std::string::size_type valueLength =
ossimString(value).length();
405 anExpression.
compile(regularExpressionPattern);
410 while(anExpression.
find(result.
c_str()+offset))
412 if(anExpression.
start() < anExpression.
end())
415 anExpression.
end()-anExpression.
start(),
417 offset += anExpression.
start() + valueLength;
429 const char *value)
const 433 anExpression.
compile(regularExpressionPattern);
440 if(anExpression.
start() < anExpression.
end())
443 anExpression.
end()-anExpression.
start(),
461 if ( (s ==
"true") ||
468 else if ( (s ==
"false") ||
493 if ( (s ==
"true") ||
500 else if ( (s ==
"false") ||
562 return aString.
toInt();
712 if((result != 0)&&
size()>0)
716 if ( byteType ==
"K")
720 else if ( byteType ==
"M")
724 else if ( byteType ==
"G")
728 else if( byteType ==
"T")
976 s << std::setprecision(precision);
980 s << std::setiosflags(std::ios::fixed);
998 s << std::setprecision(precision);
1002 s << std::setiosflags(std::ios::fixed);
1011 std::string::size_type pos)
const 1016 if(last >= std::string::npos)
return *
this;
1022 std::string::size_type pos)
const 1025 if (last >= std::string::npos)
return ossimString();
1037 bool skipBlankFields)
const 1039 if(this->
empty())
return;
1041 std::string::const_iterator iterStart =
m_str.begin();
1042 std::string::const_iterator iterCurrent =
m_str.begin();
1044 while(iterCurrent !=
m_str.end())
1046 if(std::find(separatorList.
m_str.begin(), separatorList.
m_str.end(), *iterCurrent) != separatorList.
m_str.end())
1048 if(iterStart == iterCurrent)
1050 if(!skipBlankFields)
1057 result.push_back(
ossimString(iterStart, iterCurrent));
1061 iterStart = iterCurrent;
1068 if(iterStart!=iterCurrent)
1070 result.push_back(
ossimString(iterStart, iterCurrent));
1077 char* s = strtok(const_cast<char*>(copyString.
c_str()),
1078 separatorList.
c_str());
1080 for(std::string::size_type i = 0; i < separatorList.
size(); ++ i)
1082 if (((*(this->
begin())) == separatorList.
c_str()[i]) && !skipBlankFields)
1088 if ((*s != 0) || !skipBlankFields)
1089 s = strtok(NULL, separatorList.
c_str());
1091 for(std::string::size_type i = 0; i < separatorList.
size(); ++ i)
1093 if (((*(this->
end()-1)) == separatorList.
c_str()[i]) && !skipBlankFields)
1094 result.push_back(
"");
1100 bool skipBlankFields)
const 1102 std::vector<ossimString> result;
1104 split(result, separatorList, skipBlankFields);
1113 if(stringList.size())
1115 for(
long i = 0; i < ((long)stringList.size()-1); ++i)
1117 *
this += stringList[i];
1120 *
this += stringList[stringList.size()-1];
1130 while(iter !=
end())
1134 if(c > 47 && c < 58)
1138 else if(c > 64 && c < 91)
1142 else if(c > 96 && c < 123)
1164 #ifdef OSSIM_ID_ENABLED ossimString before(const ossimString &str, std::string::size_type pos=0) const
METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If strin...
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
static ossimString upcase(const ossimString &aString)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
ossimString match(const char *regularExpressionPattern) const
Returns from found pattern to end of pattern.
std::string::iterator iterator
const ossimString & join(const std::vector< ossimString > &stringList, const ossimString &separator)
ossimString beforeRegExp(const char *regularExpressionPattern) const
Returns from start of string up to but not including found pattern.
ossim_uint8 toUInt8() const
ossimString afterPos(std::string::size_type pos) const
double nan()
Method to return ieee floating point double precision NAN.
bool contains(char aChar) const
static ossimString toString(bool aValue)
Numeric to string methods.
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
std::string::const_iterator const_iterator
ossim_uint32 toUInt32() const
unsigned short ossim_uint16
std::string::size_type size_type
std::string::iterator end()
ossimString fromRegExp(const char *regularExpressionPattern) const
Returns from position of found pattern to end of string.
ossim_int32 toInt32() const
ossimString afterRegExp(const char *regularExpressionPattern) const
Returns from position after found pattern to end of string.
void push_back(char c)
Equivalent to insert(end(), c).
ossim_int64 memoryUnitToInt64() const
This takes a string and will test for numeric followed by a unit type:
ossimString()
default constructor
ossimString replaceAllThatMatch(const char *regularExpressionPattern, const char *value="") const
ossimString expandEnvironmentVariable() const
If the variable "$(env_var_name)" is found in the string, where "env_var_name" is any system environm...
static ossimString stripLeading(const ossimString &value, char characterToStrip)
std::string::size_type length() const
std::string::size_type size() const
bool toBool() const
String to numeric methods.
std::string::iterator begin()
unsigned long long ossim_uint64
unsigned int ossim_uint32
std::string::iterator erase(std::string::iterator p)
Erases the character at position p.
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossim_float64 toFloat64() const
unsigned long toULong() const
ossim_float32 toFloat32() const
static ossimString downcase(const ossimString &aString)
ossimString urlEncode() const
void compile(const char *)
std::vector< ossimString > explode(const ossimString &delimeter) const
ossim_uint32 start() const
ossimString replaceStrThatMatch(const char *regularExpressionPattern, const char *value="") const
ossim_uint16 toUInt16() const
long toLong() const
toLong's deprecated, please use the toInts...
std::string & replace(std::string::size_type pos, std::string::size_type n, const std::string &s)
Replaces a substring of *this with the string s.
ossim_uint64 toUInt64() const
ossimString beforePos(std::string::size_type pos) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
ossim_int64 toInt64() const
std::string substr(std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
Equivalent to basic_string(*this, pos, n).
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
std::basic_istringstream< char > istringstream
Class for char input memory streams.
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.
ossimString & upcase()
Upcases this string.
ossimString getOssimId() const
If OSSIM_ID_ENABLED returns the OSSIM_ID which currently is the expanded cvs.
unsigned char ossim_uint8
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int16 toInt16() const
ossimString & downcase()
Downcases this string.
const std::string & string() const
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.