mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Reformat per new coding guidelines.
Change-Id: Ib0e5d3a6fabe6db414d72b334ca7a7f33bc5726b
This commit is contained in:
@@ -14,94 +14,84 @@
|
||||
#include "nt_leb128.h"
|
||||
#include "nt_raw_istream.h"
|
||||
|
||||
namespace NtImpl {
|
||||
namespace ntimpl {
|
||||
|
||||
class WireDecoder
|
||||
{
|
||||
public:
|
||||
explicit WireDecoder(raw_istream& is, unsigned int proto_rev);
|
||||
~WireDecoder();
|
||||
class WireDecoder {
|
||||
public:
|
||||
explicit WireDecoder(raw_istream& is, unsigned int proto_rev);
|
||||
~WireDecoder();
|
||||
|
||||
void SetProtocolRev(unsigned int proto_rev)
|
||||
{
|
||||
m_proto_rev = proto_rev;
|
||||
}
|
||||
void SetProtocolRev(unsigned int proto_rev) { m_proto_rev = proto_rev; }
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_error = nullptr;
|
||||
}
|
||||
void Reset() { m_error = nullptr; }
|
||||
|
||||
const char* GetError() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
const char* GetError() const { return m_error; }
|
||||
|
||||
bool Read(char** buf, std::size_t len)
|
||||
{
|
||||
if (len > m_allocated)
|
||||
Realloc(len);
|
||||
*buf = m_buf;
|
||||
return m_is.read(m_buf, len);
|
||||
}
|
||||
bool Read(char** buf, std::size_t len) {
|
||||
if (len > m_allocated) Realloc(len);
|
||||
*buf = m_buf;
|
||||
return m_is.read(m_buf, len);
|
||||
}
|
||||
|
||||
bool Read8(unsigned int* val)
|
||||
{
|
||||
char* buf;
|
||||
if (!Read(&buf, 1)) return false;
|
||||
*val = (*((unsigned char *)buf)) & 0xff;
|
||||
return true;
|
||||
}
|
||||
bool Read8(unsigned int* val) {
|
||||
char* buf;
|
||||
if (!Read(&buf, 1)) return false;
|
||||
*val = (*((unsigned char*)buf)) & 0xff;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Read16(unsigned int* val)
|
||||
{
|
||||
char* buf;
|
||||
if (!Read(&buf, 2)) return false;
|
||||
unsigned int v = (*((unsigned char *)buf)) & 0xff;
|
||||
++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff;
|
||||
*val = v;
|
||||
return true;
|
||||
}
|
||||
bool Read16(unsigned int* val) {
|
||||
char* buf;
|
||||
if (!Read(&buf, 2)) return false;
|
||||
unsigned int v = (*((unsigned char*)buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
v |= (*((unsigned char*)buf)) & 0xff;
|
||||
*val = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Read32(unsigned long *val)
|
||||
{
|
||||
char* buf;
|
||||
if (!Read(&buf, 4)) return false;
|
||||
unsigned int v = (*((unsigned char *)buf)) & 0xff;
|
||||
++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff;
|
||||
++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff;
|
||||
++buf; v <<= 8; v |= (*((unsigned char *)buf)) & 0xff;
|
||||
*val = v;
|
||||
return true;
|
||||
}
|
||||
bool Read32(unsigned long* val) {
|
||||
char* buf;
|
||||
if (!Read(&buf, 4)) return false;
|
||||
unsigned int v = (*((unsigned char*)buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
v |= (*((unsigned char*)buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
v |= (*((unsigned char*)buf)) & 0xff;
|
||||
++buf;
|
||||
v <<= 8;
|
||||
v |= (*((unsigned char*)buf)) & 0xff;
|
||||
*val = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadDouble(double* val);
|
||||
bool ReadDouble(double* val);
|
||||
|
||||
bool ReadULEB128(unsigned long* val)
|
||||
{
|
||||
return read_uleb128(m_is, val);
|
||||
}
|
||||
bool ReadULEB128(unsigned long* val) { return read_uleb128(m_is, val); }
|
||||
|
||||
bool ReadType(NT_Type* type);
|
||||
bool ReadValue(NT_Type type, NT_Value* value);
|
||||
bool ReadString(NT_String* str);
|
||||
bool ReadType(NT_Type* type);
|
||||
bool ReadValue(NT_Type type, NT_Value* value);
|
||||
bool ReadString(NT_String* str);
|
||||
|
||||
WireDecoder(const WireDecoder&) = delete;
|
||||
WireDecoder& operator= (const WireDecoder&) = delete;
|
||||
WireDecoder(const WireDecoder&) = delete;
|
||||
WireDecoder& operator=(const WireDecoder&) = delete;
|
||||
|
||||
protected:
|
||||
unsigned int m_proto_rev;
|
||||
const char* m_error;
|
||||
protected:
|
||||
unsigned int m_proto_rev;
|
||||
const char* m_error;
|
||||
|
||||
private:
|
||||
void Realloc(std::size_t len);
|
||||
private:
|
||||
void Realloc(std::size_t len);
|
||||
|
||||
raw_istream& m_is;
|
||||
raw_istream& m_is;
|
||||
|
||||
char* m_buf;
|
||||
std::size_t m_allocated;
|
||||
char* m_buf;
|
||||
std::size_t m_allocated;
|
||||
};
|
||||
|
||||
} // namespace NtImpl
|
||||
} // namespace ntimpl
|
||||
|
||||
#endif /* NT_WIREDECODER_H_ */
|
||||
#endif // NT_WIREDECODER_H_
|
||||
|
||||
Reference in New Issue
Block a user