write TES3 header

This commit is contained in:
Marc Zinnschlag 2013-09-15 15:31:44 +02:00
parent 1ee228a566
commit db70095148
3 changed files with 45 additions and 0 deletions

View file

@ -10,6 +10,9 @@ CSMDoc::Saving::Saving (Document& document)
{
appendStage (new OpenSaveStage (mDocument, mState));
appendStage (new WriteHeaderStage (mDocument, mState));
appendStage (new CloseSaveStage (mState));

View file

@ -30,6 +30,32 @@ void CSMDoc::OpenSaveStage::perform (int stage, std::vector<std::string>& messag
}
CSMDoc::WriteHeaderStage::WriteHeaderStage (Document& document, SavingState& state)
: mDocument (document), mState (state)
{}
int CSMDoc::WriteHeaderStage::setup()
{
return 1;
}
void CSMDoc::WriteHeaderStage::perform (int stage, std::vector<std::string>& messages)
{
mState.getWriter().setVersion();
mState.getWriter().setFormat (0);
/// \todo fill in missing header information
mState.getWriter().setAuthor ("");
mState.getWriter().setDescription ("");
mState.getWriter().setRecordCount (0);
/// \todo fill in dependency list
mState.getWriter().save (mState.getStream());
}
CSMDoc::CloseSaveStage::CloseSaveStage (SavingState& state)
: mState (state)
{}

View file

@ -24,6 +24,22 @@ namespace CSMDoc
///< Messages resulting from this stage will be appended to \a messages.
};
class WriteHeaderStage : public Stage
{
Document& mDocument;
SavingState& mState;
public:
WriteHeaderStage (Document& document, SavingState& state);
virtual int setup();
///< \return number of steps
virtual void perform (int stage, std::vector<std::string>& messages);
///< Messages resulting from this stage will be appended to \a messages.
};
class CloseSaveStage : public Stage
{
SavingState& mState;