45 lines
772 B
C++
45 lines
772 B
C++
#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
|
|
|