[r1]: trunk / MMix / MMix.Machine / BinaryWriter.hpp  Maximize  Restore  History

Download this file

69 lines (64 with data), 1.4 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef MMIX_MACHINE_BINARYWRITER_INCLUDED
#define MMIX_MACHINE_BINARYWRITER_INCLUDED
#include <MMix.Machine/Type.hpp>
#include <fstream>
#include <vector>
namespace MMix { namespace Machine {
class BinaryWriter
{
public:
BinaryWriter(const String& fileName_, Octa& loc_, Octa& oloc_);
~BinaryWriter();
Octa Loc() const { return loc; }
Octa FileLoc() const { return floc; }
void Emit(Octa o);
void Emit(Tetra t);
void Emit(Wyde w);
void Emit(Byte b)
{
Put(b);
++loc;
}
void Put(Octa o);
void Put(Tetra t);
void Put(Wyde w)
{
Put(w.GetByte(0));
Put(w.GetByte(1));
}
void Put(Byte b)
{
Write(b);
++oloc;
}
void Write(Octa o);
void Write(Tetra t);
void Write(Wyde w)
{
Write(w.GetByte(0));
Write(w.GetByte(1));
}
void Write(Byte b)
{
if (bufpos >= bufsize)
{
Flush();
}
buffer[bufpos++] = b;
++floc;
}
void Write(const String& s);
void Flush();
void Align(int alignment);
private:
Octa& loc;
Octa& oloc;
Octa floc;
String fileName;
std::ofstream file;
std::vector<Byte> buffer;
int bufpos;
int bufsize;
};
} } // namespace MMix::Machine
#endif // MMIX_MACHINE_BINARYWRITER_INCLUDED

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks