Initial RetroNFS95 Win9x VxD prototype
This commit is contained in:
44
include/xdr.hpp
Normal file
44
include/xdr.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef RETRONFS95_XDR_HPP
|
||||
#define RETRONFS95_XDR_HPP
|
||||
|
||||
#include "compat.hpp"
|
||||
|
||||
namespace retronfs {
|
||||
|
||||
class XdrWriter {
|
||||
public:
|
||||
void u32(uint32_t v);
|
||||
void u64(uint64_t v);
|
||||
void opaque(const Bytes& data);
|
||||
void fixed_opaque(const byte* data, unsigned len);
|
||||
void str(const std::string& value);
|
||||
const Bytes& data() const;
|
||||
|
||||
private:
|
||||
Bytes out_;
|
||||
void pad(unsigned len);
|
||||
};
|
||||
|
||||
class XdrReader {
|
||||
public:
|
||||
explicit XdrReader(const Bytes& data);
|
||||
|
||||
uint32_t u32();
|
||||
uint64_t u64();
|
||||
Bytes opaque();
|
||||
Bytes fixed_opaque(unsigned len);
|
||||
std::string str();
|
||||
bool eof() const;
|
||||
unsigned remaining() const;
|
||||
|
||||
private:
|
||||
const Bytes& in_;
|
||||
unsigned pos_;
|
||||
void require(unsigned n);
|
||||
void skip_pad(unsigned len);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user