timestamp.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 TIMESTAMP_HEADER
00020 #define TIMESTAMP_HEADER
00021 
00025 
00026 #include "whiptk/whipcore.h"
00027 #include "whiptk/object.h"
00028 
00030 class WHIPTK_API WT_Timestamp : public WT_Object
00031 {
00032 protected:
00033 
00034     // Don't need to document this
00035     #ifndef DOXYGEN_IGNORE
00036     WT_String               m_string;
00037     WT_Integer32            m_seconds;
00038     WT_String               m_guid;
00039 
00040     enum WT_Materialize_Stage
00041     {
00042         Eating_Initial_Whitespace,
00043         Gathering_Seconds,
00044         Eating_Middle_Whitespace,
00045         Gathering_String,
00046         Eating_Next_Whitespace,
00047         Gathering_GUID,
00048         Eating_End_Whitespace
00049     } m_stage;
00050     #endif
00051 
00052 public:
00053 
00055 
00056     WT_Timestamp ()
00057         : m_seconds (0)
00058         , m_stage (Eating_Initial_Whitespace)
00059     {}
00060 
00062     WT_Timestamp(
00063         WT_Integer32 seconds, 
00064         char const * exAsciiOpcode 
00065         );
00066 
00068     WT_Timestamp(WT_Timestamp const & ts)
00069         : WT_Object()
00070         , m_seconds (ts.seconds())
00071         , m_stage (Eating_Initial_Whitespace)
00072     {
00073         set(ts.string());
00074     }
00075         virtual ~WT_Timestamp()
00076         {}
00078 
00080 
00081     WT_String const & string(void) const {   return m_string;    }
00082 
00084     WT_Integer32 seconds(void) const    {   return m_seconds;   }
00085 
00087     WT_String const & guid(void) const {   return m_guid;      }
00088 
00090     void       set(char const * exAsciiOpcode);
00092     void       set(WT_String const & exAsciiOpcode);
00094     void       set(WT_Unsigned_Integer16 const * exAsciiOpcode);
00096     void       set(
00097         WT_Integer32 seconds, 
00098         char const * exAsciiOpcode 
00099         );
00101     void       set(
00102         WT_Integer32 seconds, 
00103         WT_String const & string 
00104         );
00106     void       set(
00107         WT_Integer32 seconds, 
00108         WT_Unsigned_Integer16 const * string 
00109         );
00111     void       set(WT_Timestamp const & ts);
00113     void       set_guid(WT_String const & guid);
00114 
00116     WT_Timestamp const & operator=(WT_Timestamp const & ts)
00117     {
00118         set(ts);
00119         return *this;
00120     }
00122 
00124     WT_Result    materialize(WT_Opcode const & opcode, WT_File & file);
00125     WT_Type      object_type() const;
00126     WT_Result    skip_operand(WT_Opcode const & opcode, WT_File & file);
00128 
00130 
00131     WT_Result    serialize(
00132         WT_File & file, 
00133         char const * exAsciiOpcode 
00134         ) const;
00135 };
00136 
00137 
00138 #define DECLARE_TIMESTAMP_CLASS(class_name) \
00139     class WHIPTK_API WT_##class_name : public WT_Timestamp \
00140     { \
00141     public: \
00142  \
00143         WT_ID            object_id() const; \
00144         WT_Result        process(WT_File & file); \
00145         WT_Result        serialize(WT_File & file) const; \
00146   \
00147  \
00148         static WT_Result default_process(  WT_##class_name & item,  WT_File & file); \
00149     }                                                                                                  //
00150 
00151 #define IMPLEMENT_TIMESTAMP_CLASS_FUNCTIONS(class_name, class_lower, class_command)                        \
00152     WT_Object::WT_ID    WT_##class_name::object_id() const                                              \
00153         {return class_name##_ID;}                                                                       \
00154     WT_Result WT_##class_name::serialize(WT_File & file) const                                          \
00155         {return WT_Timestamp::serialize (file, class_command);}                                         \
00156     WT_Result WT_##class_name::process(WT_File & file)                                                  \
00157         {WD_Assert (file.class_lower##_action());                                                       \
00158             return (file.class_lower##_action())(*this, file);}                                         \
00159     WT_Result WT_##class_name::default_process(WT_##class_name & item, WT_File & file)                  \
00160         {                                                                                               \
00161             file.rendition().drawing_info().class_lower() = item;                                       \
00162             return WT_Result::Success;                                                                  \
00163         }                                                                   //
00164 
00166 
00171 DECLARE_TIMESTAMP_CLASS (Creation_Time);
00173 
00178 DECLARE_TIMESTAMP_CLASS (Modification_Time);
00180 
00185 DECLARE_TIMESTAMP_CLASS (Source_Creation_Time);
00187 
00192 DECLARE_TIMESTAMP_CLASS (Source_Modification_Time);
00193 
00194 #endif // TIMESTAMP_HEADER

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