AppSave Class Reference

#include <appio.h>

Class Description

See also
Class AppLoad, Class AppDataChunk, Class CharacterStrings.

Description:
This class is a general chunk-ifying code useful for writing hierarchical data structures to a linear stream, such as an AppData block.

All methods of this class are implemented by the system.

AppSave will write hierarchical chunks into a private buffer, enlarging it as needed. When completed, use the methods BufferPtr() and NBytesWritten() to get at this buffer. (AppSave will delete the buffer in its DeleteThis() method , so you need to copy the buffer to save the data.)

The chunk hierarchy should always have a single highest level chunk. Chunks can be nested to any depth.

A Chunk can contain either sub-chunks, or data, but not both.
Sample Code:
AppSave *asave = NewAppSave(1000);
asave->BeginChunk(MAIN_CHUNK);
asave->BeginChunk(CHUNK1);
// .. write data
asave->EndChunk();
asave->BeginChunk(CHUNK2);
// .. write data
asave->EndChunk();
asave->BeginChunk(CHUNK3);
// .. write data
asave->EndChunk();
asave->EndChunk(); // end MAIN_CHUNK
+ Inheritance diagram for AppSave:

Public Member Functions

virtual void DeleteThis ()=0
 
virtual BYTE * BufferPtr ()=0
 
virtual int NBytesWritten ()=0
 
virtual void BeginChunk (USHORT id)=0
 
virtual void EndChunk ()=0
 
virtual int CurChunkDepth ()=0
 
virtual IOResult Write (const void *buf, ULONG nbytes, ULONG *nwrit)=0
 
virtual IOResult WriteWString (const char *str)=0
 
virtual IOResult WriteWString (const wchar_t *str)=0
 
virtual IOResult WriteCString (const char *str)=0
 
virtual IOResult WriteCString (const wchar_t *str)=0
 
virtual UINT CodePage () const
 

Protected Member Functions

virtual ~AppSave ()
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Constructor & Destructor Documentation

virtual ~AppSave ( )
inlineprotectedvirtual
84 {}

Member Function Documentation

virtual void DeleteThis ( )
pure virtual
Remarks
This method deletes the AppSave instance.
virtual BYTE* BufferPtr ( )
pure virtual
Remarks
This method is used after saving to get a pointer to the buffer created.
virtual int NBytesWritten ( )
pure virtual
Remarks
This method returns the number of bytes that were written in the buffer.
virtual void BeginChunk ( USHORT  id)
pure virtual
Remarks
This method is used to begin a chunk. The ID passed need only be unique within the plug-ins data itself.
Parameters:
USHORT id

The id for the chunk.
virtual void EndChunk ( )
pure virtual
Remarks
This method is used to end a chunk, and back-patch the length.
virtual int CurChunkDepth ( )
pure virtual
Remarks
This method is used internally for checking balanced BeginChunk/EndChunk.
virtual IOResult Write ( const void buf,
ULONG  nbytes,
ULONG *  nwrit 
)
pure virtual
Remarks
This method writes a block of bytes.
Parameters:
const void *buf

The buffer to write.

ULONG nbytes

The number of bytes to write.

ULONG *nwrit

The number of bytes actually written.
Returns
IO_OK - The write was acceptable - no errors.

IO_ERROR - This is returned if an error occurred.
virtual IOResult WriteWString ( const char *  str)
pure virtual
Remarks
This method is used to write wide character strings.
Parameters:
const char *str

The string to write.
Returns
IO_OK - The write was acceptable - no errors.

IO_ERROR - This is returned if an error occurred.
virtual IOResult WriteWString ( const wchar_t *  str)
pure virtual
Remarks
This method is used to write wide character strings.
Parameters:
const wchar_t *str

The string to write.
Returns
IO_OK - The write was acceptable - no errors.

IO_ERROR - This is returned if an error occurred.
virtual IOResult WriteCString ( const char *  str)
pure virtual
Remarks
This method is used to write single byte character strings.
Parameters:
const char *str

The string to write.
Returns
IO_OK - The write was acceptable - no errors.

IO_ERROR - This is returned if an error occurred.
virtual IOResult WriteCString ( const wchar_t *  str)
pure virtual
Remarks
This method is used to write single byte character strings.
Parameters:
const wchar_t *str

The string to write.
Returns
IO_OK - The write was acceptable - no errors.

IO_ERROR - This is returned if an error occurred.
virtual UINT CodePage ( ) const
inlinevirtual
163 { return (MAX_RELEASE >= MAX_RELEASE_R15_ALPHA_UNICODE_UNICODE) ? CP_UTF8 : CP_ACP; }
#define MAX_RELEASE_R15_ALPHA_UNICODE_UNICODE
3ds Max R15 (2013) Alpha, Beta Unicode release id (SimCity Unicode branch, unicode build) ...
Definition: plugapi.h:116
#define MAX_RELEASE
Identifier of the current 3ds Max release.
Definition: plugapi.h:153