/usr/include/ossim/base/ossimString.h is in libossim-dev 1.8.16-4ubuntu1.
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 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | //*******************************************************************
//
// 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 20491 2012-01-23 20:10:06Z dburken $
#ifndef ossimString_HEADER
#define ossimString_HEADER 1
#include <ossim/base/ossimConstants.h>
#include <string>
#include <vector>
#include <iostream>
class OSSIM_DLL ossimString
{
public:
typedef std::string::const_iterator const_iterator;
typedef std::string::iterator iterator;
typedef std::string::size_type size_type;
/** @brief default constructor */
ossimString(): m_str() {}
/** @brief constructor that takes a std::string */
ossimString(const std::string& s):m_str(s) {}
/**
* @brief constructor that takes char*
* NOTE: std::string construtor throws exception given null pointer;
* hence, the null check.
*/
ossimString(const char *aString):m_str( aString?aString:"" ){}
/** @brief copy constructor */
ossimString(const ossimString& aString):m_str(aString.m_str){}
/** @brief constructor - constructs with n copies of c */
ossimString(std::string::size_type n, char c):m_str(n,c){}
/** @brief constructor - constructs with 1 c. */
ossimString(char aChar):m_str(1, aChar){}
template <class Iter>
ossimString(Iter startIter, Iter endIter):m_str(startIter, endIter){}
/** @brief destructor */
~ossimString(){}
bool contains(const ossimString& aString) const
{ return m_str.find(aString.m_str)!=std::string::npos; }
bool contains(const char* aString) const
{ return m_str.find(aString)!=std::string::npos; }
/** @brief Type conversion operator to a const std::string&. */
operator const std::string&() const { return m_str; }
/** @brief Type conversion operator to a std::string&. */
operator std::string&() { return m_str; }
/** @brief Type conversion operator to a const char*. */
operator const char*() const { return m_str.c_str(); }
/** @brief For backward compatibility. */
const char* chars() const { return m_str.c_str(); }
/** @brief Reads s from the input stream is. */
friend OSSIM_DLL std::istream& operator>>(std::istream& is, ossimString& s);
/** @brief Writes s to the output stream os. */
friend OSSIM_DLL std::ostream& operator<<(std::ostream& os,
const ossimString& s);
/**
* @brief Reads a string from the input stream is, stopping when it
* reaches delim.
*/
friend OSSIM_DLL std::istream& getline( std::istream& is,
ossimString& str,
char delim );
/** @brief Reads a single line from the input stream is. */
friend OSSIM_DLL std::istream& getline( std::istream& is, ossimString& str );
const ossimString& operator=(const std::string& s)
{
m_str = s;
return *this;
}
const ossimString& operator=(const char* s)
{
if (s) // std::string::operator= throws exception given null pointer.
{
m_str = s;
}
else
{
m_str = "";
}
return *this;
}
const ossimString& operator=(char c)
{
m_str = c;
return *this;
}
const ossimString& operator=(const ossimString& s)
{
if ( this != &s )
{
m_str = s.m_str;
}
return *this;
}
const ossimString& operator+=(const ossimString& s)
{
m_str.append(s.m_str);
return *this;
}
const ossimString& operator+=(const std::string& s)
{
m_str.append(s);
return *this;
}
const ossimString& operator+=(const char* s)
{
if ( s ) m_str.append(s);
return *this;
}
const ossimString& operator+=(char c)
{
m_str.append(1, c);
return *this;
}
const ossimString& append(const ossimString& s);
const ossimString& append(const std::string& s);
const ossimString& append(const char* s);
/**
* @brief Provides access to the data contained in the %string.
* @param n The index of the character to access.
* @return Read-only (const) reference to the character.
* @throw std::out_of_range If @a n is an invalid index.
*
* This function provides for safer data access. The parameter is
* first checked that it is in the range of the string. The function
* throws out_of_range if the check fails.
*/
const char& at(std::string::size_type n) const;
/**
* @brief Provides access to the data contained in the %string.
* @param n The index of the character to access.
* @return Read/write reference to the character.
* @throw std::out_of_range If @a n is an invalid index.
*
* This function provides for safer data access. The parameter is
* first checked that it is in the range of the string. The function
* throws out_of_range if the check fails. Success results in
* unsharing the string.
*/
char& at(std::string::size_type n);
/** @brief Append n copies of c to *this. */
const ossimString& append(std::string::size_type n, char c);
ossimString operator+(const ossimString& s)const
{
ossimString returnS(*this);
returnS.m_str.append(s.m_str);
return returnS;
}
ossimString operator+(const std::string& s)const
{
ossimString returnS(*this);
returnS.m_str.append(s);
return returnS;
}
ossimString operator+(const char* s)const
{
ossimString returnS(*this);
if ( s ) returnS.m_str.append(s);
return returnS;
}
ossimString operator+(char c)const
{
ossimString returnS(*this);
returnS.m_str.append(1, c);
return returnS;
}
friend OSSIM_DLL ossimString operator+(const char* s1, const ossimString& s2);
friend OSSIM_DLL ossimString operator+(const std::string s1, const ossimString& s2);
friend OSSIM_DLL ossimString operator+(char c, const ossimString& s2);
friend OSSIM_DLL bool operator==(const char* lhs, const ossimString& rhs);
friend OSSIM_DLL bool operator==(const std::string& lhs, const ossimString& rhs);
/**
* @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 (m_str.compare( rhs.m_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 = (m_str.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 !(m_str.compare(rhs.m_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 = !(m_str.compare(std::string(rhs)) == 0);
}
return result;
}
char& operator[](std::string::size_type i)
{
return m_str[i];
// return *( const_cast<char*>(m_strc_str())+i);
}
const char& operator[](std::string::size_type i)const
{
return m_str[i];
}
/**
* @brief If pos > size(), throws out_of_range. Otherwise, equivalent to
* insert(begin() + pos, s, s + traits::length(s)).
*/
std::string& insert(std::string::size_type pos, const char* s);
/** @brief Equivalent to insert(end(), c). */
void push_back(char c);
/** @brief Equivalent to basic_string(*this, pos, n). */
std::string substr(std::string::size_type pos = 0,
std::string::size_type n = std::string::npos) const;
/**
* 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;
/**
* Substitutes searchKey string with replacementValue and returns a
* string. Will replace all occurrences found if "replaceAll" is true.
*/
ossimString substitute(const ossimString &searchKey,
const ossimString &replacementValue,
bool replaceAll=false)const;
/**
* Substitutes searchKey string with replacementValue and returns a
* reference to *this. Will replace all occurrences 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;
/**
* If the variable "$(env_var_name)" is found in the string, where
* "env_var_name" is any system environment variable resolvable by
* the getenv() function, the variable is expanded in place and the
* result returned.
*/
ossimString expandEnvironmentVariable() 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();
ossimString upcase()const;
/**
* Downcases this string.
*
* @return Reference to this.
*/
ossimString& downcase();
ossimString downcase()const;
/**
* @brief Returns a pointer to a null-terminated array of characters
* representing the string's contents.
*/
const char* c_str() const { return m_str.c_str(); }
/**
* @brief Returns a pointer to an array of characters (not necessarily
* null-terminated) representing the string's contents.
*/
const char* data() const { return m_str.data(); }
/** @return The size of the string. */
std::string::size_type size() const { return m_str.size(); }
/** @return The size of the string. */
std::string::size_type length() const { return m_str.size(); }
/** @return True if size is 0. */
bool empty() const { return m_str.empty(); }
/** @return The underlying std::string container. */
const std::string& string() const { return m_str; }
/** @return The underlying std::string container. */
std::string& string() { return m_str; }
/** @return An iterator pointing to the beginning of the string. */
std::string::iterator begin() { return m_str.begin(); }
/** @return An iterator pointing to the end of the string. */
std::string::iterator end() { return m_str.end(); }
/** @return An const_iterator pointing to the beginning of the string. */
std::string::const_iterator begin() const { return m_str.begin(); }
/** @return An const_iterator pointing to the end of the string. */
std::string::const_iterator end() const { return m_str.end(); }
/** @brief Erases the entire container. */
void clear() { m_str.clear(); }
/** @brief Erases the character at position p. */
std::string::iterator erase(std::string::iterator p);
/** @brief Erases the range [first, last). */
std::string::iterator erase(std::string::iterator first,
std::string::iterator last);
/** @brief Erases a range. */
std::string& erase(std::string::size_type pos = 0,
std::string::size_type n = std::string::npos);
/**
* @brief Searches for s as a substring of *this, beginning at character
* pos of *this.
*/
std::string::size_type find(const std::string& s,
std::string::size_type pos = 0) const;
/**
* @brief Searches for the first n characters of s as a substring of *this,
* beginning at character pos of *this.
*/
std::string::size_type find(const char* s,
std::string::size_type pos,
std::string::size_type n) const;
/**
* @brief Searches for a null-terminated character array as a substring
* of *this, beginning at character pos of *this.
*/
std::string::size_type find(const char* s,
std::string::size_type pos = 0) const;
/**
* @brief Searches for the character c, beginning at character position
* pos.
*/
std::string::size_type find(char c, std::string::size_type pos = 0) const;
/**
* @brief Searches backward for s as a substring of *this, beginning at
* character position min(pos, size()).
*/
std::string::size_type rfind(const std::string& s,
std::string::size_type pos = 0) const;
/**
* @brief Searches backward for the first n characters of s as a substring
* of *this, beginning at character position min(pos, size()).
*/
std::string::size_type rfind(const char* s,
std::string::size_type pos,
std::string::size_type n) const;
/**
* @brief Searches backward for a null-terminated character array as a
* substring of *this, beginning at character min(pos, size()).
*/
std::string::size_type rfind(const char* s,
std::string::size_type pos = 0) const;
/**
* @brief Searches backward for the character c, beginning at character
* position min(pos, size().
*/
std::string::size_type rfind(char c, std::string::size_type pos = 0) const;
/** @brief Equivalent to find(c, pos). */
std::string::size_type find_first_of(
char c, std::string::size_type pos = 0) const;
/**
* @brief Returns the smallest character position N such that
* pos <= N < size(), and such that (*this)[N] does not compare equal to c.
* Returns npos if no such character position exists.
*/
std::string::size_type find_first_not_of(
char c, std::string::size_type pos = 0) const;
/**
* @brief Equivalent to find_first_of(s, pos, traits::length(s)).
*/
std::string::size_type find_first_of(
const char* s, std::string::size_type pos = 0) const;
/**
* @brief Equivalent to find_first_not_of(s, pos, traits::length(s)).
*/
std::string::size_type find_first_not_of(
const char* s, std::string::size_type pos = 0) const;
/** @brief Equivalent to rfind(c, pos). */
std::string::size_type find_last_of(
char c, std::string::size_type pos = std::string::npos) const;
/**
* @brief Erases the existing characters and replaces them by n copies
* of c.
*/
std::string& assign(std::string::size_type n, char c);
/** @brief Replaces a substring of *this with the string s. */
std::string& replace(std::string::size_type pos,
std::string::size_type n,
const std::string& s);
/** brief Equivalent to insert(erase(first, last), s.begin(), s.end()). */
std::string& replace(std::string::iterator first,
std::string::iterator last,
const std::string& s);
/** @brief Replaces a substring of *this with a substring of s. */
std::string& replace(std::string::size_type pos,
std::string::size_type n,
const std::string& s,
std::string::size_type pos1,
std::string::size_type n1);
/** @brief Requests that the string's capacity be changed. */
void reserve(std::string::size_type n);
/**
* 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 empty 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);
ossim_uint8 toUInt8()const;
static ossim_uint8 toUInt8(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 fixed If true setiosflags(std::ios::fixed) will be called.
*/
static ossimString toString(ossim_float32 aValue,
ossim_int32 precision = 8,
bool fixed = false);
/**
* @param aValue Value to convert to string.
*
* @param precision Decimal point precision of the output.
*
* @param fixed If true setiosflags(std::ios::fixed) will be called.
*/
static ossimString toString(ossim_float64 aValue,
ossim_int32 precision = 15,
bool fixed = false);
static ossimString stripLeading(const ossimString &value,
char characterToStrip);
/**
* Splits this string into a vector of strings (fields) using the delimiter list specified.
* If a delimiter is encountered at the beginning or the end of this, or two delimiters are
* contiguous, a blank field is inserted in the vector, unless skipBlankFields is true.
*/
void split(std::vector<ossimString>& result,
const ossimString& separatorList,
bool skipBlankFields=false)const;
std::vector<ossimString> split(const ossimString& separatorList,
bool skipBlankFields=false)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 20491 2012-01-23 20:10:06Z dburken $ macro; else, an empty string.
*/
ossimString getOssimId() const;
protected:
std::string m_str;
};
inline std::string::iterator ossimString::erase(std::string::iterator p)
{
return m_str.erase(p);
}
inline std::string::iterator ossimString::erase(std::string::iterator first,
std::string::iterator last)
{
return m_str.erase(first, last);
}
inline std::string& ossimString::erase(std::string::size_type pos,
std::string::size_type n)
{
return m_str.erase(pos, n);
}
inline std::string::size_type ossimString::find(
const std::string& s, std::string::size_type pos) const
{
return m_str.find(s, pos);
}
inline std::string::size_type ossimString::find(
const char* s, std::string::size_type pos, std::string::size_type n) const
{
return m_str.find(s, pos, n);
}
inline std::string::size_type ossimString::find(
const char* s, std::string::size_type pos) const
{
return m_str.find(s, pos);
}
inline std::string::size_type ossimString::find(
char c, std::string::size_type pos) const
{
return m_str.find(c, pos);
}
inline std::string::size_type ossimString::rfind(
const std::string& s, std::string::size_type pos) const
{
return m_str.rfind(s, pos);
}
inline std::string::size_type ossimString::rfind(
const char* s, std::string::size_type pos, std::string::size_type n) const
{
return m_str.rfind(s, pos, n);
}
inline std::string::size_type ossimString::rfind(
const char* s, std::string::size_type pos) const
{
return m_str.rfind(s, pos);
}
inline std::string::size_type ossimString::rfind(
char c, std::string::size_type pos) const
{
return m_str.rfind(c, pos);
}
inline std::string::size_type ossimString::find_first_of(
char c, std::string::size_type pos) const
{
return m_str.find_first_of(c, pos);
}
inline std::string::size_type ossimString::find_first_of(
const char* s, std::string::size_type pos) const
{
return m_str.find_first_of(s, pos);
}
inline std::string::size_type ossimString::find_first_not_of(
const char c, std::string::size_type pos) const
{
return m_str.find_first_not_of(c, pos);
}
inline std::string::size_type ossimString::find_first_not_of(
const char* s, std::string::size_type pos) const
{
return m_str.find_first_not_of(s, pos);
}
inline std::string::size_type ossimString::find_last_of(
char c, std::string::size_type pos) const
{
return m_str.find_last_of(c, pos);
}
inline const ossimString& ossimString::append(const ossimString& s)
{
m_str.append(s.m_str);
return *this;
}
inline const ossimString& ossimString::append(const std::string& s)
{
m_str.append(s);
return *this;
}
inline const ossimString& ossimString::append(const char* s)
{
if ( s ) m_str.append(s);
return *this;
}
inline const ossimString& ossimString::append(std::string::size_type n, char c)
{
m_str.append(n, c);
return *this;
}
inline const char& ossimString::at(std::string::size_type n) const
{
return m_str.at(n);
}
inline char& ossimString::at(std::string::size_type n)
{
return m_str.at(n);
}
inline std::string& ossimString::assign(std::string::size_type n, char c)
{
return m_str.assign(n, c);
}
inline std::string& ossimString::replace(
std::string::size_type pos, std::string::size_type n, const std::string& s)
{
return m_str.replace(pos, n, s);
}
inline std::string& ossimString::replace(std::string::iterator first,
std::string::iterator last,
const std::string& s)
{
return m_str.replace(first, last, s);
}
inline std::string& ossimString::replace(std::string::size_type pos,
std::string::size_type n,
const std::string& s,
std::string::size_type pos1,
std::string::size_type n1)
{
return m_str.replace(pos, n, s, pos1, n1);
}
inline void ossimString::reserve(std::string::size_type n)
{
m_str.reserve(n);
}
inline std::string& ossimString::insert(std::string::size_type pos,
const char* s)
{
if (s) m_str.insert(pos, s);
return m_str;
}
inline void ossimString::push_back(char c)
{
m_str.push_back(c);
}
inline std::string ossimString::substr(std::string::size_type pos,
std::string::size_type n) const
{
return m_str.substr(pos, n);
}
inline std::istream& getline( std::istream& is, ossimString& str, char delim )
{
return std::getline( is, str.string(), delim );
}
inline std::istream& getline( std::istream& is, ossimString& str )
{
// Not sure why getline( is, str.string()) doesn't work. (drb)
return std::getline( is, str.string(), '\n' );
}
inline std::istream& operator>>(std::istream& is, ossimString& s)
{
return is >> s.string();
}
inline std::ostream& operator<<(std::ostream& os, const ossimString& s)
{
return os << s.string();
}
inline ossimString operator+(const char* s1, const ossimString& s2)
{
ossimString result;
if ( s1 ) result = ossimString( s1 + s2.string() );
else result = s2;
return result;
}
inline ossimString operator+(const std::string s1, const ossimString& s2)
{
return ossimString( s1 + s2.string() );
}
inline ossimString operator+(char c, const ossimString& s2)
{
return ossimString( c + s2.string() );
}
inline bool operator==(const char* lhs, const ossimString& rhs)
{
return (rhs.operator ==(lhs));
}
inline bool operator==(const std::string& lhs, const ossimString& rhs)
{
return (rhs.operator ==(lhs));
}
/**
* @brief For use with std::map as a compare operator:
* std::map<ossimString, ossimString, ossimStringLtstr>
*
* This will allow the find method on map to work.
*/
struct ossimStringLtstr
{
bool operator()(const ossimString& s1, const ossimString& s2) const
{
return s1.string().compare(s2.string()) < 0;
}
};
#endif /* #ifndef ossimString_HEADER */
|