Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

String

00001 /*
00002  * NOTE: "zlib/libpng" style License
00003  *
00004  *                 ----=== s t d n e t ===----
00005  *
00006  * Copyright (c) 2002 Warwick Molloy   w-molloy@users.sf.net
00007  *
00008  * Copyright (c) 2002 Stdnet Community
00009  * HTTP://Sourceforge.net/projects/stdnet
00010  *
00011  * All references to "software" refer to the stdnet.
00012  *
00013  * This software is provided 'as-is', without any express or
00014  * implied warranty. In no event will the authors be held liable
00015  * for any damages arising from the use of this software.
00016  *
00017  * Permission is granted to anyone to use this software for any
00018  * purpose, including commercial applications, and to alter it
00019  * and redistribute it freely, subject to the following
00020  * restrictions:
00021  *
00022  * 1.  The origin of this software must not be misrepresented;
00023  *     you must not claim that you wrote the original software.
00024  *     If you use this software in a product, an acknowledgment
00025  *     in the product documentation would be appreciated but
00026  *     is not required.
00027  *
00028  * 2.  Altered source versions must be plainly marked as such,
00029  *     and must not be misrepresented as being the original
00030  *     software.
00031  *
00032  * 3.  This notice may not be removed or altered from any source
00033  *     distribution.
00034  */
00035 
00036 #ifndef __system_Class__
00037 #define __system_Class__
00038 
00039 #include <stdnet/config.h>
00040 #include <stdnet/system/Object>
00041 #include <stdnet/system/_TakeOwnership>
00042 
00043 namespace stdbase {
00044     namespace system {
00045 
00054 class String : public Object
00055 {
00056 private:
00057     char *  string_val;
00058     int     string_len;
00059 
00060 protected:
00061     String( const char s[] );
00062 
00063     String( char * const s, _TakeOwnership);
00064 
00065     String(
00066         const char s[],
00067         const int len
00068     );
00069 
00070     String(
00071         char * const s,
00072         const int len,
00073         _TakeOwnership o
00074     );
00075 
00076     virtual ~String();
00077 
00078 public:
00079     virtual bool
00080         equals( ObjectRef obj) const;
00081 
00082     static reference< String >
00083         create( const char val[] );
00084 
00085     static reference< String >
00086         create( const char val[], const int len );
00087 
00088     static reference< String >
00089         create( char * const val, _TakeOwnership);
00090 
00091     static reference< String >
00092         create(
00093             char * const val,
00094             const int len,
00095             _TakeOwnership
00096         );
00097 
00098     virtual int
00099         length() const;
00100 
00101     virtual void
00102         getChars(
00103             int     srcBegin,
00104             int     srcEnd,
00105             char    dst[],
00106             int     dstBegin
00107         ) const;
00108 };
00109 
00110 //typedef reference<String>   StringRef;
00111 class StringRef : public reference< String >
00112 {
00113 public:
00114     StringRef( String * p)
00115         : reference<String>( p )
00116     {};
00117 
00118     StringRef( Object * p)
00119         : reference<String>( p )
00120     {};
00121 
00122     StringRef( const StringRef & r)
00123         : reference<String>( r )
00124     {};
00125 
00126     StringRef( const ObjectRef & r)
00127         : reference<String>( r )
00128     {};
00129 
00130     StringRef( const reference<String> & r)
00131         : reference<String>( r )
00132     {};
00133 
00134     StringRef( const char text[] )
00135         : reference<String>( String::create( text ) )
00136     {};
00137 
00138     ~StringRef()
00139     {};
00140 
00147     StringRef
00148     operator + (
00149             const StringRef & b
00150         ) const;
00151 
00158     StringRef
00159     operator + (
00160             const char        b[]
00161         ) const;
00162 
00169     StringRef
00170     operator + (
00171             const int  b_int
00172         ) const;
00173 
00174 };
00175 
00176     } // -- end namespace system --
00177 } // ------ end namespace stdbase --
00178 
00179 
00180 //  -- Globally accessible operators --
00181 //
00182 
00183 // ---- Operators in reverse direction -----
00184 
00191 inline stdbase::system::StringRef
00192 operator + (
00193         const int                   b_int,
00194         stdbase::system::StringRef  a
00195     )
00196 {   return  a.operator+ (b_int); }
00197 
00204 inline stdbase::system::StringRef
00205 operator + (
00206         const char                  b[],
00207         stdbase::system::StringRef  a
00208     )
00209 {   return a.operator +(b);  }
00210 
00211 
00212 
00213 #endif      //  __system_Class__
00214 

Generated at Tue Aug 13 14:19:39 2002 for stdnet2 by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001