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 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
|
/*
*
* Copyright (C) 1997-2023, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: ofstd
*
* Author: Andrew Hewett
*
* Purpose: A simple string class
*
*/
/*
** A simple string class
** - for OFFIS projects when an ANSI string class is not always available
** - based on the ANSI-C++ specifications
** - this implementation is intended to be slow but reliable
** - it is known to be slow but is it reliable?
*/
#include "dcmtk/config/osconfig.h" /* include OS specific configuration first */
#ifndef HAVE_STL_STRING
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/ofstd/ofcast.h"
#include "dcmtk/ofstd/ofbmanip.h"
#include "dcmtk/ofstd/oftypes.h"
#include "dcmtk/ofstd/ofstd.h"
#include "dcmtk/ofstd/ofdiag.h"
static const char* verify_string(const char *s)
{
if (s == NULL)
{
#ifdef DEBUG
fprintf(stderr, "WARNING: OFString constructed from NULL, this is deprecated.\n");
#endif
#ifdef USE_NULL_SAFE_OFSTRING
s = "";
#endif
}
return s;
}
/*
** Constructors
*/
OFString::OFString()
: theCString(NULL), theSize(0), theCapacity(0)
{
reserve(1);
}
OFString::OFString(const OFString& str, size_t pos, size_t n)
: theCString(NULL), theSize(0), theCapacity(0)
{
this->assign(str, pos, n);
}
OFString::OFString (const char* s, size_t n)
: theCString(NULL), theSize(0), theCapacity(0)
{
s = verify_string(s);
if (n == OFString_npos) {
n = strlen(s);
}
reserve(n);
OFBitmanipTemplate<char>::copyMem(s, this->theCString, n);
this->theCString[n] = '\0';
this->theSize = n;
}
OFString::OFString (const char* s)
: theCString(NULL), theSize(0), theCapacity(0)
{
s = verify_string(s);
const size_t n = strlen(s);
reserve(n);
// Because we used strlen() to figure out the length we can use strlcpy()
// since there won't be any '\0' bytes in the string.
// The amount of memory allocated is always theCapacity+1
// because one extra byte is always allocated for the eos zero byte.
OFStandard::strlcpy(this->theCString, s, this->theCapacity+1);
this->theSize = n;
}
OFString::OFString (size_t rep, char c)
: theCString(NULL), theSize(0), theCapacity(0)
{
reserve(rep);
for (size_t i = 0; i < rep; i++) {
this->theCString[i] = c;
}
this->theCString[rep] = '\0';
this->theSize = rep;
}
/*
** Destructor
*/
OFString::~OFString()
{
if (theCString) {
delete[] theCString;
theCString = NULL;
}
}
/*
** Operator =
*/
OFString&
OFString::operator= (const OFString& rhs)
{
this->assign(rhs);
return *this;
}
OFString&
OFString::operator= (const char* s)
{
this->assign(s);
return *this;
}
OFString&
OFString::operator= (char s)
{
this->assign(1, s);
return *this;
}
/*
** Operator +=
*/
OFString&
OFString::operator+= (const OFString& rhs)
{
return this->append(rhs);
}
OFString&
OFString::operator+= (const char* s)
{
return this->append(s);
}
OFString&
OFString::operator+= (char s)
{
return this->append(1, s);
}
/*
** Append
*/
OFString&
OFString::append (const OFString& str, size_t pos, size_t n)
{
OFString b(str, pos, n);
this->reserve(this->size() + b.size());
// We can't use strcat() because some string could contain NULL bytes
// We need size() + 1 so that the EOS mark is copied over, too
OFBitmanipTemplate<char>::copyMem(b.theCString, this->theCString + this->size(), b.size() + 1);
this->theSize += b.size();
return *this;
}
OFString&
OFString::append (const char* s, size_t n)
{
OFString str(s, n);
return this->append(str);
}
OFString&
OFString::append (const char* s)
{
OFString str(s);
return this->append(str);
}
OFString&
OFString::append (size_t rep, char c)
{
OFString str(rep, c);
return this->append(str);
}
/*
** Assign
*/
OFString&
OFString::assign (const OFString& str, size_t pos, size_t n)
{
OFSTRING_OUTOFRANGE(pos > str.size());
const size_t remain = (str.size() - pos);
if ((n == OFString_npos) || (n > remain)) {
n = remain;
}
if (n > 0) {
this->reserve(n);
// Someone could try to assign a string to itself, but strncpy() must
// not be called on overlapping memory areas, therefore, we use moveMem().
OFBitmanipTemplate<char>::moveMem(str.theCString + pos, this->theCString, n);
this->theCString[n] = '\0';
this->theSize = n;
} else {
this->reserve(1);
/* assign an empty string */
this->theCString[0] = '\0';
this->theSize = 0;
}
return *this;
}
OFString&
OFString::assign (const OFString& str)
{
return assign(str, 0, OFString_npos);
}
OFString&
OFString::assign (const char* s, size_t n)
{
OFString str(s, n);
return this->assign(str);
}
OFString&
OFString::assign (const char* s)
{
OFString str(s);
return this->assign(str);
}
OFString&
OFString::assign (const char* s, const char *e)
{
OFString str(s, e - s);
return this->assign(str);
}
OFString&
OFString::assign (size_t rep, char c)
{
OFString str(rep, c);
return this->assign(str);
}
/*
** Insert
*/
OFString&
OFString::insert (size_t pos1, const OFString& str, size_t pos2, size_t n)
{
OFString i(str, pos2, n);
OFString a(*this, OFstatic_cast(size_t, 0), pos1);
OFString b(*this, pos1);
return this->assign(a).append(i).append(b);
}
OFString&
OFString::insert (size_t pos, const char* s, size_t n)
{
OFString str(s, n);
return this->insert(pos, str);
}
OFString&
OFString::insert (size_t pos, const char* s)
{
OFString str(s);
return this->insert(pos, str);
}
OFString&
OFString::insert (size_t pos, size_t rep, char s)
{
OFString str(rep, s);
return this->insert(pos, str);
}
/*
** Erase
*/
OFString&
OFString::erase (size_t pos, size_t n)
{
OFString a(*this, 0, pos);
OFString b;
if (n != OFString_npos) {
b.assign(*this, pos + n, OFString_npos);
}
return this->assign(a).append(b);
}
/*
** Replace
*/
OFString&
OFString::replace (size_t pos1, size_t n1, const OFString& str,
size_t pos2, size_t n2)
{
OFString a(*this, OFstatic_cast(size_t, 0), pos1);
OFString b;
if ((n1 < OFString_npos) && ((pos1 + n1) < this->size())) {
b.assign(*this, pos1 + n1, OFString_npos);
}
OFString i(str, pos2, n2);
return this->assign(a).append(i).append(b);
}
OFString&
OFString::replace (size_t pos, size_t n, const char* s, size_t n2)
{
OFString str(s, n2);
return this->replace(pos, n, str);
}
OFString&
OFString::replace (size_t pos, size_t n, const char* s)
{
OFString str(s);
return this->replace(pos, n, str);
}
OFString&
OFString::replace (size_t pos, size_t n, size_t rep, char s)
{
OFString str(rep, s);
return this->replace(pos, n, str);
}
/*
** Data
*/
const char*
OFString::data () const
{
return (this->size() != 0) ? this->c_str() : "";
}
/*
** Resize
*/
void
OFString::resize (size_t n, char c)
{
OFSTRING_LENGTHERROR(n == OFString_npos);
reserve(n);
const size_t len = this->size();
if (n <= len) {
for (size_t i = n; i < len; i++) {
this->theCString[i] = '\0';
}
} else {
for (size_t i = len; i < n; i++) {
this->theCString[i] = c;
}
this->theCString[n] = '\0';
}
this->theSize = n;
}
/*
** Reserve
*/
void
OFString::reserve (size_t res_arg)
{
if (res_arg == OFString_npos) {
res_arg = 0; /* let at least space for eos get reserved */
}
res_arg++; /* add space for eos */
if (this->theCapacity < res_arg) {
char* newstr = new char[res_arg];
if (newstr) {
size_t usedSpace = 0;
this->theCapacity = res_arg - 1; /* not the eos */
if (this->size() > 0) {
const size_t len = size();
// copyMem() because theCString could have null bytes
OFBitmanipTemplate<char>::copyMem(this->theCString, newstr, len);
usedSpace = len;
}
// suppress spurious gcc 12 warning
#include DCMTK_DIAGNOSTIC_PUSH
#include DCMTK_DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
OFBitmanipTemplate<char>::zeroMem(newstr + usedSpace, res_arg - usedSpace);
#include DCMTK_DIAGNOSTIC_POP
char* oldstr = this->theCString;
this->theCString = newstr;
delete[] oldstr;
} else {
OFSTRING_MEMORYALLOCERROR(newstr);
}
}
}
/*
** Copy
*/
size_t
OFString::copy (char* s, size_t n, size_t pos) const
{
OFString sub(this->substr(pos, n));
const size_t result = sub.size();
// The string could have NULL bytes so no strncpy()
OFBitmanipTemplate<char>::copyMem(sub.theCString, s, result);
return result;
}
/*
** Substr
*/
OFString
OFString::substr (size_t pos, size_t n) const
{
OFString sub;
return sub.assign(*this, pos, n);
}
/*
** Swap
*/
void
OFString::swap(OFString& s)
{
char* tmpCString = s.theCString;
s.theCString = this->theCString;
this->theCString = tmpCString;
size_t tmpSize = s.theSize;
s.theSize = this->theSize;
this->theSize = tmpSize;
size_t tmpCapacity = s.theCapacity;
s.theCapacity = this->theCapacity;
this->theCapacity = tmpCapacity;
}
/*
** Compare
*/
int
OFString::compare (const OFString& str) const
{
const size_t this_size = this->size();
const size_t str_size = str.size();
const size_t rlen = (this_size < str_size) ? this_size : str_size;
// Our string could contain null bytes and thus we can't use strncmp()
int result = memcmp(this->theCString, str.theCString, rlen);
if (result == 0) {
result = this_size < str_size ? -1 : this_size > str_size ? 1 : 0;
}
return result;
}
int
OFString::compare (size_t pos1, size_t n1, const OFString& str) const
{
return OFString(*this, pos1, n1).compare(str);
}
int
OFString::compare (size_t pos1, size_t n1, const OFString& str,
size_t pos2, size_t n2) const
{
return OFString(*this, pos1, n1).compare(OFString(str, pos2, n2));
}
int
OFString::compare (const char* s) const
{
return this->compare(OFString(s));
}
int
OFString::compare (size_t pos1, size_t n1,
const char* s, size_t n2) const
{
return OFString(*this, pos1, n1).compare(OFString(s, n2));
}
/*
** Find
*/
size_t
OFString::find (const OFString& pattern, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t pattern_size = pattern.size();
if ((this_size == 0) || (pattern_size == 0) || (pos == OFString_npos)) {
return OFString_npos;
}
for (size_t i = pos; i < this_size; i++) {
/* is there enough space for the pattern? */
if ((i + pattern_size) > this_size) {
return OFString_npos;
}
int match = 1; /* assume there is a match */
for (size_t j = 0; (j < pattern_size) && match; j++) {
if (this->at(i + j) != pattern[j]) {
match = 0;
}
}
if (match) {
return i;
}
}
return OFString_npos;
}
size_t
OFString::find (const char* pattern, size_t pos, size_t n) const
{
OFString str(pattern, n);
return this->find(str, pos);
}
size_t
OFString::find (const char* pattern, size_t pos) const
{
OFString str(pattern);
return this->find(str, pos);
}
size_t
OFString::find (char pattern, size_t pos) const
{
size_t i = pos;
const size_t this_size = this->size();
while ((i < this_size) && (this->at(i) != pattern))
i++;
return (i < this_size) ? i : OFString_npos;
}
/*
** Rfind
*/
size_t
OFString::rfind (const OFString& pattern, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t pattern_size = pattern.size();
if ((this_size == 0) || (pattern_size == 0) || (this_size < pattern_size)) {
return OFString_npos;
}
OFintptr_t above = ((this_size - pattern_size) < pos) ? (this_size - pattern_size) : pos;
for (OFintptr_t i = above; i >= 0; --i) {
int match = 1; /* assume there is a match */
for (size_t j = 0; (j < pattern_size) && match; ++j) {
if (this->at(i + j) != pattern[j]) {
match = 0;
}
}
if (match) {
return OFstatic_cast(size_t, i); // if i were < 0, the for-loop would've been already left.
}
}
return OFString_npos;
}
size_t
OFString::rfind (const char* pattern, size_t pos, size_t n) const
{
OFString str(pattern, n);
return this->rfind(str, pos);
}
size_t
OFString::rfind (const char* pattern, size_t pos) const
{
OFString str(pattern);
return this->rfind(str, pos);
}
size_t
OFString::rfind (char pattern, size_t pos) const
{
OFString str(1, pattern);
return this->rfind(str, pos);
}
/*
** Find_first_of
*/
size_t
OFString::find_first_of (const OFString& str, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t str_size = str.size();
if ((this_size == 0) || (str_size == 0) || (pos == OFString_npos)) {
return OFString_npos;
}
for (size_t i = pos; i < this_size; i++) {
for (size_t j = 0; j < str_size; j++) {
if (this->at(i) == str[j]) {
return i;
}
}
}
return OFString_npos;
}
size_t
OFString::find_first_of (const char* s, size_t pos, size_t n) const
{
OFString str(s, n);
return this->find_first_of(str, pos);
}
size_t
OFString::find_first_of (const char* s, size_t pos) const
{
OFString str(s);
return this->find_first_of(str, pos);
}
size_t
OFString::find_first_of (char s, size_t pos) const
{
OFString str(1, s);
return this->find_first_of(str, pos);
}
/*
** Find_last_of
*/
size_t
OFString::find_last_of (const OFString& str, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t str_size = str.size();
if ((this_size == 0) || (str_size == 0)) {
return OFString_npos;
}
if ((pos == OFString_npos) || (pos > this_size)) {
pos = this_size;
}
for (int i = OFstatic_cast(int, pos - 1); i >= 0; i--) {
for (size_t j = 0; j < str_size; j++) {
if (this->at(i) == str[j]) {
return i;
}
}
}
return OFString_npos;
}
size_t
OFString::find_last_of (const char* s, size_t pos, size_t n) const
{
OFString str(s, n);
return this->find_last_of(str, pos);
}
size_t
OFString::find_last_of (const char* s, size_t pos) const
{
OFString str(s);
return this->find_last_of(str, pos);
}
size_t
OFString::find_last_of (char s, size_t pos) const
{
OFString str(1, s);
return this->find_last_of(str, pos);
}
/*
** Find_first_not_of
*/
size_t
OFString::find_first_not_of (const OFString& str, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t str_size = str.size();
if ((this_size == 0) || (str_size == 0) || (pos == OFString_npos)) {
return OFString_npos;
}
for (size_t i = pos; i < this_size; i++) {
if (str.find(this->at(i)) == OFString_npos)
return i;
}
return OFString_npos;
}
size_t
OFString::find_first_not_of (const char* s, size_t pos, size_t n) const
{
OFString str(s, n);
return this->find_first_not_of(str, pos);
}
size_t
OFString::find_first_not_of (const char* s, size_t pos) const
{
OFString str(s);
return this->find_first_not_of(str, pos);
}
size_t
OFString::find_first_not_of (char s, size_t pos) const
{
OFString str(1, s);
return this->find_first_not_of(str, pos);
}
/*
** Find_last_not_of
*/
size_t
OFString::find_last_not_of (const OFString& str, size_t pos) const
{
/* determine string length only once */
const size_t this_size = this->size();
const size_t str_size = str.size();
if ((this_size == 0) || (str_size == 0)) {
return OFString_npos;
}
if (pos == OFString_npos) {
pos = this_size;
}
for (int i = OFstatic_cast(int, pos - 1); i >= 0; i--) {
if (str.find(this->at(i)) == OFString_npos)
return i;
}
return OFString_npos;
}
size_t
OFString::find_last_not_of (const char* s, size_t pos, size_t n) const
{
OFString str(s, n);
return this->find_last_not_of(str, pos);
}
size_t
OFString::find_last_not_of (const char* s, size_t pos) const
{
OFString str(s);
return this->find_last_not_of(str, pos);
}
size_t
OFString::find_last_not_of (char s, size_t pos) const
{
OFString str(1, s);
return this->find_last_not_of(str, pos);
}
/*
** Operator <<
*/
STD_NAMESPACE ostream& operator<< (STD_NAMESPACE ostream& o, const OFString& s)
{
return o.write (s.c_str(), s.size());
}
/*
** Operator >>
*/
STD_NAMESPACE istream& operator>> (STD_NAMESPACE istream& i, OFString& s)
{
// suppress spurious gcc 12 warning
#include DCMTK_DIAGNOSTIC_PUSH
#include DCMTK_DIAGNOSTIC_IGNORE_STRINGOP_OVERFLOW
s.resize(0);
#include DCMTK_DIAGNOSTIC_POP
char c = '\0';
size_t n = s.max_size();
if (i.width() > 0) {
n = OFstatic_cast(size_t, i.width());
}
// skip white space before word
i.get(c);
while (i.good() && isspace(OFstatic_cast(unsigned char, c))) {
i.get(c);
}
// get the word
while (i.good() && !isspace(OFstatic_cast(unsigned char, c)) && n--) {
s += c;
i.get(c);
}
if (isspace(OFstatic_cast(unsigned char, c))) {
i.putback(c);
}
i.width(0);
return i;
}
/*
** Operator +
*/
OFString operator+ (const OFString& lhs, const OFString& rhs)
{
OFString s(lhs);
s += rhs;
return s;
}
OFString operator+ (const char* lhs, const OFString& rhs)
{
OFString s(lhs);
s += rhs;
return s;
}
OFString operator+ (char lhs, const OFString& rhs)
{
OFString s(1, lhs);
s += rhs;
return s;
}
OFString operator+ (const OFString& lhs, const char* rhs)
{
OFString s(lhs);
s += rhs;
return s;
}
OFString operator+ (const OFString& lhs, char rhs)
{
OFString s(lhs);
s += rhs;
return s;
}
/*
** Operator ==
*/
OFBool operator== (const OFString& lhs, const OFString& rhs)
{
return (lhs.compare(rhs) == 0) ? OFTrue : OFFalse;
}
OFBool operator== (const char* lhs, const OFString& rhs)
{
OFString slhs(lhs);
return (slhs == rhs);
}
OFBool operator== (char lhs, const OFString& rhs)
{
OFString slhs(1, lhs);
return (slhs == rhs);
}
OFBool operator== (const OFString& lhs, const char* rhs)
{
OFString srhs(rhs);
return (lhs == srhs);
}
OFBool operator== (const OFString& lhs, char rhs)
{
OFString srhs(1, rhs);
return (lhs == srhs);
}
/*
** Operator <
*/
OFBool operator< (const OFString& lhs, const OFString& rhs)
{
return (lhs.compare(rhs) < 0) ? OFTrue : OFFalse;
}
OFBool operator< (const char* lhs, const OFString& rhs)
{
OFString slhs(lhs);
return (slhs < rhs);
}
OFBool operator< (char lhs, const OFString& rhs)
{
OFString slhs(1, lhs);
return (slhs < rhs);
}
OFBool operator< (const OFString& lhs, const char* rhs)
{
OFString srhs(rhs);
return (lhs < srhs);
}
OFBool operator< (const OFString& lhs, char rhs)
{
OFString srhs(1, rhs);
return (lhs < srhs);
}
/*
** Operator <=
*/
OFBool operator<= (const OFString& lhs, const OFString& rhs)
{
return (!(rhs < lhs));
}
OFBool operator<= (const char* lhs, const OFString& rhs)
{
return (!(rhs < lhs));
}
OFBool operator<= (char lhs, const OFString& rhs)
{
return (!(rhs < lhs));
}
OFBool operator<= (const OFString& lhs, const char* rhs)
{
return (!(rhs < lhs));
}
OFBool operator<= (const OFString& lhs, char rhs)
{
return (!(rhs < lhs));
}
/*
** Operator !=
*/
OFBool operator!= (const OFString& lhs, const OFString& rhs)
{
return (!(lhs == rhs));
}
OFBool operator!= (const char* lhs, const OFString& rhs)
{
return (!(lhs == rhs));
}
OFBool operator!= (char lhs, const OFString& rhs)
{
return (!(lhs == rhs));
}
OFBool operator!= (const OFString& lhs, const char* rhs)
{
return (!(lhs == rhs));
}
OFBool operator!= (const OFString& lhs, char rhs)
{
return (!(lhs == rhs));
}
/*
** Operator >
*/
OFBool operator> (const OFString& lhs, const OFString& rhs)
{
return (rhs < lhs);
}
OFBool operator> (const char* lhs, const OFString& rhs)
{
return (rhs < lhs);
}
OFBool operator> (char lhs, const OFString& rhs)
{
return (rhs < lhs);
}
OFBool operator> (const OFString& lhs, const char* rhs)
{
return (rhs < lhs);
}
OFBool operator> (const OFString& lhs, char rhs)
{
return (rhs < lhs);
}
/*
** Operator >=
*/
OFBool operator>= (const OFString& lhs, const OFString& rhs)
{
return (!(lhs < rhs));
}
OFBool operator>= (const char* lhs, const OFString& rhs)
{
return (!(lhs < rhs));
}
OFBool operator>= (char lhs, const OFString& rhs)
{
return (!(lhs < rhs));
}
OFBool operator>= (const OFString& lhs, const char* rhs)
{
return (!(lhs < rhs));
}
OFBool operator>= (const OFString& lhs, char rhs)
{
return (!(lhs < rhs));
}
#else /* HAVE_STL_STRING */
int ofstring_cc_dummy_to_keep_linker_from_moaning = 0;
#endif
|