#include <fstream>
#include <vector>
#include <assert.h>
+#include <stdarg.h>
namespace meshio {
namespace binary {
void readAll(const wchar_t *path, std::vector<char> &all);
#endif
+/**
+ * \83f\81[\83^\8f\91\82«\8d\9e\82Ý\83C\83\93\83^\81[\83t\83F\81[\83X
+ */
+class IWriter
+{
+public:
+ virtual ~IWriter(){}
+ virtual void write(const char *buf, unsigned int size)=0;
+ void printLn(const char *fmt, ...)
+ {
+ char buf[1024];
+ va_list list;
+ va_start(list, fmt);
+ vsprintf(buf, fmt, list);
+ write(buf, strlen(buf));
+ write("\r\n", 2);
+ va_end(list);
+ }
+ template<typename T>
+ void writeArray(const T *array, size_t element_count)
+ {
+ write(
+ reinterpret_cast<const char*>(array),
+ sizeof(T)*element_count);
+ }
+ template<typename T>
+ void writeValue(T value)
+ {
+ writeArray(&value, 1);
+ }
+};
+
+class FileWriter : public IWriter
+{
+ FILE *io_;
+
+public:
+ FileWriter(const char *path);
+ FileWriter(const wchar_t *path);
+ virtual ~FileWriter();
+ virtual void write(const char *buf, unsigned int size);
+};
+
} // namespace binary
} // namespace meshio