attribute_url.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 
00019 #if !defined ATTRIBUTE_URL_HEADER
00020 #define ATTRIBUTE_URL_HEADER
00021 
00025 
00026 
00027 #include "whiptk/url.h"
00028 
00029 class WT_File;
00030 class WT_URL_Item;
00031 
00036 
00037 
00040 class WHIPTK_API WT_Attribute_URL : public WT_Attribute
00041 {
00042     friend class WT_Rendition;
00043         friend class WT_Opcode;
00044         friend class WT_W2D_Class_Factory;
00045 
00046 protected:
00047 
00048     int                          m_incarnation;
00049     WT_Integer32                 m_current_index;
00050     WT_String                    m_current_address;
00051     WT_String                    m_current_friendly_name;
00052     WT_URL_List                  m_url_list;
00053     WT_Integer32                 m_count;
00054     WT_Integer32                 m_attribute_id;
00055 
00056     enum WT_Materialize_Stage
00057     {
00058         Eating_Initial_Whitespace,
00059 
00060         Gathering_String,
00061         Eating_End_Whitespace,
00062         Skipping_Last_Paren,
00063                 Reading_AttributeID,
00064 
00065         Getting_Next_Block,
00066         Getting_Assigned_Index,
00067         Getting_Address,
00068         Getting_Friendly_Name,
00069         Getting_Closing_Block_Paren,
00070         Reading_Index,
00071         Completed
00072 
00073     }  m_stage;
00074 
00075 public:
00076 
00078 
00079     WT_Attribute_URL()
00080         : m_incarnation(-1)
00081         , m_current_index(0)
00082         , m_count(0)
00083         , m_attribute_id(-1)
00084         , m_stage(Eating_Initial_Whitespace)
00085     { }
00086 
00088     WT_Attribute_URL(WT_Attribute &attribute);
00089 
00091     WT_Attribute_URL(WT_Attribute &attribute, WT_URL_Item &item);
00092 
00094     WT_Attribute_URL(
00095         WT_Attribute &attribute, 
00096         WT_Integer32 index, 
00097         WT_Unsigned_Integer16 const * address, 
00098         WT_Unsigned_Integer16 const * friendly_name 
00099         );
00100 
00102         WT_Attribute_URL(WT_Attribute_URL const& url)
00103         {
00104                 *this = url;
00105         }
00106 
00107         virtual ~WT_Attribute_URL()
00108         {}
00110 
00111 public:
00113 
00115     WT_Integer32 const& attribute_id(void) const;
00116 
00117     inline WT_Integer32& attribute_id() { return m_attribute_id; }
00118 
00120 
00124     void add_url(
00125         WT_URL_Item & item
00126         )
00127     {
00128         WD_Assert((item.index() != WD_URL_Optimize)); // user should use add_url_optimized!
00129         m_url_list.add(item);
00130     };
00131 
00133 
00137     void add_url(
00138         WT_Integer32 index,
00139         WT_Unsigned_Integer16 const *address,
00140         WT_Unsigned_Integer16 const *friendly_name
00141         )
00142     {
00143         set(index, address, friendly_name);
00144     }
00145 
00147 
00151     void add_url(
00152         WT_Integer32 index, 
00153         WT_String & address, 
00154         WT_String & friendly_name 
00155         )
00156     {
00157         WT_URL_Item item(index, address, friendly_name);
00158         add_url(item);
00159     }
00160 
00162 
00164     void add_url_optimized(
00165         WT_URL_Item & item, 
00166         WT_File & file 
00167         );
00168 
00170 
00172     void add_url_optimized(
00173         WT_Integer32 index, 
00174         WT_Unsigned_Integer16 const *address, 
00175         WT_Unsigned_Integer16 const *friendly_name, 
00176         WT_File & file 
00177         )
00178     {
00179         WT_URL_Item item(index, address, friendly_name);
00180         add_url_optimized(item, file);
00181     }
00182 
00184 
00186     void add_url_optimized(
00187         WT_Integer32 index, 
00188         WT_String & address, 
00189         WT_String & friendly_name, 
00190         WT_File & file 
00191         )
00192     {
00193         WT_URL_Item item(index, address, friendly_name);
00194         add_url_optimized(item, file);
00195     }
00196 
00198     virtual void clear() { 
00199         m_url_list.remove_all(); 
00200         m_attribute_id = -1; 
00201         m_count = 0;
00202     }
00203 
00205 
00210     void flush_rendition(WT_File & file) ;
00211 
00213     void set(
00214         WT_Integer32 index, 
00215         WT_Unsigned_Integer16 const * address, 
00216         WT_Unsigned_Integer16 const * friendly_name 
00217         );
00218 
00220     WT_URL_List const & url()
00221     {    return m_url_list;    }
00222 
00224     virtual WT_Attribute_URL const & operator=(WT_Attribute_URL const & url);
00226 
00228     WT_ID            object_id() const;
00229     WT_Result        materialize(WT_Opcode const & opcode, WT_File & file);
00230     WT_Result        process(WT_File & file);
00231     WT_Result        skip_operand(WT_Opcode const & opcode, WT_File & file);
00232     WT_Result        serialize (WT_File & file) const;
00233     WT_Result        sync (WT_File & file) const;
00234     WT_Boolean       operator== (WT_Attribute const & attrib) const;
00236 
00238 
00240     static WT_Result default_process(
00241         WT_Attribute_URL & item, 
00242         WT_File & file 
00243         );
00244 };
00245 
00247 
00248 #endif // URL_HEADER

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