Fleshing out the esm writer a bit

This commit is contained in:
Alexander "Ace" Olofsson 2012-04-06 22:25:33 +02:00
parent b81ac363fc
commit 47013799ea
2 changed files with 50 additions and 1 deletions

View file

@ -3,6 +3,42 @@
namespace ESM namespace ESM
{ {
void ESMWriter::setVersion(Version ver)
{
m_header.version = ver;
}
void ESMWriter::setType(FileType type)
{
m_header.type = type;
}
void ESMWriter::setAuthor(const std::string& auth)
{
strcpy(auth.c_str(), m_header.author, 32);
}
void ESMWriter::setDescription(const std::string& desc)
{
strcpy(desc.c_str(), m_header.desc, 256);
}
void ESMWriter::save(const std::string& file)
{
std::ostream os(file, "wb");
save(os);
}
void ESMWriter::save(std::ostream& file)
{
// TODO: Saving
}
void ESMWriter::close()
{
// TODO: Saving
}
void ESMWriter::writeHNString(const std::string& name, const std::string& data) void ESMWriter::writeHNString(const std::string& name, const std::string& data)
{ {
writeName(name); writeName(name);
@ -17,7 +53,7 @@ void ESMWriter::writeHString(const std::string& data)
void ESMWriter::writeName(const std::string& name) void ESMWriter::writeName(const std::string& name)
{ {
assert((name.size() == 4 && name.c_str()[3] != '\0') || (name.size() == 5 && name.c_str()[4] == '\0')); assert((name.size() == 4 && name[3] != '\0') || (name.size() == 5 && name[4] == '\0'));
write(name.c_str(), name.size()-1); write(name.c_str(), name.size()-1);
} }

View file

@ -11,6 +11,16 @@ namespace ESM {
class ESMWriter class ESMWriter
{ {
public: public:
void setVersion(Version ver);
void setType(FileType type);
void setAuthor(const std::string& author);
void setDescription(const std::string& desc);
void save(const std::string& file);
void save(std::ostream& file);
void close();
void writeHNString(const std::string& name, const std::string& data); void writeHNString(const std::string& name, const std::string& data);
void writeHNOString(const std::string& name, const std::string& data) void writeHNOString(const std::string& name, const std::string& data)
{ {
@ -65,6 +75,9 @@ public:
private: private:
std::ostream m_stream; std::ostream m_stream;
HEDRstruct m_header;
SaveData m_saveData;
}; };
} }