Fleshing out the esm writer a bit

actorid
Alexander "Ace" Olofsson 13 years ago
parent b81ac363fc
commit 47013799ea

@ -3,6 +3,42 @@
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)
{
writeName(name);
@ -17,7 +53,7 @@ void ESMWriter::writeHString(const std::string& data)
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);
}

@ -11,6 +11,16 @@ namespace ESM {
class ESMWriter
{
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 writeHNOString(const std::string& name, const std::string& data)
{
@ -65,6 +75,9 @@ public:
private:
std::ostream m_stream;
HEDRstruct m_header;
SaveData m_saveData;
};
}

Loading…
Cancel
Save