wtstring.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 #if !defined WTSTRING_HEADER
00019 #define WTSTRING_HEADER
00020 
00024 
00025 #include "whiptk/whipcore.h"
00026 
00027 class WT_File;
00028 
00030 class WHIPTK_API WT_String
00031 {
00033     enum WT_Materialize_Stage
00034     {
00035         Eating_Initial_Whitespace,
00036         Getting_String_Type,
00037         Getting_String,
00038         Getting_String_Length,
00039         Getting_String_Data,
00040         Getting_End_Quote
00041     } m_stage;
00042 
00044     enum
00045     {
00046         Not_Yet_Scanned,
00047         Only_ASCII,
00048         Non_ASCII
00049     } m_string_type;
00050 
00051     WT_Integer32                m_length;
00052     WT_Unsigned_Integer16*      m_string;
00053     WT_Byte*                    m_ascii_string;
00054     WT_Byte                     m_lead_byte;
00055 
00056 
00057 public:
00058 
00060     static const    WT_String kNull;
00061 
00064     static int wcslen (WT_Unsigned_Integer16 const * string);
00065 
00067 
00068     WT_String()
00069     : m_stage(Eating_Initial_Whitespace)
00070     , m_string_type(Not_Yet_Scanned)
00071     , m_length(0)
00072     , m_string(WD_Null)
00073     , m_ascii_string(WD_Null)
00074     , m_lead_byte (0)
00075     {}
00076 
00078     WT_String( WT_String const & string ) throw(WT_Result);
00080     WT_String( WT_Unsigned_Integer16 const * string ) throw(WT_Result);
00082     WT_String( WT_Byte const * string ) throw(WT_Result);
00084     WT_String( char const * string ) throw(WT_Result);
00086     WT_String( int length, WT_Unsigned_Integer16 const * string ) throw(WT_Result);
00088     WT_String( int length, WT_Byte const * string ) throw(WT_Result);
00090     WT_String( int length, char const * string ) throw(WT_Result);
00092     ~WT_String();
00094 
00096 
00097 
00099     WT_Result serialize(
00100         WT_File & file, 
00101         WT_Boolean force_quotes=WD_False 
00102         ) const;
00103 
00105 
00107     WT_Result materialize(
00108         WT_File & file 
00109         );
00111 
00113 
00114     char const *                   ascii()     const ;
00116     int                            length()    const { return m_length; }
00118     WT_Unsigned_Integer16 const *  unicode()   const ;
00120     operator const WT_Unsigned_Integer16 * ()  const { return unicode();}
00122     WT_Result               set( int length, WT_Unsigned_Integer16 const * string );
00124     WT_Result               set( int length, WT_Byte const * string );
00126     WT_Result               set( int length, char const * string );
00128     WT_Result               set( WT_String const & string );
00130     WT_String const &  operator= ( WT_Unsigned_Integer16 const * string ) throw(WT_Result);
00132     WT_String const &  operator= ( WT_Byte const * string ) throw(WT_Result);
00134     WT_String const &  operator= ( char const * string ) throw(WT_Result);
00136     WT_String const &  operator= ( WT_String const & string ) throw(WT_Result);
00138 
00140 
00141     WT_Boolean         operator== ( char const * string )      const;
00143     WT_Boolean         operator== ( WT_String const & string ) const;
00145     WT_Boolean         operator!= ( char const * string )      const { return !(*this==string); }
00147     WT_Boolean         operator!= ( WT_String const & string ) const { return !(*this==string); }
00149     WT_Boolean         equals(char const * string, WT_Boolean case_sensitive=WD_True ) const;
00151     WT_Boolean         equals(WT_String const & string, WT_Boolean case_sensitive=WD_True ) const;
00153     WT_Boolean         equals_no_case(char const * string ) const;
00155     WT_Boolean         equals_no_case(WT_String const & string ) const;
00157     WT_Boolean         is_ascii() const;
00159 
00160 #ifdef WHIP_USE_WCHAR_STRINGS
00161 
00162 
00163 
00166     WT_String( wchar_t const * string ) throw(WT_Result);
00168 
00171     WT_Result               set( int length, wchar_t const * string );
00173 
00176     WT_String const & operator= ( wchar_t const * string ) throw(WT_Result);
00178 #endif
00179 
00180 
00182 
00183     static WT_Boolean  is_ascii( int length, WT_Unsigned_Integer16 const * string );
00185     static WT_Boolean  is_ascii( int length, char const * string );
00187 
00189 
00190 
00195     static WT_Unsigned_Integer16 * to_unicode(
00196         int length, 
00197         WT_Byte const * string 
00198         ) throw(WT_Result);
00199 
00201 
00207     static wchar_t * to_wchar(
00208         int length, 
00209         WT_Unsigned_Integer16 const * string 
00210         ) throw(WT_Result);
00211 
00213 
00217     static WT_Byte *               to_ascii(
00218         int length, 
00219         WT_Unsigned_Integer16 const * string 
00220         ) throw(WT_Result);
00221 
00223     static WT_Byte                 to_binary(
00224         WT_Byte ascii_hex_digit 
00225         );
00227 
00228 private:
00229     WT_Boolean                     restore();
00230     WT_Boolean                     expand();
00231 
00232 
00233 };
00234 
00235 #endif // WTSTRING_HEADER

Generated on Tue Jan 6 22:41:13 2009 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.5