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

opcode.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 OPCODE_HEADER
00019 #define OPCODE_HEADER
00020 
00021 #include "whiptk/whipcore.h"
00022 #include "whiptk/object.h"
00023 
00024 class WT_Rendition;
00025 
00027 class WHIPTK_API WT_Opcode
00028 {
00029 public:
00031     enum WT_Type
00032     {
00033         Single_Byte,
00034         Extended_ASCII,
00035         Extended_Binary,
00036         Unary_Optioncode,
00037         Null_Optioncode
00038     };
00039 private:
00040     enum WT_Status
00041     {
00042         Starting,
00043         Finished,
00044         Eating_Whitespace,
00045         Determining_Opcode_Type,
00046         Accumulating_Extended_Opcode
00047     };
00048 
00049     int            m_size;
00050     WT_Byte        m_token[WD_MAX_OPCODE_TOKEN_SIZE + 2];
00051     WT_Type        m_type;
00052     WT_Status      m_status;
00053 
00054     int            m_prior_paren_level;
00055 
00056 public:
00058     WT_Opcode()
00059         :m_size (0)
00060         ,m_type (Single_Byte)
00061         ,m_status (Starting)
00062         ,m_prior_paren_level(0)
00063     { }
00065 
00067     virtual int matching_paren_level() const  {  return m_prior_paren_level; }
00069     virtual int size() const  { return m_size; }
00071     virtual WT_Byte const * token() const {  return &m_token[0]; }
00073     virtual WT_Type type() const { return m_type; }
00075 
00076     virtual WT_Result skip_past_matching_paren(WT_File & file) const;
00078 
00079     WT_Result      get_opcode(WT_File & file, WT_Boolean allow_sub_options = WD_False);
00081 
00084     WT_Object *    object_from_opcode(
00085         WT_Rendition & rend, 
00086         WT_Result & result, 
00087         WT_File & file 
00088         ) const;
00090     WT_Boolean     is_legal_opcode_character(WT_Byte byte) const;
00092     WT_Boolean     is_opcode_terminator(WT_Byte byte) const;
00093 };
00094 
00096 class WHIPTK_API WT_Optioncode : public WT_Opcode
00097 {
00098 protected:
00099 
00100     int m_option_id; 
00102 public:
00103 
00105     WT_Optioncode()
00106         : m_option_id(-1)
00107     { }
00108 
00110 
00111     WT_Result get_optioncode(WT_File & file)
00112     {
00113         m_option_id = -1;                   // Get rid of any previous option's id
00114         return WT_Opcode::get_opcode(file, WD_True);
00115     }
00116 
00118     int option_id()
00119     {
00120         if (m_option_id == -1)
00121             m_option_id = option_id_from_optioncode();
00122         return m_option_id;
00123     }
00124 
00126     virtual int option_id_from_optioncode() = 0;
00127 };
00128 
00129 #endif // OPCODE_HEADER

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