1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00
OpenMW/components/esm/esm_writer.cpp

66 lines
1.1 KiB
C++
Raw Normal View History

#include "esm_writer.hpp"
namespace ESM
{
2012-04-06 22:25:33 +02:00
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);
writeHString(data);
}
void ESMWriter::writeHString(const std::string& data)
{
writeT<int>(data.size()-1);
write(data.c_str(), data.size()-1);
}
void ESMWriter::writeName(const std::string& name)
{
2012-04-06 22:25:33 +02:00
assert((name.size() == 4 && name[3] != '\0') || (name.size() == 5 && name[4] == '\0'));
write(name.c_str(), name.size()-1);
}
void ESMWriter::write(const char* data, int size)
{
m_stream.write(data, size);
}
}