1 #ifndef MESH_IO_BINARY_H_INCLUDED
2 #define MESH_IO_BINARY_H_INCLUDED
13 *
\83f
\81[
\83^
\93Ç
\82Ý
\8d\9e\82Ý
\83C
\83\93\83^
\81[
\83t
\83F
\81[
\83X
19 virtual unsigned int read(char *buf, unsigned int size)=0;
20 virtual unsigned int getPos()const=0;
21 virtual bool isEnd()const=0;
26 if(read(reinterpret_cast<char*>(&t), sizeof(t))){
36 return get(byte) ? byte : 0;
38 std::string getString(unsigned int length, bool isTrim=false)
40 std::vector<char> buf(length);
41 read(&buf[0], buf.size());
43 std::vector<char>::iterator it;
46 for(; it!=buf.end(); ++it){
55 return std::string(buf.begin(), it);
57 unsigned char getUchar()
60 return get(value) ? value : 0;
62 unsigned short getUshort()
65 return get(value) ? value : 0;
67 unsigned int getUint()
70 return get(value) ? value : 0;
75 *
\83t
\83@
\83C
\83\8b\82©
\82ç
\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
77 class FileReader : public IReader
84 FileReader(const char *path);
85 virtual ~FileReader();
86 virtual unsigned int read(char *buf, unsigned int size);
87 virtual unsigned int getPos()const;
88 virtual bool isEnd()const;
92 *
\83\81\83\82\83\8a\82©
\82ç
\82Ì
\93Ç
\82Ý
\8d\9e\82Ý
94 class MemoryReader : public IReader
101 MemoryReader(const char *buf, unsigned int size);
102 virtual ~MemoryReader();
103 virtual unsigned int read(char *buf, unsigned int size);
104 virtual unsigned int getPos()const;
105 virtual bool isEnd()const;
108 void readAll(const char *path, std::vector<char> &all);
110 void readAll(const wchar_t *path, std::vector<char> &all);
114 *
\83f
\81[
\83^
\8f\91\82«
\8d\9e\82Ý
\83C
\83\93\83^
\81[
\83t
\83F
\81[
\83X
120 virtual void write(const char *buf, unsigned int size)=0;
121 void printLn(const char *fmt, ...)
126 vsprintf(buf, fmt, list);
127 write(buf, strlen(buf));
132 void writeArray(const T *array, size_t element_count)
135 reinterpret_cast<const char*>(array),
136 sizeof(T)*element_count);
139 void writeValue(T value)
141 writeArray(&value, 1);
145 class FileWriter : public IWriter
150 FileWriter(const char *path);
151 virtual ~FileWriter();
152 virtual void write(const char *buf, unsigned int size);
155 } // namespace binary
156 } // namespace meshio
158 #endif // MESH_IO_BINARY_H_INCLUDED