Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages | Examples

wtstring.h

00001 //  Copyright (c) 1996-2002 by Autodesk, Inc.
00002 //
00003 //  By using this code, you are agreeing to the terms and conditions of
00004 //  the License Agreement included in the documentation for this code.
00005 //
00006 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00007 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00008 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00009 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00010 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00011 //
00012 //  Use, duplication, or disclosure by the U.S. Government is subject to
00013 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00014 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00015 //  Data and Computer Software), as applicable.
00016 //
00017 
00018 #if !defined WTSTRING_HEADER
00019 #define WTSTRING_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 
00024 class WHIPTK_API WT_String
00025 {
00027     enum WT_Materialize_Stage
00028     {
00029         Eating_Initial_Whitespace,
00030         Getting_String_Type,
00031         Getting_String,
00032         Getting_String_Length,
00033         Getting_String_Data,
00034         Getting_End_Quote
00035     } m_stage;
00036 
00038     enum
00039     {
00040         Not_Yet_Scanned,
00041         Only_ASCII,
00042         Non_ASCII
00043     } m_string_type;
00044 
00045     WT_Integer32                m_length;
00046     WT_Unsigned_Integer16*      m_string;
00047     WT_Byte*                    m_ascii_string;
00048     WT_Byte                     m_lead_byte;
00049 
00050 
00051 public:
00052 
00054     static const    WT_String kNull;
00055 
00057     static size_t wcslen (WT_Unsigned_Integer16 const * string);
00058 
00060 
00061     WT_String()
00062     : m_stage(Eating_Initial_Whitespace)
00063     , m_string_type(Not_Yet_Scanned)
00064     , m_length(0)
00065     , m_string(WD_Null)
00066     , m_ascii_string(WD_Null)
00067     , m_lead_byte (0)
00068     {}
00069 
00071     WT_String( WT_String const & string );
00073     WT_String( WT_Unsigned_Integer16 const * string );
00075     WT_String( WT_Byte const * string );
00077     WT_String( char const * string );
00079     WT_String( int length, WT_Unsigned_Integer16 const * string );
00081     WT_String( int length, WT_Byte const * string );
00083     WT_String( int length, char const * string );
00085     ~WT_String();
00087 
00089 
00090 
00092     WT_Result serialize(
00093         WT_File & file, 
00094         WT_Boolean force_quotes=WD_False 
00095         ) const;
00096 
00098 
00100     WT_Result materialize(
00101         WT_File & file 
00102         );
00104 
00106 
00107     char const *                   ascii()     const ;
00109     int                            length()    const { return m_length; }
00111     WT_Unsigned_Integer16 const *  unicode()   const ;
00113     operator const WT_Unsigned_Integer16 * ()  const { return unicode();}
00115     void               set( int length, WT_Unsigned_Integer16 const * string );
00117     void               set( int length, WT_Byte const * string );
00119     void               set( int length, char const * string );
00121     void               set( WT_String const & string );
00123     WT_String const &  operator= ( WT_Unsigned_Integer16 const * string );
00125     WT_String const &  operator= ( WT_Byte const * string );
00127     WT_String const &  operator= ( char const * string );
00129     WT_String const &  operator= ( WT_String const & string );
00131 
00133 
00134     WT_Boolean         operator== ( char const * string )      const;
00136     WT_Boolean         operator== ( WT_String const & string ) const;
00138     WT_Boolean         operator!= ( char const * string )      const { return !(*this==string); }
00140     WT_Boolean         operator!= ( WT_String const & string ) const { return !(*this==string); }
00142     WT_Boolean         equals(char const * string, WT_Boolean case_sensitive=WD_True ) const;
00144     WT_Boolean         equals(WT_String const & string, WT_Boolean case_sensitive=WD_True ) const;
00146     WT_Boolean         equals_no_case(char const * string ) const;
00148     WT_Boolean         equals_no_case(WT_String const & string ) const;
00150     WT_Boolean         is_ascii() const;
00152 
00154 
00155     static WT_Boolean  is_ascii( int length, WT_Unsigned_Integer16 const * string );
00157     static WT_Boolean  is_ascii( int length, char const * string );
00159 
00161 
00162 
00167     static WT_Unsigned_Integer16 * to_unicode(
00168         int length, 
00169         WT_Byte const * string 
00170         );
00171 
00173 
00177     static WT_Byte *               to_ascii(
00178         int length, 
00179         WT_Unsigned_Integer16 const * string 
00180         );
00181 
00183     static WT_Byte                 to_binary(
00184         WT_Byte ascii_hex_digit 
00185         );
00187 
00188 private:
00189     WT_Boolean                     restore();
00190     WT_Boolean                     expand();
00191 
00192 
00193 };
00194 
00195 #endif // WTSTRING_HEADER

Generated on Tue May 17 12:07:44 2005 for Autodesk DWF Whip 2D Toolkit by  doxygen 1.4.1