- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-07-2007 07:43 AM
// define a simple memory-based FileInterface class
class MemoryFile : public BinaryFile {
private:
char * name; // The name of the part.
char * data; // The pointer to the data.
size_t size; // The current size of the data block.
FilePosition position; // Current read/write position.
public:
MemoryFile( char * in_name = NULL )
: name(NULL), data(NULL), size(0), position(0) {
if( in_name != NULL ) // Copy the input name.
name = ACIS_STRDUP( in_name);
}
~MemoryFile() {
if( name != NULL )
ACIS_FREE( name); // Release the memory
if( data != NULL )
ACIS_FREE( data );
name = NULL; data = NULL; size = 0; position = 0;
}
size_t read( void *buffer, size_t length, logical swap ) {
if( size == 0 )
length = 0; // Nothing to read.
if( length > size - position ) // Do not read
length = size - position; // passed the end.
if( length ) {
memcpy( buffer, data + position, length );
position += length; // Update read position.
}
return length;
}
void write( const void *buffer, size_t length, logical swap ) {
if( size == 0 ) // Initial call, get some memory.
data = (char*) ACIS_MALLOC( size = 1024 );
if( length > size - position )
data = (char*) // We need more memory.
ACIS_SAFE_REALLOC( data, size, size *= 2 );
if( length ) {
memcpy( data + position, buffer, length );
position += length; // Update the write position.
}
}
FilePosition set_mark() { return position; }
FilePosition goto_mark( FilePosition file_pos ) {
if( file_pos == -1 || file_pos > size )
return position = size; // Set to end of data.
else
return position = file_pos;
}
};Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-07-2007 11:18 AM
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-08-2007 07:22 AM
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2007 06:59 AM
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-13-2007 02:06 PM
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-28-2007 02:34 PM
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-03-2007 01:01 AM
Best Regards,
Stacey
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
12-03-2007 12:04 PM
Hi Hari
ACIS always expects to write data in the native format of the current machine. (The ability to target other formats has long been deprecated.) The BinaryFile write method therefore does not have to take its logical swap argument into consideration. The read method on the other hand does have to. The need to swap is determined early on in the restore process, when the ACIS version information of the input data is evaluated. Subsequent calls to the read method then must swap the input data when the following three conditions are all true:
1) when the logical need_swap is true (or is_byte_swapping() returns true)
2) when the logical swap input argument is true
3) when the size_t length input argument is less than 9 bytes
This would look something like this:
if( swap && need_swap && length <= 8 ) {
// swap the input data
}
The simple memory based FileInterface example does not take cross-platform issues into consideration.
Hope this helps,
Jeff
Re: Cross-plat form issue with api_restor e_entity_l ist_file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-07-2008 09:46 AM

