Vault  4.1
Public Member Functions
VFileWriter Class Reference

This class simplifies using the VFSNode::safelyOverwriteFile() API, by relieving you of the need to manually create a temporary buffer stream, etc. More...

#include <vfilewriter.h>

List of all members.

Public Member Functions

 VFileWriter (const VFSNode &target)
 Creates the helper objects, pointing to a specific file node.
VTextIOStreamgetTextOutputStream ()
VBinaryIOStreamgetBinaryOutputStream ()
void save ()

Detailed Description

This class simplifies using the VFSNode::safelyOverwriteFile() API, by relieving you of the need to manually create a temporary buffer stream, etc.

You just instantiate the VFileWriter with the target file node, then write to either a text or binary stream obtained by one of the getter APIs, and finally 'save' the data. The reason for the explicit save call is so that nothing is written if an exception is thrown during your serialization, unless you want to catch it and still write whatever data you did put in the output stream (perhaps after first manipulating the stream further). Normally you want such exceptions to propagate up and avoid writing entirely.

This initial version always does your writes to a VMemoryStream and then uses that with the VFSNode::safelyOverwriteFile() API. It would be good to enhance this with an option (or default behavior) that actually writes to a temporary file directly, and then swaps it the way that VFSNode::safelyOverwriteFile() does with the buffered data.

So it can look like this,if you had text data for example:

void Thing::saveMyData() { VFileWriter writer(mMyFileNode); mMyData.writeToTextStream(writer.getTextOutputStream()); writer.save(); }

Definition at line 41 of file vfilewriter.h.


Constructor & Destructor Documentation

VFileWriter::VFileWriter ( const VFSNode target)

Creates the helper objects, pointing to a specific file node.

Parameters:
targetthe file node that will be written to

Definition at line 13 of file vfilewriter.cpp.


The documentation for this class was generated from the following files:

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.