mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-14 11:26:07 +00:00
Fix linking with static libs, CVector3f work, Initial COutputStream
Former-commit-id: 693fe93eab
This commit is contained in:
@@ -3,9 +3,72 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
class COutputStream;
|
||||
template <typename T>
|
||||
void coutput_stream_helper(const T& t, COutputStream& out) {
|
||||
t.PutTo(out);
|
||||
}
|
||||
|
||||
class COutputStream {
|
||||
void DoPut(const void* ptr, size_t len);
|
||||
void Flush();
|
||||
void DoFlush();
|
||||
public:
|
||||
COutputStream(int len);
|
||||
virtual ~COutputStream();
|
||||
void WriteBits(int val, int bitCount);
|
||||
|
||||
void FlushShiftRegister();
|
||||
void Put(const void* ptr, size_t len) {
|
||||
FlushShiftRegister();
|
||||
DoPut(ptr, len);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Put(const T& t) {
|
||||
coutput_stream_helper(t, *this);
|
||||
}
|
||||
|
||||
void WriteReal32(float t) {
|
||||
Put(t);
|
||||
}
|
||||
|
||||
void WriteUint32(uint t) {
|
||||
Put(t);
|
||||
}
|
||||
void WriteInt32(int t) {
|
||||
Put(t);
|
||||
}
|
||||
|
||||
void WriteLong(int t) {
|
||||
Put(&t, sizeof(int));
|
||||
}
|
||||
|
||||
private:
|
||||
uint mPosition;
|
||||
uint mBufLen;
|
||||
void* mBufPtr;
|
||||
uint mNumWrites;
|
||||
uint mShiftRegister;
|
||||
uint mShiftRegisterOffset;
|
||||
uchar mScratch[96];
|
||||
};
|
||||
|
||||
template <>
|
||||
inline void coutput_stream_helper(const float& t, COutputStream& out) {
|
||||
int tmp = *(int*)&t;
|
||||
out.Put(&tmp, sizeof(float));
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void coutput_stream_helper(const int& t, COutputStream& out) {
|
||||
out.WriteLong(t);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void coutput_stream_helper(const uint& t, COutputStream& out) {
|
||||
out.WriteLong(t);
|
||||
}
|
||||
|
||||
|
||||
#endif // _COUTPUTSTREAM_HPP
|
||||
|
||||
Reference in New Issue
Block a user