/var/tmp/tog-pegasus-2.9.0-8m.mo8/pegasus/src/Pegasus/Common/String.h
00001 //%LICENSE////////////////////////////////////////////////////////////////
00002 //
00003 // Licensed to The Open Group (TOG) under one or more contributor license
00004 // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
00005 // this work for additional information regarding copyright ownership.
00006 // Each contributor licenses this file to you under the OpenPegasus Open
00007 // Source License; you may not use this file except in compliance with the
00008 // License.
00009 //
00010 // Permission is hereby granted, free of charge, to any person obtaining a
00011 // copy of this software and associated documentation files (the "Software"),
00012 // to deal in the Software without restriction, including without limitation
00013 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00014 // and/or sell copies of the Software, and to permit persons to whom the
00015 // Software is furnished to do so, subject to the following conditions:
00016 //
00017 // The above copyright notice and this permission notice shall be included
00018 // in all copies or substantial portions of the Software.
00019 //
00020 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00021 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00023 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00024 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00025 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00026 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00027 //
00029 //
00030 //%/////////////////////////////////////////////////////////////////////////////
00031 
00032 #ifndef Pegasus_String_h
00033 #define Pegasus_String_h
00034 
00035 #ifdef PEGASUS_OS_HPUX
00036 # ifdef HPUX_IA64_NATIVE_COMPILER
00037 #  include <iostream>
00038 # else
00039 #  include <iostream.h>
00040 # endif
00041 #else
00042 # include <iostream>
00043 #endif
00044 #include <Pegasus/Common/Config.h>
00045 #include <Pegasus/Common/Char16.h>
00046 #include <Pegasus/Common/Linkage.h>
00047 
00048 PEGASUS_NAMESPACE_BEGIN
00049 
00050 class String;
00051 struct StringRep;
00052 
00056 class PEGASUS_COMMON_LINKAGE CString
00057 {
00058 public:
00059 
00063     CString();
00064 
00069     CString(const CString& cstr);
00070 
00074     ~CString();
00075 
00082     CString& operator=(const CString& cstr);
00083 
00097     operator const char*() const;
00098 
00099 private:
00100 
00101     CString(char* cstr);
00102 
00103     friend class String;
00104 
00105     char* _rep;
00106 };
00107 
00118 class PEGASUS_COMMON_LINKAGE String
00119 {
00120 public:
00121 
00126     static const String EMPTY;
00127 
00131     String();
00132 
00137     String(const String& str);
00138 
00149     String(const String& str, Uint32 n);
00150 
00158     String(const Char16* str);
00159 
00169     String(const Char16* str, Uint32 n);
00170 
00179     String(const char* str);
00180 
00191     String(const char* str, Uint32 n);
00192 
00196     ~String();
00197 
00206     String& operator=(const String& str);
00207 
00216     String& assign(const String& str);
00217 
00227     String& assign(const Char16* str);
00228 
00240     String& assign(const Char16* str, Uint32 n);
00241 
00253     String& assign(const char* str);
00254 
00267     String& assign(const char* str, Uint32 n);
00268 
00272     void clear();
00273 
00283     void reserveCapacity(Uint32 capacity);
00284 
00290     Uint32 size() const;
00291 
00299     const Char16* getChar16Data() const;
00300 
00317     CString getCString() const;
00318 
00326     Char16& operator[](Uint32 index);
00327 
00335     const Char16 operator[](Uint32 index) const;
00336 
00345     String& append(const Char16& c);
00346 
00359     String& append(const Char16* str, Uint32 n);
00360 
00369     String& append(const String& str);
00370 
00384     void remove(Uint32 index, Uint32 size = PEG_NOT_FOUND);
00385 
00401     String subString(Uint32 index, Uint32 n = PEG_NOT_FOUND) const;
00402 
00410     Uint32 find(Char16 c) const;
00411 
00421     Uint32 find(Uint32 index, Char16 c) const;
00422 
00431     Uint32 find(const String& s) const;
00432 
00440     Uint32 reverseFind(Char16 c) const;
00441 
00445     void toLower();
00446 
00447 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00448 
00452     void toUpper();
00453 #endif
00454 
00464     static int compare(const String& s1, const String& s2, Uint32 n);
00465 
00474     static int compare(const String& s1, const String& s2);
00475 
00484     static int compareNoCase(const String& s1, const String& s2);
00485 
00497     static Boolean equal(const String& s1, const String& s2);
00498 
00507     static Boolean equalNoCase(const String& s1, const String& s2);
00508 
00509 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00510 
00511     String(const String& s1, const String& s2);
00512 
00513     String(const String& s1, const char* s2);
00514 
00515     String(const char* s1, const String& s2);
00516 
00517     String& operator=(const char* str);
00518 
00519     Uint32 find(const char* s) const;
00520 
00521     static Boolean equal(const String& s1, const char* s2);
00522 
00523     static int compare(const String& s1, const char* s2);
00524 
00525     String& append(const char* str);
00526 
00527     String& append(const char* str, Uint32 size);
00528 
00529     static Boolean equalNoCase(const String& s1, const char* s2);
00530 
00531 #endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */
00532 
00533 private:
00534 
00535     StringRep* _rep;
00536 };
00537 
00544 PEGASUS_COMMON_LINKAGE Boolean operator==(
00545     const String& str1,
00546     const String& str2);
00547 
00554 PEGASUS_COMMON_LINKAGE Boolean operator==(const String& str1, const char* str2);
00555 
00562 PEGASUS_COMMON_LINKAGE Boolean operator==(const char* str1, const String& str2);
00563 
00570 PEGASUS_COMMON_LINKAGE Boolean operator!=(
00571     const String& str1,
00572     const String& str2);
00573 
00581 PEGASUS_COMMON_LINKAGE PEGASUS_STD(ostream)& operator<<(
00582     PEGASUS_STD(ostream)& os,
00583     const String& str);
00584 
00597 PEGASUS_COMMON_LINKAGE String operator+(const String& str1, const String& str2);
00598 
00605 PEGASUS_COMMON_LINKAGE Boolean operator<(
00606     const String& str1,
00607     const String& str2);
00608 
00616 PEGASUS_COMMON_LINKAGE Boolean operator<=(
00617     const String& str1,
00618     const String& str2);
00619 
00626 PEGASUS_COMMON_LINKAGE Boolean operator>(
00627     const String& str1,
00628     const String& str2);
00629 
00637 PEGASUS_COMMON_LINKAGE Boolean operator>=(
00638     const String& str1,
00639     const String& str2);
00640 
00641 #ifdef PEGASUS_USE_EXPERIMENTAL_INTERFACES
00642 
00643 PEGASUS_COMMON_LINKAGE Boolean operator==(const String& s1, const String& s2);
00644 
00645 PEGASUS_COMMON_LINKAGE Boolean operator==(const String& s1, const char* s2);
00646 
00647 PEGASUS_COMMON_LINKAGE Boolean operator==(const char* s1, const String& s2);
00648 
00649 PEGASUS_COMMON_LINKAGE Boolean operator!=(const String& s1, const String& s2);
00650 
00651 PEGASUS_COMMON_LINKAGE Boolean operator!=(const String& s1, const char* s2);
00652 
00653 PEGASUS_COMMON_LINKAGE Boolean operator!=(const char* s1, const String& s2);
00654 
00655 PEGASUS_COMMON_LINKAGE Boolean operator<(const String& s1, const String& s2);
00656 
00657 PEGASUS_COMMON_LINKAGE Boolean operator<(const String& s1, const char* s2);
00658 
00659 PEGASUS_COMMON_LINKAGE Boolean operator<(const char* s1, const String& s2);
00660 
00661 PEGASUS_COMMON_LINKAGE Boolean operator>(const String& s1, const String& s2);
00662 
00663 PEGASUS_COMMON_LINKAGE Boolean operator>(const String& s1, const char* s2);
00664 
00665 PEGASUS_COMMON_LINKAGE Boolean operator>(const char* s1, const String& s2);
00666 
00667 PEGASUS_COMMON_LINKAGE Boolean operator<=(const String& s1, const String& s2);
00668 
00669 PEGASUS_COMMON_LINKAGE Boolean operator<=(const String& s1, const char* s2);
00670 
00671 PEGASUS_COMMON_LINKAGE Boolean operator<=(const char* s1, const String& s2);
00672 
00673 PEGASUS_COMMON_LINKAGE Boolean operator>=(const String& s1, const String& s2);
00674 
00675 PEGASUS_COMMON_LINKAGE Boolean operator>=(const String& s1, const char* s2);
00676 
00677 PEGASUS_COMMON_LINKAGE Boolean operator>=(const char* s1, const String& s2);
00678 
00679 PEGASUS_COMMON_LINKAGE String operator+(const String& s1, const String& s2);
00680 
00681 PEGASUS_COMMON_LINKAGE String operator+(const String& s1, const char* s2);
00682 
00683 PEGASUS_COMMON_LINKAGE String operator+(const char* s1, const String& s2);
00684 
00685 #endif /* PEGASUS_USE_EXPERIMENTAL_INTERFACES */
00686 
00687 PEGASUS_NAMESPACE_END
00688 
00689 #if defined(PEGASUS_INTERNALONLY)
00690 # include "StringInline.h"
00691 #endif
00692 
00693 #endif /* Pegasus_String_h */