informational.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 INFORMATIONAL_HEADER
00020 #define INFORMATIONAL_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/object.h"
00028 
00029 
00030 #define DECLARE_INFORMATIONAL_CLASS(class_name)\
00031     class WHIPTK_API WT_##class_name : public WT_Informational {\
00032     public: \
00033         WT_ID object_id() const;\
00034         WT_Type        object_type() const;\
00035         WT_Result      process(WT_File & file);\
00036         WT_Result      serialize(WT_File & file) const;\
00037  static WT_Result default_process(  WT_##class_name & item, WT_File & file );\
00038     };
00039 
00040 #define IMPLEMENT_INFORMATIONAL_CLASS_FUNCTIONS(class_name, class_lower, class_type, class_command)\
00041     WT_Object::WT_ID    WT_##class_name::object_id() const\
00042         {return class_name##_ID;}\
00043     WT_Object::WT_Type WT_##class_name::object_type() const\
00044         {return class_type;}\
00045     WT_Result WT_##class_name::serialize(WT_File & file) const\
00046         {return WT_Informational::serialize (file, class_command);}\
00047     WT_Result WT_##class_name::process(WT_File & file)\
00048         {WD_Assert (file.class_lower##_action());\
00049             return (file.class_lower##_action())(*this, file);}\
00050     WT_Result WT_##class_name::default_process(WT_##class_name & item, WT_File & file)\
00051         {   file.rendition().drawing_info().class_lower() = item;\
00052             preprocess_workarounds(item, file);\
00053             return WT_Result::Success;}
00054 
00055 
00064 
00065 
00070 class WHIPTK_API WT_Informational : public WT_Object
00071 {
00072 protected:
00073 
00074     WT_String m_string; 
00076 
00077     enum WT_Materialize_Stage
00078     {
00079         Eating_Initial_Whitespace,
00080         Gathering_String,
00081         Eating_End_Whitespace
00082     } m_stage;
00083 
00084 protected:
00086     static WT_Result preprocess_workarounds(WT_Object & item, WT_File & file);
00087 
00088 public:
00089 
00091     WT_Informational ()
00092         : m_stage (Eating_Initial_Whitespace)
00093     {}
00094 
00096     WT_Informational(char * string)
00097         : m_stage (Eating_Initial_Whitespace)
00098     {   set(string);    }
00099 
00101     WT_Informational(WT_Unsigned_Integer16 * string)
00102         : m_stage (Eating_Initial_Whitespace)
00103     {   set(string);    }
00104 
00106     WT_Informational(WT_Informational const & info)
00107         : WT_Object()
00108         , m_stage (Eating_Initial_Whitespace)
00109     {
00110         set(info.string());
00111     }
00112         virtual ~WT_Informational()
00113         {}
00114 public:
00116     virtual WT_Type    object_type() const { return Informational; }
00117     virtual WT_ID            object_id() const { return Unknown_ID; }
00118     virtual WT_Result        process(WT_File & /*file*/) { return WT_Result::Success; }
00119     virtual WT_Result        serialize (WT_File & /*file*/) const { return WT_Result::Success; }
00120     virtual WT_Result            materialize(WT_Opcode const & opcode, WT_File & file);
00122     virtual WT_Result            serialize(WT_File & file, char const * name) const;
00123     virtual WT_Result            skip_operand(WT_Opcode const & opcode, WT_File & file);
00125 
00127 
00128     void                set(char const * info);
00130     void                set(WT_Unsigned_Integer16 const * info);
00132     void                set(int length, WT_Unsigned_Integer16 const * info);
00134     void                set(WT_String const & info);
00136     WT_String const &   string(void) const
00137     {   return m_string;    }
00139     WT_Informational const & operator=(WT_Informational const & info)
00140     {
00141         set(info.string());
00142         return *this;
00143     }
00145     WT_Informational const & operator=(char * info)
00146     {
00147         set(info);
00148         return *this;
00149     }
00151 };
00152 
00154  \
00155 DECLARE_INFORMATIONAL_CLASS (Author)
00157  \
00158 DECLARE_INFORMATIONAL_CLASS (Comments)
00160  \
00161 DECLARE_INFORMATIONAL_CLASS (Copyright)
00163  \
00164 DECLARE_INFORMATIONAL_CLASS (Creator)
00166  \
00167 DECLARE_INFORMATIONAL_CLASS (Description)
00169  \
00170 DECLARE_INFORMATIONAL_CLASS (Keywords)
00172  \
00173 DECLARE_INFORMATIONAL_CLASS (Title)
00175  \
00176 DECLARE_INFORMATIONAL_CLASS (Subject)
00178  \
00179 DECLARE_INFORMATIONAL_CLASS (Source_Filename)
00180 
00181 
00182 
00183 #endif // INFORMATIONAL_HEADER

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