请教各位大侠:如何把返回的抽象类指针实例化啊?(0分)

  • 主题发起人 主题发起人 thomastangmin
  • 开始时间 开始时间
T

thomastangmin

Unregistered / Unconfirmed
GUEST, unregistred user!
//class WT_File;
class WT_Opcode;
/// Base class for all WHIP! objects and attributes that can be serialized to or materialized from a file.
class WHIPTK_API WT_Object
{
public:
/// Object ID. Allows object class identification without having RTTI enabled.
enum WT_ID
{
Unknown_ID
,Adapt_Line_Patterns_ID
,Author_ID
,Background_ID
,Code_Page_ID
,Color_ID
,Color_Map_ID
,Comments_ID
,Compressed_Data_Moniker_ID
,Contour_Set_ID
,Copyright_ID
,Creator_ID
,Creation_Time_ID
,Dash_Pattern_ID
,Description_ID
,Drawing_Info_ID
,DWF_Header_ID
,Embed_ID
,Embedded_Font_ID
,End_Of_DWF_ID
,Fill_ID
,Fill_Pattern_ID
,Filled_Ellipse_ID
,Gouraud_Polyline_ID
,Gouraud_Polytriangle_ID
,Image_ID
,Inked_Area_ID
,Keywords_ID
,Layer_ID
,Layer_List_ID
,Line_Caps_ID
,Line_Join_ID
,Line_Pattern_ID
,Line_Style_ID
,Line_Pattern_Scale_ID
,Line_Weight_ID
,Marker_Size_ID
,Marker_Symbol_ID
,Merge_Control_ID
,Miter_Angle_ID
,Miter_Length_ID
,Modification_Time_ID
,Named_View_ID
,Named_View_List_ID
,Trusted_Font_List_ID
,Object_Node_ID
,Object_Node_List_ID
,Option_ID
,Origin_ID
,Outline_Ellipse_ID
,Plot_Info_ID
,Polygon_ID
,Polyline_ID
,Polymarker_ID
,Polytriangle_ID
,Projection_ID
,Source_Creation_Time_ID
,Source_Filename_ID
,Source_Modification_Time_ID
,Subject_ID
,Text_ID
,Title_ID
,Units_ID
,URL_ID
,URL_List_ID
,View_ID
,Viewport_ID
,Viewport_Option_Viewport_Units_ID
,Visibility_ID
,Font_ID
,Font_Option_Font_Name_ID
,Font_Option_Charset_ID
,Font_Option_Pitch_ID
,Font_Option_Family_ID
,Font_Option_Style_ID
,Font_Option_Height_ID
,Font_Option_Rotation_ID
,Font_Option_Width_Scale_ID
,Font_Option_Spacing_ID
,Font_Option_Oblique_ID
,Font_Option_Flags_ID
,Text_Option_Overscore_ID
,Text_Option_Underscore_ID
,Text_Option_Bounds_ID
,Text_Option_Reserved_ID
,PNG_Group4_Image_ID
,Optimized_For_Plot_ID
,Group_begin
_ID
,Group_End_ID
,Block_Meaning_ID
,Encryption_ID
,Orientation_ID
,Alignment_ID
,Password_ID
,Guid_ID
,FileTime_ID
,BlockRef_ID
,Directory_ID
,UserData_ID
,Pen_Pattern_ID
,SignData_ID
,Guid_List_ID
,Font_Extension_ID
,PenPat_Options_ID
};
/// General type of an object.
enum WT_Type
{
Unknown
,Attribute
,Drawable
,Definition
,Compression
,Comment
,Wrapper
,Option
,Informational
};
protected:
WT_Boolean m_materialized;
/**< /brief WD_True if the instance has been materialized from a WT_File. */
public:
/// Constructs a WT_Object object.
WT_Object ()
: m_materialized(WD_False)
{ }
/// Destroys a WT_Object object.
virtual ~WT_Object ()
{ }
/// Returns the WT_Type for this object.
virtual WT_Type object_type() const = 0;
/// Returns the WT_ID for this object.
virtual WT_ID object_id() const = 0;
/// Materializes the contents of the object from the file and the given opcode.
/** Reads in the object data and causes the file reading to proceed to the end of this object.
* /warning This is used by the framework and should not be called by client code.
* /retval WT_Result::Success The operation was successful.
* /retval WT_Result::Opcode_Not_Valid_For_This_Object The objectdo
es not support the opcode type.
* /retval WT_Result::Internal_Error Something went very wrong.
*/
virtual WT_Result materialize(
WT_Opcode const & opcode, /**< The opcode which corresponds to the object. */
WT_File & file /**< The file being read. */
) = 0;
/// Calls the configured action handler for this object (passes in the file reference.)
/** /warning This is used by the framework and should not be called by client code.
*/
virtual WT_Result process(WT_File & file) = 0;
/// Causes the serialization of the object to the file.
/** If this is a WT_Drawable derived object, this method may cause the object to be
* delayed (in case a coincident like-object follows) and/or merged (in case a coincident
* like-object preceeded) so as to optimize the output.
*
* /retval WT_Result::Success The operation was successful.
*/
virtual WT_Result serialize (
WT_File & file /**< The file being written. */
) const = 0;
/// Causes the file reading to proceed to the end of this object.
/** /warning This is used by the framework and should not be called by client code.
* /bug Not all objects perform skip_operand() correctly;
this is a known problem.
* For best results, if client code must use WT_File::get_next_object_shell() manually,
* it should also call the corresponding WT_Object::materialize() method to avoid this
* problem.
* /sa WT_File::get_next_object_shell(), WT_File_Heuristics::set_deferred_delete().
*/
virtual WT_Result skip_operand(WT_Opcode const & opcode, WT_File & file);
/// Returns WD_True if the instance has been materialized from a WT_File. */
WT_Boolean materialized() const
{
return m_materialized;
}
};

class WHIPTK_API WT_File
{
public:
/// The mode used for reading or writing.
enum WT_File_mode
{
File_Inactive, /**< /brief Default mode - nothing can bedo
ne with the file in this mode. */
File_Read, /**< /brief Open file for writing. */
File_Write, /**< /brief Open file for writing. */
Block_Write, /**< /brief /deprecated Block writing is only available for classic %DWF files of version 00.55. */
Block_Read, /**< /brief /deprecated Block reading is only available for classic %DWF files of version 00.55. */
Block_Append /**< /brief /deprecated Block appending is only available for classic %DWF files of version 00.55. */
};
//@{ /name Construction / destruction.
/// Constructs a WT_File object.
WT_File();
/// Destroys a WT_File object.
~WT_File();
//@}
//@{ /name I/O startup / shutdown / status methods
/// Close the file.
WT_Result close();
/// Returns the file mode with which the file was opened (one of /ref WT_File_mode "enum WT_File_mode".)
WT_File_mode file_mode() const;
/// Returns the filename that was opened.
WT_String const & filename() const;
/// Returns an accessor to the WT_File_Heuristics object for this file.
WT_File_Heuristics & heuristics() { return m_heuristics;
}
/// Open the file based on the filename, file mode, and heuristics, which should be configured prior to calling open().
/** /retval WT_Result::Success The operation was successful.
* /retval WT_Result::Out_Of_Memory_Error An internal object could not be created.
*/
WT_Result open();
/// Sets the file mode to be used for opening the file.
void set_file_mode(WT_File_mode mode);
/// Sets the filename which is to be opened.
void set_filename(char const * name);
/// Sets the filename which is to be opened.
void set_filename(int length, WT_Unsigned_Integer16 const * name);
/// Sets the filename which is to be opened.
void set_filename(WT_Unsigned_Integer16 const * name);
/// Returns the decimal revision of the toolkit.
/** The version is calculated as follows: (major_version * 100) + minor_version.
* For example, if the toolkit is version 00.55, the decimal revision is 55;
* for version 06.00, the decimal revision is 600.
*/
int toolkit_decimal_revision() const { return (toolkit_major_revision() * 100) + toolkit_minor_revision();
}
/// Returns the major revision of the toolkit.
/** For example, if the toolkit is version 06.00, the major revision is 6.
*/
int toolkit_major_revision() const { return WD_Toolkit_Major_Revision;
}
/// Returns the minor revision of the toolkit.
/** For example, if the toolkit is version 06.00, the minor revision is 0.
*/
int toolkit_minor_revision() const { return WD_Toolkit_Minor_Revision;
}
//@}
//@{ /name Data access methods
/// Used when a file is opened for reading to return a read-only accessor to the current object set in get_next_object() -/> get_next_object_shell()
WT_Object const * current_object() const { return m_current_object;}
/// Returns a writable reference to the local WT_Dash_Pattern_List object for this file (contains the set of WT_Dash_Pattern objects for this file.)
WT_Dash_Pattern_List & dash_pattern_list() { return m_dpat_list;
}
/// Returns the write-mode optimizing WT_Rendition object for this file.
/** /warning Clients should use this when setting rendition attributes and should
* /b never use this during read operations (use rendition() when reading.)
* /sa /ref groupRenditionAttributes "Rendition attributes"
*/
WT_Rendition & desired_rendition() {return m_desired_rendition;}
/// Returns a writable reference to the local WT_Layer_List object for this file (contains the set of WT_Layer objects for this file.)
WT_Layer_List & layer_list() { return m_layer_list;
}
/// Returns the read-mode current WT_Rendition object for this file.
/** /warning Clients should use this during read operations when reading the current /ref groupRenditionAttributes "rendition attributes",
* but should /b never use this during write operations (use desired_rendition() when writing.)
*/
WT_Rendition & rendition() { return *m_rendition;
}
/// Used when a file is opened for reading to return an accessor to the current object set in get_next_object() -/> get_next_object_shell()
WT_Object * object() { return m_current_object;
}
/// Returns a writable reference to the local WT_Object_Node_List object for this file (contains the set of WT_Object_Node objects for this file.)
WT_Object_Node_List & object_node_list() { return m_object_node_list;
}
/// Sets a pointer to store a user-defined data item.
/** /warning When the default stream action handlers are used, this is used internally to
* store the FILE pointer used to read/write the file. Users wishing to store a custom
* pointer and still use the default stream action handlers can use the WT_Heuristics::set_user_data() method.
*/
void set_stream_user_data(void * stream_user_data) { m_stream_user_data = stream_user_data;
}
/// Retrieves the pointer to a user-defined data item.
void * stream_user_data() { return m_stream_user_data;
}
//@}
//@{ /name Reader state machine methods
/// Reads the next object from the file stream (butdo
es not process it.)
/** This calls get_next_object_shell() then
WT_Object::materialize() to fully
* create and populate the object contents from the file. The file pointer is
* moved to the next object/opcode.
*
* /retval WT_Result::Success The operation was successful.
*/
WT_Result get_next_object();
/// Reads the next object opcode and determines the object type, creates an empty (default) object.
/** This methoddo
es not move the file pointer beyond the opcode of the object. If the object
* is not materialized through a call to the WT_Object::materialize() method (typically by the
* framework,) then
upon retriving the /b next object shell, the current object is skipped through
* a call to WT_Object::skip_operand().
* /warning Dangerous when used by client code and especially with deferred delete.
* /sa WT_Object::skip_operand(), WT_File_Heuristics::set_deferred_delete().
*/
WT_Result get_next_object_shell();
/// Processes the next object.
/** This calls get_next_object(), and then
calls the object's processing handler if configured
* or the object's default_process() method.
*
* /retval WT_Result::Success The operation was successful.
*/
WT_Result process_next_object();
//@}
/** /name Object processing handler set methods
* Sets read-mode object processing handlers. If set, these are called when
* process_next_object() is called. Otherwise, the default_process() method
* of each object is called.
* @{
*/
#define CALLBACK_MACRO(class_name, class_lower) /
void set_##class_lower##_action(WT_##class_name##_Action action) /
{m_##class_lower##_action = action;}
CALLBACK_LIST
#undef CALLBACK_MACRO
//@}
/** /name Object processing handler get methods
* Gets the read-mode object processing handlers. If set, these are called when
* process_next_object() is called. Otherwise, the default_process() method
* of each object is called.
* @{
*/
#define CALLBACK_MACRO(class_name, class_lower) /
WT_##class_name##_Action class_lower##_action() /
{return m_##class_lower##_action;}
CALLBACK_LIST
#undef CALLBACK_MACRO
//@}
/** /name I/O customization set/get methods
* These methods allow client code to override how low-level file I/O works
* by allowing client code to selectively implement various I/O procedures.
* @{
*/
void set_stream_close_action(WT_Stream_Close_Action action) { m_stream_close_action = action;
}
void set_stream_end_seek_action(WT_Stream_End_Seek_Action action) { m_stream_end_seek_action = action;
}
void set_stream_open_action(WT_Stream_Open_Action action) { m_stream_open_action = action;
}
void set_stream_read_action(WT_Stream_Read_Action action) { m_stream_read_action = action;
}
void set_stream_seek_action(WT_Stream_Seek_Action action) { m_stream_seek_action = action;
}
void set_stream_tell_action(WT_Stream_Tell_Action action) { m_stream_tell_action = action;
}
void set_stream_write_action(WT_Stream_Write_Action action) { m_stream_write_action = action;
}
WT_Stream_Close_Action stream_close_action() { return m_stream_close_action;
}
WT_Stream_End_Seek_Action stream_end_seek_action() { return m_stream_end_seek_action;
}
WT_Stream_Open_Action stream_open_action() { return m_stream_open_action;
}
WT_Stream_Read_Action stream_read_action() { return m_stream_read_action;
}
WT_Stream_Seek_Action stream_seek_action() { return m_stream_seek_action;
}
WT_Stream_Tell_Action stream_tell_action(){ return m_stream_tell_action;
}
WT_Stream_Write_Action stream_write_action() { return m_stream_write_action;
}
//@}
/** /name BlockRef and Directory methods
* /deprecated These methods are available only for backward compatibility to allow client code
* to continue to write %DWF 00.55 files which contain WT_BlockRef objects.
* @{
*/
/// Adds a new WT_BlockRef object to the local WT_Directory.
WT_Result add_blockref(WT_BlockRef & blockref) { return m_directory.add(blockref);
}
/// Sets the /a bBinaryFileType to WD_True if the file is binary and sets /a end_byte_length to the length of the last opcode (EndOfDWF)
/** If the file mode is opened as Block_Append or Block_Read, this method will help in
* determining the file type (whether the file is in ascii or binary format).
*/
WT_Result is_file_type_binary(WT_Boolean & bBinaryFileType, int & end_byte_length);

/// Returns the local WT_Directory object for this file (contains the set of WT_BlockRef objects for this file.)
WT_Directory const get_directory() { return m_directory;
}
/// Moves the file pointer to the begin
ning of the directory for this file.
/** Available when a file is opened as Block_Append or Block_Read
*/
WT_Result get_to_the_directory();
//@}
// Wedo
n't want todo
cument the following methods. They're for internal use only,
// but public so that we are not force to make every object a friend.
#ifndefdo
XYGEN_IGNORE
// Internal Reader state machine stuff that's just plain dangerous to use.
WT_Result get_next_object(WT_File *p_uncompressed_file);
WT_Result process_next_object(WT_File *p_uncompressed_file);
// Internal reader / writer functions only used by WT_Object derivatives, not by client code.
WT_Result compress_write(int count, void const * data);
const WT_Opcode & current_opcode() const { return m_opcode;
}
int data_decompression() { return m_data_decompression;
}
WT_Result decompress_read(int count, int & num_read, void * data);
WT_Result decompress_seek(int count, int & num_seeked);
int decrement_paren_count() { return --m_paren_count;}
int decrement_tab_level() { return --m_tab_level;
}
WT_Logical_Point de_update_current_point(WT_Logical_Point const & delta);
WT_Drawable * delayed_drawable() const { return m_delayed_drawable;
}
WT_Result dump_delayed_drawable();
WT_Result eat_whitespace();
WT_File_Stats * file_stats() { return m_file_stats;
}
WT_Result handle_leftover_decompressor_stream_read_data(int avail_in, WT_Byte const * next_in);
WT_Boolean have_read_first_opcode() const { return m_have_read_first_opcode;
}
int increment_paren_count() { return ++m_paren_count;
}
int increment_tab_level() { return ++m_tab_level;
}
WT_Result merge_or_delay_drawable(WT_Drawable const & current);
int next_incarnation() { return m_next_incarnation++;
}
int paren_count() const { return m_paren_count;
}
WT_Result put_back(int size, WT_Byte const * buffer);
WT_Result put_back(WT_Byte const & a_byte) { return put_back(sizeof(WT_Byte), & a_byte);
}
WT_Result read(char * & string, int max_size, WT_Boolean allow_initial_open_paren = WD_False);
// Too big to
WT_Result read(int count, WT_Logical_Point * points);
WT_Result read(int count, WT_Logical_Point_16 * points);
WT_Result read(int count, WT_RGBA32 * colors);
WT_Result read(int count, WT_Unsigned_Integer16 * buffer);
WT_Result read(int size, char * buffer);
WT_Result read(int size, WT_Byte * buffer);
WT_Result read(WT_Byte & a_byte);
WT_Result read(WT_Integer16 & a_word);
WT_Result read(WT_Integer32 & a_word);
WT_Result read(WT_RGBA32 & a_color);
WT_Result read(WT_Unsigned_Integer16 & a_word);
WT_Result read(WT_Unsigned_Integer32 & a_word);
WT_Result read_ascii(double & a_word);
WT_Result read_ascii(int count, WT_RGBA32 * colors);
WT_Result read_ascii(WT_Color & a_color, WT_Boolean allow_indexed_color = WD_True);
WT_Result read_ascii(WT_Integer16 & a_word);
WT_Result read_ascii(WT_Integer32 & a_word);
WT_Result read_ascii(WT_Logical_Box & a_box);
WT_Result read_ascii(WT_Logical_Point & a_point);
WT_Result read_ascii(WT_RGBA32 & a_color);
WT_Result read_ascii(WT_Unsigned_Integer16 & a_word);
WT_Result read_ascii(WT_Unsigned_Integer32 & a_dword);
WT_Result read_block(WT_File & block_file, WT_BlockRef & blockref);
WT_Result read_count (WT_Integer32 & count);
WT_Result read_hex(int count, WT_Byte * data);
WT_Result read_hex(WT_Byte & byte);
WT_Result read_index_tree(int max_size, WT_Boolean allow_initial_open_paren = WD_False);
// Too big to
WT_Result set_block_size_for_tail_blockref(WT_Unsigned_Integer32 current_blockref_file_offset);
void set_data_decompression(int decompression) { m_data_decompression = decompression;
}
void set_delayed_drawable(WT_Drawable * drwbl) { WD_Assert(!m_delayed_drawable);
m_delayed_drawable = drwbl;
}
void set_directory(WT_Directory directory) { m_directory = directory;
} /* in the default_process of WT_Directory, we set the file directory member value to the directory that we might have materialized from the file opened in Block_Append, Block_Read or File_Read mode. */
void set_have_read_first_opcode(WT_Boolean state) { m_have_read_first_opcode = state;
}
void set_paren_count(int count) { m_paren_count = count;
}
void set_tab_level(int count) { m_tab_level = count;
}
WT_Result skip(int size);
WT_Unsigned_Integer16 skip_byte_length() const { return m_skip_byte_length;
}
WT_Result skip_past_matching_paren(int terminating_paren_level);
int tab_level() const { return m_tab_level;
}
int this_opcode_start_position() const { return m_this_opcode_start_position;
}
WT_Logical_Point update_current_point(WT_Logical_Point const & new_point);
WT_Result write(char const * str);
WT_Result write(int count, WT_Byte const * data);
WT_Result write(int count, WT_Logical_Point const * points);
WT_Result write(int count, WT_Logical_Point_16 const * points);
WT_Result write(int count, WT_Unsigned_Integer16 const * data);
WT_Result write(WT_Byte a_byte);
WT_Result write(WT_Integer16 a_word);
WT_Result write(WT_Integer32 a_word);
WT_Result write(WT_RGBA32 a_color);
WT_Result write(WT_Unsigned_Integer16 a_word);
WT_Result write(WT_Unsigned_Integer32 a_dword);
WT_Result write_ascii(double val);
WT_Result write_ascii(int count, WT_Logical_Point const * points);
WT_Result write_ascii(WT_Integer16 a_word);
WT_Result write_ascii(WT_Integer32 a_word);
WT_Result write_ascii(WT_Logical_Point const & point);
WT_Result write_ascii(WT_RGBA32 a_color);
WT_Result write_ascii(WT_Unsigned_Integer16 a_word);
WT_Result write_ascii(WT_Unsigned_Integer32 a_dword);
WT_Result write_block(WT_File & file);
WT_Result write_count(int count);
WT_Result write_geom_tab_level();
WT_Result write_hex(int count, WT_Byte const * data);
WT_Result write_hex(WT_Byte data);
WT_Result write_padded_ascii(double a_double);
WT_Result write_padded_ascii(int count, WT_Logical_Point const * points);
WT_Result write_padded_ascii(WT_Integer16 a_word);
WT_Result write_padded_ascii(WT_Integer32 a_word);
WT_Result write_padded_ascii(WT_Logical_Point const & point);
WT_Result write_padded_ascii(WT_Unsigned_Integer16 a_word);
WT_Result write_padded_ascii(WT_Unsigned_Integer32 a_word);
WT_Result write_quoted_string(char const * str, WT_Boolean force_quotes = WD_False);
WT_Result write_quoted_string(WT_Unsigned_Integer16 const * str);
WT_Result write_tab_level();
#endif
protected:
/// Holds a pointer to a user-defined data item.
void * m_stream_user_data;
/** /name Reader processing handler properties
* If set, these are called when process_next_object() is called.
* Otherwise, the default_process() method of each object is called.
* @{
*/
#define CALLBACK_MACRO(class_name, class_lower) /
WT_##class_name##_Action m_##class_lower##_action;
CALLBACK_LIST
#undef CALLBACK_MACRO
//@}
//@{ /name I/O customization propreties
WT_Stream_End_Seek_Action m_stored_stream_end_seek_action;
WT_Stream_Read_Action m_stored_stream_read_action;
WT_Stream_Seek_Action m_stored_stream_seek_action;
WT_Stream_Close_Action m_stream_close_action;
WT_Stream_End_Seek_Action m_stream_end_seek_action;
WT_Stream_Open_Action m_stream_open_action;
WT_Stream_Read_Action m_stream_read_action;
WT_Stream_Seek_Action m_stream_seek_action;
WT_Stream_Tell_Action m_stream_tell_action;
WT_Stream_Write_Action m_stream_write_action;
//@}
// Default I/O and decompression methods,do
cument readersdo
n't need to know about these
#ifndefdo
XYGEN_IGNORE
static WT_Result default_close (WT_File & file);
static WT_Result default_end_seek (WT_File & file);
static WT_Result default_open (WT_File & file);
static WT_Result default_read (WT_File & file, int desired_bytes, int & bytes_read, void * buffer);
static WT_Result default_seek (WT_File & file, int distance, int & amount_seeked);
static WT_Result default_tell (WT_File & file, unsigned long *current_file_pointer_position);
static WT_Result default_write(WT_File & file, int size, void const * buffer);
#endif
private:
WT_String m_filename;
WT_File_mode m_mode;
WT_File_Heuristics m_heuristics;
WT_Rendition m_desired_rendition;
WT_Rendition * m_rendition;

WT_Opcode m_opcode;
WT_Object * m_current_object;
WT_Layer_List m_layer_list;
WT_Object_Node_List m_object_node_list;
WT_Dash_Pattern_List m_dpat_list;

WT_Boolean m_have_read_first_opcode;
WT_Logical_Point m_current_point;
int m_next_incarnation;
int m_actual_file_position;
int m_paren_count;
int m_tab_level;
WT_FIFO<WT_Byte> m_read_fifo;
WT_Byte m_quote;
WT_Boolean m_processing_quoted_string;
WT_Boolean m_processing_escaped_literal;
WT_FIFO<WT_Byte> m_string_accumulator;
WT_Compressor * m_compressor;
WT_DeCompressor * m_decompressor;
int m_data_decompression;
WT_FIFO<WT_Byte> m_decomp_leftover_data_buffer;
WT_Drawable * m_delayed_drawable;
WT_Boolean m_currently_dumping_delayed_drawable;
int m_current_file_position;
int m_this_opcode_start_position;
int m_number_of_opcodes_read;
WT_File_Stats * m_file_stats;
// Persistant scratch values in case we run out of data
WT_Integer32 m_read_colors_state;
WT_Integer32 m_read_ascii_value;
int m_read_ascii_sign;
do
uble m_read_ascii_double_value;
do
uble m_read_ascii_double_sign;
do
uble m_read_ascii_double_divisor;
WT_Logical_Point m_read_ascii_logical_point_value;
WT_Integer32 m_temp_index;
WT_RGBA32 m_temp_rgba;
WT_Logical_Box m_temp_box;
WT_Directory m_directory;
//As we skip unknown extended ascii opcodes (possibly because, those opcodes
//were added as part of a subsequent whip toolkit releases), we just accumulate
//the unknown opcode's field length so that we can seek back and read them
//when unknown opcode materializes as part of WT_Unknown::materialize.
WT_Unsigned_Integer16 m_skip_byte_length;
enum
{
Getting_Count_Byte,
Getting_Extended_Count_Short
} m_read_count_state;
enum
{
Eating_Initial_Whitespace,
Getting_Sign,
Eating_Post_Sign_Whitespace,
Getting_First_Digit,
Accumulating_Subsequent_Digits,
Accumulating_Fractional_Digits,
Accumulating_Exponent
} m_read_ascii_integer32_state,
m_read_ascii_double_state;
enum
{
Getting_X_Coordinate,
Getting_Comma,
Getting_Y_Coordinate
} m_read_ascii_logical_point_state;
enum
{
Getting_Min_Point,
Eating_Middle_Whitespace,
Getting_Max_Point,
} m_read_ascii_logical_box_state;
enum
{
Getting_First_Value,
Getting_Separator,
Getting_Green,
Getting_Green_Comma,
Getting_Blue,
Getting_Blue_Comma,
Getting_Alpha
} m_read_ascii_color_state;
int m_read_hex_multiple_state;
enum
{
Eating_Whitespace,
Getting_Hex_Value
} m_read_hex_state;

WT_Result shut_down_decompression();

private:
static WT_Result temporary_decomp_leftover_end_seek (WT_File & file);
static WT_Result temporary_decomp_leftover_read (WT_File & file, int desired_bytes, int & bytes_read, void * buffer);
static WT_Result temporary_decomp_leftover_seek (WT_File & file, int desired_bytes, int & bytes_seeked);
WT_Result write_uncompressed_tab_level(void);
WT_Result write_uncompressed (char const * str);
WT_Result write_uncompressed (WT_Byte a_byte);
/*
Parent application would typically open a dwf file in Block_Append or
Block_Read mode to append new blocks at the end and update the
directory info. Read_Write mode of opening dwf file feature was
primarily added for server side programming (non-streaming users). In
such a scenario, initialize_open_for_read_write_mode function will set
the file heuristics format type to either binary or ascii and read
through the directory information and set the file pointer position to
the begin
ing file offset of the existing directory opcode information.
So, a subseqeunt change in rendition blockref would signal addition of
new block at the end with new drawables following it. Whip toolkit
will finally take care of rewriting the updated directory information.
Also, when opened in Block_Append mode, we read through the existing
dwf data to make sure that we have the right rendition attribute
data set before we start appending new information. Also, to properly
transform the appended block information in to relativized dwf data,
we need to read through existing information. Wedo
n't have todo

this for Block_Read mode.
*/
WT_Result initialize_open_for_block_read_mode();
WT_Result initialize_open_for_block_append_mode();
/*Since the block size for a already serialized block is not decided
up until the next blockref gets serialized (as mentioned above in the
comments for set_block_size_for_tail_blockref function), we wait till
the file close time (when the block size for all blocks is pretty much
decided) and seek back to the blockref serialized instances and
re-serialize them with the updated block size information. */
WT_Result rewrite_blockref_instance(WT_BlockRef *blockref);
/*rewrite_blockref_instance function updates an (one) already serialized
blockref instance (which is not part of the directory instance).
rewrite_block_sizes_for_all_blockrefs loops through anddo
es the rewriting
business for all of the previously serialized blockref instances.*/
WT_Result rewrite_block_sizes_for_all_blockrefs();
};

WT_File whip_file;
do {
result = whip_file.process_next_object();
//在这里添加实现代码
//调用whip_file.current_object()
} while (result == WT_Result::Success);
这里最后的部分是实例程序,原程序只是说可以用whip_file.current_object()来处理当前对象,可是whip_file.current_object()实际是WT_Object const * current_object() const { return m_current_object;},而WT_Object 又是个抽象类,所以小弟就茫然了哦!
说明:程序其他地方还有30多个类是继承WT_Object 来的!
请教各位大侠:如何把返回的抽象类指针实例化啊?
 
强制类型转换
 
它用的是const来限制了的,怎么转换呢?
能举个简单的例子吗?
 
// TestClass010.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
class BaseClass
{
public:
BaseClass();
virtual ~BaseClass();
virtual char GetCC() const = 0;
};
class ABaseClass
{
public:
ABaseClass();
virtual ~ABaseClass();
char GetCC()
{
return 'C';
}
};
class OtherClass
{
public:
OtherClass();
virtual ~OtherClass();
BaseClass const * current_object() const
{
return m_current_object;
}
private:
BaseClass * m_current_object;
};
int main(int argc, char* argv[])
{
//OtherClass cc;
//cout<<cc.current_object()->GetCC()<<endl;
//怎么在这里添加上行的处理
return 0;
}
 
int main(int argc, char* argv[])
{
//OtherClass cc;
//cout<<cc.current_object()->GetCC()<<endl;
//怎么在这里添加上行的处理
OtherClass cc;
ABaseClass *aa;
aa=dynamic_cast<ABaseClass*>(cc.current_object());
return 0;
}
 
error C2682:
cannot use dynamic_cast to convert from 'const class BaseClass *' to 'class ABaseClass *'
 
老兄,
编译器报这种错误呢!
 
const ABaseClass *aa;
aa=dynamic_cast<const ABaseClass* >(cc.current_object());
 
没有注意返回值的const修饰
 
就是啥
如果允许的话,我都修改核心代码算了!
可惜。。。
 
?
const修饰没有错呀,你又不需要改变它的值,只是用来取数据。
const ABaseClass *aa;
aa=dynamic_cast<const ABaseClass* >(cc.current_object());
aa->GetCC();
有问题吗?
 
老兄,
编译器报这种错误呢!
error C2682:
cannot use dynamic_cast to convert from 'const class BaseClass *' to 'class ABaseClass *'
 
后退
顶部