it_bus/string.h

00001 #ifndef _IT_BUS_STRING_H_
00002 #define _IT_BUS_STRING_H_
00003 
00004 //  @Copyright (c) 2004 IONA Technologies PLC. All Rights Reserved.
00005 //
00006 
00007 #include <stdio.h>
00008 #include <it_cal/types.h>
00009 #include <it_dsa/string.h>
00010 #include <it_bus/api_defines.h>
00011 
00012 namespace IT_Bus
00013 {
00014     class StringBody;          // Private implementation details.
00015     
00021     class IT_AFC_API String
00022     {
00023       public:
00024         
00025         enum { npos = ULONG_MAX };
00026         enum { icu_npos = LONG_MAX };
00027 
00028         typedef char*       iterator;
00029         typedef const char* const_iterator;
00030 
00032         typedef IT_UShort UChar;
00033 
00034         // The empty string.
00035         // 
00036         static const String EMPTY;
00037 
00038         // Constructors
00039         //
00040         String(
00041             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00042         );
00043         String(
00044             const char*          cb,
00045             size_t               n = npos,
00046             const char*          encoding = 0,
00047             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00048         );
00049         String(
00050             const char*          cb,
00051             bool                 c_str,
00052             size_t               n,
00053             const char*          encoding = 0,
00054             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00055         );
00056         String(
00057             size_t               n,
00058             char                 c,
00059             const char*          encoding = 0,
00060             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00061         );
00062         String(
00063             const String&    s,
00064             size_t               pos = 0,
00065             size_t               n   = npos,
00066             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00067         );
00068         String(
00069             const IT_String&     s,
00070             size_t               pos = 0,
00071             size_t               n   = npos,
00072             const char*          encoding = 0,
00073             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00074         );
00075 
00081         String(
00082             const char*          str,
00083             IT_StringRep::Policy policy,
00084             size_t               n = npos,
00085             const char*          encoding = 0,
00086             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00087         );
00088 
00097         String(
00098             const UChar*         uchars,
00099             IT_StringRep::Policy policy,
00100             size_t               n  = npos,
00101             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00102         );
00103             
00105         String(
00106             const UChar*      sb,
00107             const IT_String&      encoding,            
00108             size_t                n = npos,
00109             IT_StringRep::Policy  policy = IT_StringRep::COPY,
00110             IT_ExceptionHandler&  eh = IT_EXCEPTION_HANDLER
00111         );
00112 
00116         String(
00117             const wchar_t*        wb,            
00118             size_t                n = npos,
00119             IT_StringRep::Policy  policy = IT_StringRep::COPY,
00120             IT_ExceptionHandler&  eh = IT_EXCEPTION_HANDLER
00121         );
00122         
00123         ~String();
00124         
00125         // Capacity
00126         //
00127         size_t size() const;
00128         size_t length() const;
00129         size_t max_size() const;
00130 
00131         void
00132         resize(
00133             size_t               n,
00134             char                 c  = '\0',
00135             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00136         );
00137         
00138         size_t 
00139         capacity() const;
00140         
00141         void
00142         reserve(
00143             size_t               res_arg = 0,
00144             IT_ExceptionHandler& eh      = IT_EXCEPTION_HANDLER
00145         );
00146         
00147         IT_Bool
00148         empty() const;
00149         
00150         // Copy and swap
00151         //
00152         size_t
00153         copy(
00154             char*                s,
00155             size_t               n,
00156             size_t               pos = 0,
00157             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00158         ) const;
00159 
00160         void
00161         swap(
00162             String& s
00163         );
00164         
00165         // char* operations
00166         //
00167         const char* c_str(
00168             const char* encoding = 0
00169         ) const;  // NUL-terminated
00170         
00171         const char* c_str(
00172             const char* encoding,
00173             size_t& len
00174         ) const;  // NUL-terminated
00175 
00176         const char*
00177         data() const;   // might not be NUL-terminated
00178         
00179         // IT_String operations
00180         //
00181         IT_String 
00182         get_it_string() const;
00183 
00184         operator IT_String() const;
00185                 
00186         // utf16 buffer operations
00187         //
00188         const UChar*
00189         utf16_str() const;
00190 
00191         // Deprecated, for backwards compatibility.
00192         const UChar*
00193         utf16_str();
00194         
00195         // wchar_t* operations
00196         //
00197         const wchar_t*
00198         wchar_t_str() const;
00199         
00200         // Char encoding access
00201         //
00202         IT_String
00203         get_encoding() const;
00204 
00205         IT_Bool
00206         is_unicode() const;
00207         
00208         // Element access
00209         //
00210         char operator[](size_t index) const;
00211         char& operator[](size_t index);
00212         char at(size_t index) const;
00213         inline char& at(size_t index);
00214         
00215         // char* Iterators
00216         //
00217         iterator begin();
00218         const_iterator begin() const;
00219         iterator end();
00220         const_iterator end() const;
00221         
00222         // Assignment
00223         //
00224         String&
00225         operator=(
00226             const String& other
00227         );
00228         String&
00229         operator=(
00230             const IT_String& other
00231         );
00232         String&
00233         operator=(
00234             const char* str
00235         );
00236         String&
00237         operator=(
00238             char c
00239         );
00240         String&
00241         assign(
00242             const IT_String&     s,
00243             size_t               pos = 0,
00244             size_t               n   = npos,
00245             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00246         );
00247         String&
00248         assign(
00249             const String&     s,
00250             size_t               pos = 0,
00251             size_t               n   = npos,
00252             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00253         );
00254         String&
00255         assign(
00256             const char*          s,
00257             size_t               n  = npos,
00258             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00259         );
00260         String&
00261         assign(
00262             size_t               n,
00263             char                 c,
00264             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00265         );
00266         
00267         // Insertion
00268         //
00269         String&
00270         insert(
00271             size_t               pos,
00272             const String&     s,
00273             size_t               pos2 = 0,
00274             size_t               n    = npos,
00275             IT_ExceptionHandler& eh   = IT_EXCEPTION_HANDLER
00276         );
00277         String&
00278         insert(
00279             size_t               pos,
00280             const IT_String&     s,
00281             size_t               pos2 = 0,
00282             size_t               n    = npos,
00283             IT_ExceptionHandler& eh   = IT_EXCEPTION_HANDLER
00284         );
00285         String&
00286         insert(
00287             size_t               pos,
00288             const char*          s,
00289             size_t               n  = npos,
00290             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00291         );
00292         String&
00293         insert(
00294             size_t               pos,
00295             size_t               n,
00296             char                 c,
00297             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00298         );
00299         iterator
00300         insert(
00301             iterator             p,
00302             char                 c  = '\0',
00303             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00304         );
00305         void
00306         insert(
00307             iterator             p,
00308             size_t               n,
00309             char                 c,
00310             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00311         );
00312         
00319         String&
00320         insert(
00321             size_t               pos,
00322             const UChar*         uchars,
00323             size_t               n  = npos,
00324             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00325         );
00326         
00327         // Modifiers
00328         //
00329         String&
00330         operator+=(
00331             const IT_String& other
00332         );
00333         String&
00334         operator+=(
00335             const String& other
00336         );
00337         String&
00338         operator+=(
00339             const char* str
00340         );
00341         String&
00342         operator+=(
00343             char c
00344         );      
00345         String&
00346         append(
00347             const IT_String&     s,
00348             size_t               pos = 0,
00349             size_t               n   = npos,
00350             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00351         );
00352         String&
00353         append(
00354             const String&     s,
00355             size_t               pos = 0,
00356             size_t               n   = npos,
00357             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00358         );
00359         String&
00360         append(
00361             const char*          cb,
00362             size_t               n  = npos,
00363             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00364         );
00365         String&
00366         append(
00367             size_t               n,
00368             char                 c,
00369             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00370         );
00371         
00377         String&
00378         append(
00379             const UChar*         uchars,
00380             size_t               n  = npos,
00381             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00382         );
00383         
00384         // Erasure
00385         //
00386         String&
00387         erase(
00388             size_t               pos = 0,
00389             size_t               n   = String::npos,
00390             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00391         );
00392         iterator
00393         erase(
00394             iterator             p,
00395             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00396         );
00397         iterator
00398         erase(
00399             iterator             first,
00400             iterator             last,
00401             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00402         );
00403         
00404         // Replacement
00405         //
00406         String&
00407         replace(
00408             size_t               pos,
00409             size_t               n,
00410             const String&    s,
00411             size_t               pos2 = 0,
00412             size_t               n2   = npos,
00413             IT_ExceptionHandler& eh   = IT_EXCEPTION_HANDLER
00414         );
00415         String&
00416         replace(
00417             size_t               pos,
00418             size_t               n,
00419             const char*          s,
00420             size_t               n2 = npos,
00421             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00422         );
00423         String&
00424         replace(
00425             size_t               pos,
00426             size_t               n,
00427             size_t               n2,
00428             char                 c,
00429             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00430         );
00431         String&
00432         replace(
00433             iterator             i1,
00434             iterator             i2,
00435             const String&     s,
00436             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00437         );
00438         String&
00439         replace(
00440             iterator             i1,
00441             iterator             i2,
00442             const char*          s,
00443             size_t               n  = npos,
00444             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00445         );
00446         String&
00447         replace(
00448             iterator             i1,
00449             iterator             i2,
00450             size_t               n,
00451             char                 c,
00452             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00453         );
00454 
00462         String&
00463         replace(
00464             size_t               pos,
00465             size_t               n,
00466             const UChar*         uchars,
00467             size_t               n2 = npos,
00468             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00469         );
00470         
00471         // Search
00472         //
00473         size_t
00474         find(
00475             const String& s,
00476             size_t           pos = 0
00477         ) const;
00478         size_t
00479         find(
00480             const char*          s,
00481             size_t               pos,
00482             size_t               n,
00483             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00484         ) const;
00485         size_t
00486         find(
00487             const char*          s,
00488             size_t               pos = 0,
00489             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00490         ) const;
00491         size_t
00492         find(
00493             char                 c,
00494             size_t               pos = 0,
00495             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00496         ) const;
00497 
00498         size_t
00499         rfind(
00500             const String& s,
00501             size_t           pos = npos
00502         ) const;
00503         size_t
00504         rfind(
00505             const char*          s,
00506             size_t               pos,
00507             size_t               n,
00508             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00509         ) const;
00510         size_t
00511         rfind(
00512             const char*          s,
00513             size_t               pos = npos,
00514             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00515         ) const;
00516         size_t
00517         rfind(
00518             char                 c,
00519             size_t               pos = npos,
00520             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00521         ) const;
00522         
00523         // Character set searching
00524         //
00525         size_t
00526         find_first_of(
00527             const String& s,
00528             size_t           pos = 0
00529         ) const;
00530         size_t
00531         find_first_of(
00532             const char*          s,
00533             size_t               pos,
00534             size_t               n,
00535             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00536         ) const;
00537         size_t
00538         find_first_of(
00539             const char*          s,
00540             size_t               pos = 0,
00541             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00542         ) const;
00543         size_t
00544         find_first_of(
00545             char                 c,
00546             size_t               pos = 0,
00547             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00548         ) const;
00549         size_t
00550         find_last_of(
00551             const String& s,
00552             size_t           pos = npos
00553         ) const;
00554         size_t
00555         find_last_of(
00556             const char*          s,
00557             size_t               pos,
00558             size_t               n,
00559             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00560         ) const;
00561         size_t
00562         find_last_of(
00563             const char*          s,
00564             size_t               pos = npos,
00565             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00566         ) const;
00567         size_t
00568         find_last_of(
00569             char                 c,
00570             size_t               pos = npos,
00571             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00572         ) const;
00573         size_t
00574         find_first_not_of(
00575             const String& s,
00576             size_t           pos = 0
00577         ) const;
00578         size_t
00579         find_first_not_of(
00580             const char*          s,
00581             size_t               pos,
00582             size_t               n,
00583             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00584         ) const;
00585         size_t
00586         find_first_not_of(
00587             const char*          s,
00588             size_t               pos = 0,
00589             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00590         ) const;
00591         size_t
00592         find_first_not_of(
00593             char                 c,
00594             size_t               pos = 0,
00595             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00596         ) const;
00597         size_t
00598         find_last_not_of(
00599             const String& s,
00600             size_t           pos = npos
00601         ) const;
00602         size_t
00603         find_last_not_of(
00604             const char*          s,
00605             size_t               pos,
00606             size_t               n,
00607             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00608         ) const;
00609         size_t
00610         find_last_not_of(
00611             const char*          s,
00612             size_t               pos = npos,
00613             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00614         ) const;
00615         size_t
00616         find_last_not_of(
00617             char                 c,
00618             size_t               pos = npos,
00619             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00620         ) const;
00621         
00622         // Substring
00623         //
00624         String
00625         substr(
00626             size_t               pos = 0,
00627             size_t               n   = npos,
00628             IT_ExceptionHandler& eh  = IT_EXCEPTION_HANDLER
00629         ) const;
00630         
00631         // Comparison / Predicates
00632         //
00633         int
00634         compare(
00635             const String& s
00636         ) const;
00637         
00638         int
00639         compare(
00640             size_t               pos1,
00641             size_t               n1,
00642             const String&    s,
00643             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00644         ) const;
00645         
00646         int
00647         compare(
00648             size_t               pos1,
00649             size_t               n1,
00650             const String&    s,
00651             size_t               pos2,
00652             size_t               n2,
00653             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00654         ) const;
00655 
00656         int
00657         compare(
00658             const char*          s,
00659             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00660         ) const;
00661 
00662         int
00663         compare(
00664             size_t               pos1,
00665             size_t               n1,
00666             const char*          s,
00667             size_t               n2 = npos,
00668             IT_ExceptionHandler& eh = IT_EXCEPTION_HANDLER
00669         ) const;        
00670 
00671         IT_ExceptionHandler&
00672         it_eh() const;
00673         
00674       private:
00675 
00676         char*
00677         c_ptr(
00678             const char* encoding = 0
00679         ) const;
00680 
00681         char*
00682         c_ptr(
00683             const char* encoding,
00684             size_t& len
00685         ) const;
00686 
00687         wchar_t*
00688         wchar_t_ptr() const;
00689 
00690         StringBody* m_body;
00691     };
00692 
00693     inline size_t
00694     String::max_size() const
00695     {
00696         return npos;
00697     }
00698 
00699     inline char
00700     String::operator[](
00701         size_t index
00702     ) const
00703     {
00704         return at(index);
00705     }
00706 
00707     inline char&
00708     String::at(
00709         size_t index
00710     )
00711     {
00712         return operator[](index);
00713     }
00714 
00715     inline String&
00716     String::operator=(
00717         const String& str
00718     )
00719     {
00720         return assign(str, 0, npos, it_eh());
00721     }
00722 
00723     inline String&
00724     String::operator=(
00725         const IT_String& str
00726     )
00727     {
00728         return assign(str, 0, npos, it_eh());
00729     }
00730 
00731     inline String&
00732     String::operator=(
00733         const char* str
00734     )
00735     {
00736         return assign(str, npos, it_eh());
00737     }
00738 
00739     inline String&
00740     String::operator=(
00741         char c
00742     )
00743     {
00744         return assign(1, c, it_eh());
00745     }
00746 
00747     inline String::iterator
00748     String::insert(
00749         String::iterator p,
00750         char                 c,
00751         IT_ExceptionHandler& eh
00752     )
00753     {
00754         insert(size_t(p - begin()), 1, c, eh);
00755         return p;
00756     }
00757 
00758     inline void
00759     String::insert(
00760         IT_String::iterator  p,
00761         size_t               n,
00762         char                 c,
00763         IT_ExceptionHandler& eh
00764     )
00765     {
00766         insert(size_t(p - begin()), n, c, eh);
00767     }
00768 
00769     inline String::iterator
00770     String::erase(
00771         String::iterator  p,
00772         IT_ExceptionHandler& eh
00773     )
00774     {
00775         erase(size_t(p - begin()), 1, eh);
00776         return p;
00777     }
00778 
00779     inline String::iterator
00780     String::erase(
00781         String::iterator first,
00782         String::iterator last,
00783         IT_ExceptionHandler& eh
00784     )
00785     {
00786         erase(size_t(first - begin()), size_t(last - first + 1), eh);
00787         return first;
00788     }
00789 
00790     inline String&
00791     String::operator+=(
00792         const String& str
00793     )
00794     {
00795         return append(str, 0, npos, it_eh());
00796     }
00797 
00798     inline String&
00799     String::operator+=(
00800         const IT_String& str
00801     )
00802     {
00803         return append(str, 0, npos, it_eh());
00804     }
00805 
00806     inline String&
00807     String::operator+=(
00808         const char* str
00809     )
00810     {
00811         return append(str, npos, it_eh());
00812     }
00813 
00814     inline String&
00815     String::operator+=(
00816         char c
00817     )
00818     {
00819         return append(1, c, it_eh());
00820     }
00821 
00822     inline int
00823     String::compare(
00824         size_t               pos1,
00825         size_t               n1,
00826         const String&    s,
00827         IT_ExceptionHandler& eh
00828     ) const
00829     {
00830         String s1(*this, pos1, n1, eh);
00831         return s1.compare(s);
00832     }
00833 
00834     inline int
00835     String::compare(
00836         size_t               pos1,
00837         size_t               n1,
00838         const String&    s,
00839         size_t               pos2,
00840         size_t               n2,
00841         IT_ExceptionHandler& eh
00842     ) const
00843     {
00844         String s1(*this, pos1, n1, eh), s2(s, pos2, n2, eh);
00845         return s1.compare(s2);
00846     }
00847 
00848 
00849     inline IT_Bool
00850     operator==(
00851         const String& s1,
00852         const String& s2
00853     )
00854     {
00855         return s1.compare(s2) == 0;
00856     }
00857 
00858     inline IT_Bool
00859     operator==(
00860         const String& s1,
00861         const char*   s2
00862     )
00863     {
00864         if(s1.is_unicode())
00865         {
00866             return s1.compare(String(s2, String::npos, "", s1.it_eh())) == 0;
00867         }
00868         else
00869         {
00870             return s1.compare(String(s2, String::npos, 0, s1.it_eh())) == 0;
00871         }
00872     }
00873 
00874     inline IT_Bool
00875     operator==(
00876         const char*   s1,
00877         const String& s2
00878     )
00879     {
00880         return s2 == s1;
00881     }
00882 
00883     inline IT_Bool
00884     operator==(
00885         const String&    s1,
00886         const IT_String& s2
00887     )
00888     {
00889         if(s1.is_unicode())
00890         {
00891             return s1.compare(String(s2, 0, String::npos, "",s1.it_eh())) == 0;
00892         }
00893         else
00894         {
00895             return s1.compare(String(s2, 0, String::npos, 0, s1.it_eh())) == 0;
00896         }
00897     }
00898 
00899     inline IT_Bool
00900     operator==(
00901         const IT_String& s1,
00902         const String&    s2
00903     )
00904     {
00905         return s2 == s1;
00906     }
00907 
00908     inline IT_Bool
00909     operator!=(
00910         const String& s1,
00911         const String& s2
00912     )
00913     {
00914         return !(s1 == s2);
00915     }
00916 
00917     inline IT_Bool
00918     operator!=(
00919         const String& s1,
00920         const char*   s2
00921     )
00922     {
00923         return !(s1 == s2);
00924     }
00925 
00926     inline IT_Bool
00927     operator!=(
00928         const char*   s1,
00929         const String& s2
00930     )
00931     {
00932         return !(s1 == s2);
00933     }
00934 
00935     inline IT_Bool
00936     operator!=(
00937         const String&    s1,
00938         const IT_String& s2
00939     )
00940     {
00941         return !(s1 == s2);
00942     }
00943     
00944     inline IT_Bool
00945     operator!=(
00946         const IT_String& s1,
00947         const String&    s2
00948     )
00949     {
00950         return !(s1 == s2);
00951     }
00952     
00953 
00954     inline String
00955     operator+(
00956         const String& s1,
00957         const String& s2
00958     )
00959     {
00960         String newstr(s1, 0, String::npos, s1.it_eh());
00961         newstr += s2;
00962         return newstr;
00963     }
00964 
00965     inline String
00966     operator+(
00967         const char*   s1,
00968         const String& s2
00969     )
00970     {
00971         if(s2.is_unicode())
00972         {
00973             String newstr(s1, String::npos, "", s2.it_eh());
00974             newstr += s2;
00975             return newstr;
00976         }
00977         else
00978         {
00979             String newstr(s1, String::npos, 0, s2.it_eh());
00980             newstr += s2;
00981             return newstr;
00982         }
00983     }
00984 
00985     inline String
00986     operator+(
00987         const String& s1,
00988         const char*   s2
00989     )
00990     {
00991         String newstr(s1, 0, String::npos, s1.it_eh());
00992         
00993         if(s1.is_unicode())
00994         {
00995             newstr += String(s2, String::npos, "", s1.it_eh());
00996         }
00997         else
00998         {
00999             newstr += String(s2, String::npos, 0, s1.it_eh());
01000         }
01001         return newstr;
01002     }
01003 
01004     inline String
01005     operator+(
01006         char          c,
01007         const String& s2
01008     )
01009     {
01010         if(s2.is_unicode())
01011         {
01012             String newstr(1, c, "", s2.it_eh());
01013             newstr += s2;
01014             return newstr;
01015         }
01016         else
01017         {
01018             String newstr(1, c, 0, s2.it_eh());
01019             newstr += s2;
01020             return newstr;
01021         }
01022     }
01023 
01024     inline String
01025     operator+(
01026         const String& s,
01027         char          c
01028     )
01029     {
01030         String newstr(s, 0, String::npos, s.it_eh());
01031         
01032         if(s.is_unicode())
01033         {
01034             newstr += String(1, c, "", s.it_eh());
01035         }
01036         else
01037         {
01038             newstr += String(1, c, 0, s.it_eh());
01039         }
01040         return newstr;
01041     }
01042 
01043     inline String
01044     operator+(
01045         const IT_String& s1,
01046         const String& s2
01047     )
01048     {
01049         if(s2.is_unicode())
01050         {
01051             String newstr(s1, 0, String::npos, "", s1.it_eh());
01052             newstr += s2;
01053             return newstr;
01054         }
01055         else
01056         {
01057             String newstr(s1, 0, String::npos, 0, s1.it_eh());
01058             newstr += s2;
01059             return newstr;
01060         }
01061     }
01062 
01063     inline String
01064     operator+(
01065         const String& s1,
01066         const IT_String&   s2
01067     )
01068     {
01069         String newstr(s1, 0, String::npos, s1.it_eh());
01070         
01071         if(s1.is_unicode())
01072             newstr += String(s2, 0, String::npos, "", s1.it_eh());
01073         else
01074             newstr += String(s2, 0, String::npos, 0, s1.it_eh());
01075         return newstr;
01076     }
01077 }
01078 
01079 
01080 #ifndef IT_IOSTREAMS_FREE
01081 inline IT_ostream& 
01082 operator<<(
01083     IT_ostream& os, 
01084     const IT_Bus::String& buffer
01085 )
01086 {
01087     return os << (const char*) buffer.c_str();
01088 }  
01089 #endif 
01090 
01091 #endif 

Generated on Tue Mar 20 15:27:44 2007 for Artix by  doxygen 1.5.1-p1