/usr/include/ossim/base/ossimString.h is in libossim-dev 1.7.21-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | //*******************************************************************
//
// License: LGPL
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: Garrett Potts
//
// Description: This class extends the stl's string class.
//
//********************************************************************
// $Id: ossimString.h 14689 2009-06-09 19:34:02Z dburken $
#ifndef ossimString_HEADER
#define ossimString_HEADER 1
#include <string>
#include <vector>
#include <ossim/base/ossimConstants.h>
class OSSIM_DLL ossimString : public std::string
{
public:
/** default constructor */
ossimString():std::string(){}
/** constructor that takes a std::string */
ossimString(const std::string& s):std::string(s){}
/**
* constructor that takes char*
* NOTE: std::string construtor throws exception given null pointer;
* hence, the null check.
*/
ossimString(const char *aString):std::string( aString?aString:"" ){}
/** copy constructor */
ossimString(const ossimString& aString):std::string(aString.c_str()){}
/** constructor - constructs with n copies of c */
ossimString(size_type n, char c):std::string(n,c){}
/** constructor - constructs with 1 c. */
ossimString(char aChar):std::string(1, aChar){}
template <class Iter>
ossimString(Iter startIter, Iter endIter):std::string(startIter, endIter){}
bool contains(const ossimString& aString) const {return find(aString)!=npos;}
bool contains(const char* aString) const {return find(aString)!=npos;}
const ossimString& operator=(const std::string& s)
{
std::string::operator=(s);
return *this;
}
const ossimString& operator=(const char* s)
{
if (s) // std::string::operator= throws exception given null pointer.
{
std::string::operator=(s);
}
else
{
std::string::operator=("");
}
return *this;
}
const ossimString& operator=(char c)
{
std::string::operator=(c);
return *this;
}
const ossimString& operator =(const ossimString& s)
{
std::string::operator =(s.c_str());
return *this;
}
const ossimString& operator +=(const ossimString& s)
{
append(s.c_str());
return *this;
}
const ossimString& operator +=(const char* s)
{
append(ossimString(s).c_str());
return *this;
}
const ossimString& operator +=(char c)
{
append(ossimString(c).c_str());
return *this;
}
ossimString operator +(const ossimString& s)const
{
ossimString returnS(*this);
returnS.append(s.c_str());
return returnS;
}
ossimString operator +(const char* s)const
{
ossimString returnS(*this);
returnS.append(ossimString(s).c_str());
return returnS;
}
ossimString operator +(char c)const
{
ossimString returnS(*this);
returnS.append(ossimString(c).c_str());
return returnS;
}
/**
* @brief Test if this ossimString is equal to another ossimString.
* @param rhs ossimString to compare.
* @return True if strings are equal. False otherwise.
*/
bool operator==(const ossimString& rhs) const
{
return (std::string::compare(rhs.c_str()) == 0);
}
/**
* @brief Test if this ossimString is equal to a C sting.
* @param rhs C string to compare.
* @return True if strings are equal.
* False if rhs is not equal null or null.
*/
bool operator==(const char* rhs) const
{
bool result = false;
if (rhs)
{
result = (std::string::compare(std::string(rhs)) == 0);
}
return result;
}
/**
* @brief Test if this ossimString is not equal to another ossimString.
* @param rhs ossimString to compare.
* @return True if strings are not equal. False otherwise.
*/
bool operator!=(const ossimString& rhs) const
{
return !(std::string::compare(rhs.c_str()) == 0);
}
/**
* @brief Test if this ossimString is not equal to a C sting.
* @param rhs C string to compare.
* @return True if strings are not equal or rhs is null.
* False if rhs equal to this string.
*/
bool operator!=(const char* rhs) const
{
bool result = true;
if (rhs)
{
result = !(std::string::compare(std::string(rhs)) == 0);
}
return result;
}
//---
// operator[] removed. std::string::operator[] works given a
// std::string::size_type for an index.
// //
// char& operator[](int i)
// {
// return *( const_cast<char*>(c_str())+i);
// }
// const char& operator[](int i)const
// {
// return *(c_str()+i);
// }
//---
/**
* this will strip lead and trailing character passed in.
* So if you want to remove blanks:
* ossimString temp(" asdfasdf ");
* ossimString trimmedString = temp.trim(" \n\t\r");
*
* this will now contain "asdfasdf" without the blanks.
*
*/
ossimString trim(const ossimString& valueToTrim= ossimString(" \t\n\r"))const;
ossimString& trim(const ossimString& valueToTrim= ossimString(" \t\n\r"));
ossimString beforePos(std::string::size_type pos)const;
ossimString afterPos(std::string::size_type pos)const;
/**
* Substitudes searchKey string with replacementValue and returns a
* string. Will replace all occurrances found if "replaceAll" is true.
*/
ossimString substitute(const ossimString &searchKey,
const ossimString &replacementValue,
bool replaceAll=false)const;
/**
* Substitudes searchKey string with replacementValue and returns a
* reference to *this. Will replace all occurrances found if
* "replaceAll" is true. (like substitute only works on "this")
*/
ossimString& gsub(const ossimString &searchKey,
const ossimString &replacementValue,
bool replaceAll=false);
std::vector<ossimString> explode(const ossimString& delimeter) const;
/**
* @param aString String to make an upcased copy of.
*
* @return An upcased version of aString.
*/
static ossimString upcase(const ossimString& aString);
/**
* @param aString String to make an downcased copy of.
*
* @return A downcased version of aString.
*/
static ossimString downcase(const ossimString& aString);
/**
* Upcases this string.
*
* @return Reference to this.
*/
ossimString& upcase();
/**
* Downcases this string.
*
* @return Reference to this.
*/
ossimString& downcase();
operator const char*()const{return c_str();}
const char* chars()const{return c_str();}
/**
* METHOD: before(str, pos)
* Returns string beginning at pos and ending one before the token str
* If string not found or pos out of range the whole string will be
* returned.
*/
ossimString before(const ossimString& str, std::string::size_type pos=0)const;
/**
* METHOD: after(str, pos)
* Returns string immediately after the token str. The search for str
* begins at pos. Returns an emptry string if not found or pos out of
* range.
*/
ossimString after (const ossimString& str, std::string::size_type pos=0)const;
char* stringDup()const;
/**
* String to numeric methods.
*/
bool toBool()const;
static bool toBool(const ossimString& aString);
int toInt()const;
static int toInt(const ossimString& aString);
ossim_int16 toInt16()const;
static ossim_int16 toInt16(const ossimString& aString);
ossim_uint16 toUInt16()const;
static ossim_uint16 toUInt16(const ossimString& aString);
ossim_int32 toInt32()const;
static ossim_int32 toInt32(const ossimString& aString);
ossim_uint32 toUInt32()const;
static ossim_uint32 toUInt32(const ossimString& aString);
ossim_int64 toInt64()const;
static ossim_int64 toInt64(const ossimString& aString);
ossim_uint64 toUInt64()const;
static ossim_uint64 toUInt64(const ossimString& aString);
/**
* toLong's deprecated, please use the toInts...
*/
long toLong()const;
static long toLong(const ossimString& aString);
unsigned long toULong()const;
static unsigned long toULong(const ossimString& aString);
ossim_float32 toFloat32()const;
static ossim_float32 toFloat32(const ossimString& aString);
ossim_float64 toFloat64()const;
static ossim_float64 toFloat64(const ossimString& aString);
double toDouble()const;
static double toDouble(const ossimString& aString);
/**
* Numeric to string methods.
*/
static ossimString toString(bool aValue);
static ossimString toString(ossim_int16 aValue);
static ossimString toString(ossim_uint16 aValue);
static ossimString toString(ossim_int32 aValue);
static ossimString toString(ossim_uint32 aValue);
static ossimString toString(ossim_int64 aValue);
static ossimString toString(ossim_uint64 aValue);
/**
* @param aValue Value to convert to string.
*
* @param precision Decimal point precision of the output.
*
* @param trimZeroFlag If true trailing '0's and any trailing '.' will
* be trimmed.
*
* @param scientific If true output will be in scientific notation else
* fixed is used.
*
* @note The trimZeroFlag is ignored if the scientific flag is set so that
* "e-10" will not be trimmed to "e-1".
*/
static ossimString toString(ossim_float32 aValue,
int precision = 8,
bool trimZeroFlag = false,
bool scientific = false );
/**
* @param aValue Value to convert to string.
*
* @param precision Decimal point precision of the output.
*
* @param trimZeroFlag If true trailing '0's and any trailing '.' will
* be trimmed.
*
* @param scientific If true output will be in scientific notation else
* fixed is used.
*
* @note The trimZeroFlag is ignored if the scientific flag is set so that
* "e-10" will not be trimmed to "e-1".
*/
static ossimString toString(ossim_float64 aValue,
int precision = 15,
bool trimZeroFlag = false,
bool scientific = false);
static ossimString stripLeading(const ossimString &value,
char characterToStrip);
void split(std::vector<ossimString>& result,
const ossimString& separatorList)const;
std::vector<ossimString> split(const ossimString& separatorList)const;
const ossimString& join(const std::vector<ossimString>& stringList,
const ossimString& separator);
//---
// Regular expression pattern utilities
//---
/**
* Returns from start of string up to but not including found pattern.
* Returns "" if pattern not found.
*/
ossimString beforeRegExp(const char *regularExpressionPattern) const;
/**
* Returns from position of found pattern to end of string.
* Returns "" if pattern not found.
*/
ossimString fromRegExp(const char *regularExpressionPattern) const;
/**
* Returns from position after found pattern to end of string.
* Returns "" if pattern not found.
*/
ossimString afterRegExp(const char *regularExpressionPattern) const;
/**
* Returns from found pattern to end of pattern.
* Returns "" if pattern not found.
*/
ossimString match(const char *regularExpressionPattern) const;
ossimString replaceAllThatMatch(const char *regularExpressionPattern,
const char *value="") const;
ossimString replaceStrThatMatch(const char *regularExpressionPattern,
const char *value="") const;
ossimString urlEncode()const;
/**
* If OSSIM_ID_ENABLED returns the OSSIM_ID which currently is the
* expanded cvs $Id: ossimString.h 14689 2009-06-09 19:34:02Z dburken $ macro; else, an empty string.
*/
ossimString getOssimId() const;
};
#endif /* #ifndef ossimString_HEADER */
|