58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
#ifndef NETWORK_DNS_DATA_H
|
|
#define NETWORK_DNS_DATA_H
|
|
|
|
#include <vector>
|
|
#include <cstdint>
|
|
#include <iostream>
|
|
|
|
namespace Network {
|
|
namespace Dns {
|
|
|
|
class Data
|
|
{
|
|
public:
|
|
Data();
|
|
Data(const std::vector<uint8_t>& data);
|
|
Data(const uint8_t* msg, unsigned length);
|
|
Data(const Data& data);
|
|
|
|
Data& operator=(Data other);
|
|
|
|
uint8_t& GetAt(unsigned pos);
|
|
const uint8_t& GetAt(unsigned pos) const;
|
|
uint16_t& GetAt16(unsigned pos);
|
|
const uint16_t& GetAt16(unsigned pos) const;
|
|
uint32_t& GetAt32(unsigned pos);
|
|
const uint32_t& GetAt32(unsigned pos) const;
|
|
|
|
const uint8_t* GetPtr() const;
|
|
unsigned GetLength() const;
|
|
|
|
void append(const Data& data);
|
|
void append(uint8_t value);
|
|
void append(uint16_t value);
|
|
void append(uint32_t value);
|
|
void append(uint64_t value);
|
|
|
|
template<typename Arg1, typename ...Args>
|
|
void append(Arg1 value, Args ...args)
|
|
{
|
|
append(value);
|
|
append(args...);
|
|
}
|
|
|
|
void prepend(const Data& data);
|
|
|
|
void swap(Data& x) noexcept;
|
|
|
|
friend std::ostream& operator<<(std::ostream& stream, const Data& data);
|
|
|
|
private:
|
|
std::vector<uint8_t> m_data;
|
|
};
|
|
|
|
} // namespace Dns
|
|
} // namespace Network
|
|
|
|
#endif // NETWORK_DNS_DATA_H
|