//===----------------------------------------------------------------------===//
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
- unsigned &Result) {
+ unsigned &Result) {
if (Buf+4 > EndBuf) return true;
#ifdef ENDIAN_LITTLE
Result = *(unsigned*)Buf;
}
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
- uint64_t &Result) {
+ uint64_t &Result) {
if (Buf+8 > EndBuf) return true;
#ifdef ENDIAN_LITTLE
}
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
- int &Result) {
+ int &Result) {
return read(Buf, EndBuf, (unsigned &)Result);
}
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
- int64_t &Result) {
+ int64_t &Result) {
return read(Buf, EndBuf, (uint64_t &)Result);
}
// read_vbr - Read an unsigned integer encoded in variable bitrate format.
//
static inline bool read_vbr(const unsigned char *&Buf,
- const unsigned char *EndBuf, unsigned &Result) {
+ const unsigned char *EndBuf, unsigned &Result) {
unsigned Shift = Result = 0;
do {
}
static inline bool read_vbr(const unsigned char *&Buf,
- const unsigned char *EndBuf, uint64_t &Result) {
+ const unsigned char *EndBuf, uint64_t &Result) {
unsigned Shift = 0; Result = 0;
do {
// read_vbr (signed) - Read a signed number stored in sign-magnitude format
static inline bool read_vbr(const unsigned char *&Buf,
- const unsigned char *EndBuf, int &Result) {
+ const unsigned char *EndBuf, int &Result) {
unsigned R;
if (read_vbr(Buf, EndBuf, R)) return true;
if (R & 1)
static inline bool read_vbr(const unsigned char *&Buf,
- const unsigned char *EndBuf, int64_t &Result) {
+ const unsigned char *EndBuf, int64_t &Result) {
uint64_t R;
if (read_vbr(Buf, EndBuf, R)) return true;
if (R & 1)
// align32 - Round up to multiple of 32 bits...
static inline bool align32(const unsigned char *&Buf,
- const unsigned char *EndBuf) {
+ const unsigned char *EndBuf) {
Buf = (const unsigned char *)((unsigned long)(Buf+3) & (~3UL));
return Buf > EndBuf;
}
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
- std::string &Result, bool Aligned = true) {
+ std::string &Result, bool Aligned = true) {
unsigned Size;
if (read_vbr(Buf, EndBuf, Size)) return true; // Failure reading size?
if (Buf+Size > EndBuf) return true; // Size invalid?
}
static inline bool input_data(const unsigned char *&Buf,
- const unsigned char *EndBuf,
- void *Ptr, void *End, bool Align = false) {
+ const unsigned char *EndBuf,
+ void *Ptr, void *End, bool Align = false) {
unsigned char *Start = (unsigned char *)Ptr;
unsigned Amount = (unsigned char *)End - Start;
if (Buf+Amount > EndBuf) return true;
}
static inline void output(const std::string &s, std::deque<unsigned char> &Out,
- bool Aligned = true) {
+ bool Aligned = true) {
unsigned Len = s.length();
output_vbr(Len, Out); // Strings may have an arbitrary length...
Out.insert(Out.end(), s.begin(), s.end());
}
static inline void output_data(void *Ptr, void *End,
- std::deque<unsigned char> &Out,
+ std::deque<unsigned char> &Out,
bool Align = false) {
#ifdef ENDIAN_LITTLE
Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End);