opcode.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 
00022 
00023 #if !defined OPCODE_HEADER
00024 #define OPCODE_HEADER
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/object.h"
00028 
00029 class WT_Rendition;
00030 
00032 class WHIPTK_API WT_Opcode
00033 {
00034         friend class WT_Font_Option_Style;
00035         friend class WT_Pen_Pattern;
00036         friend class WT_File;
00037         friend class WT_Image;
00038         friend class WT_PNG_Group4_Image;
00039         friend class WT_Viewport;
00040         friend class WT_SignData;
00041         friend class WT_Object_Stream;
00042         friend class WT_Guid_List;
00043         friend class WT_Directory;
00044         friend class WT_BlockRef;
00045         friend class WT_W2D_Class_Factory;
00046 
00047 public:
00049     enum WT_Type
00050     {
00051         Single_Byte,
00052         Extended_ASCII,
00053         Extended_Binary,
00054         Unary_Optioncode,
00055         Null_Optioncode
00056     };
00057 private:
00058     enum WT_Status
00059     {
00060         Starting,
00061         Finished,
00062         Eating_Whitespace,
00063         Determining_Opcode_Type,
00064         Accumulating_Extended_Opcode
00065     };
00066 
00067     int            m_size;
00068     WT_Byte        m_token[WD_MAX_OPCODE_TOKEN_SIZE + 2];
00069     WT_Type        m_type;
00070     WT_Status      m_status;
00071 
00072     int            m_prior_paren_level;
00073 
00074 public:
00076     WT_Opcode()
00077         :m_size (0)
00078         ,m_type (Single_Byte)
00079         ,m_status (Starting)
00080         ,m_prior_paren_level(0)
00081     { }
00083 
00084     virtual ~WT_Opcode()
00085     { }
00086 
00087         virtual WT_Result        serialize (WT_File & /*file*/) const
00088         {
00089                 return WT_Result::Success;
00090         }
00091 
00093     virtual int matching_paren_level() const  {  return m_prior_paren_level; }
00095     virtual int size() const  { return m_size; }
00097     virtual WT_Byte const * token() const {  return &m_token[0]; }
00098         void    set_token(const char cToken);
00100     virtual WT_Type type() const { return m_type; }
00102 
00103     virtual WT_Result skip_past_matching_paren(WT_File & file) const;
00105 
00106     WT_Result      get_opcode(WT_File & file, WT_Boolean allow_sub_options = WD_False);
00108 
00111     WT_Object *    object_from_opcode(
00112         WT_Rendition & rend, 
00113         WT_Result & result, 
00114         WT_File & file 
00115         ) const;
00117     WT_Boolean     is_legal_opcode_character(WT_Byte byte) const;
00119     WT_Boolean     is_opcode_terminator(WT_Byte byte) const;
00120 };
00121 
00123 class WHIPTK_API WT_Optioncode : public WT_Opcode
00124 {
00125 protected:
00126 
00127     int m_option_id; 
00129 public:
00130 
00132     WT_Optioncode()
00133         : m_option_id(-1)
00134     { }
00135 
00137 
00138     WT_Result get_optioncode(WT_File & file)
00139     {
00140         m_option_id = -1;                   // Get rid of any previous option's id
00141         return WT_Opcode::get_opcode(file, WD_True);
00142     }
00143 
00145     int option_id()
00146     {
00147         if (m_option_id == -1)
00148             m_option_id = option_id_from_optioncode();
00149         return m_option_id;
00150     }
00151 
00153     virtual int option_id_from_optioncode() = 0;
00154 };
00155 
00156 #endif // OPCODE_HEADER

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