2015-02-05 21:57:04 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
class TLVNode {
|
|
|
|
|
public:
|
|
|
|
|
TLVNode(const uint16_t type);
|
|
|
|
|
TLVNode(const uint16_t type, const std::string value);
|
2015-02-07 10:35:29 -08:00
|
|
|
~TLVNode();
|
2015-02-05 21:57:04 +00:00
|
|
|
|
2015-02-07 15:07:34 -08:00
|
|
|
static std::unique_ptr<TLVNode> Decode(const std::string& input);
|
2015-02-05 21:57:04 +00:00
|
|
|
|
2015-02-07 10:35:29 -08:00
|
|
|
void AppendChild(TLVNode* child);
|
2015-02-07 19:01:48 +01:00
|
|
|
|
2015-02-07 10:35:29 -08:00
|
|
|
TLVNode* FindChild(const uint16_t type) const;
|
|
|
|
|
void Encode(std::string* output) const;
|
2015-02-07 19:01:48 +01:00
|
|
|
bool IsContainer() const;
|
2015-02-07 10:35:29 -08:00
|
|
|
uint16_t GetType() const;
|
|
|
|
|
const std::string& GetValue() const;
|
2015-02-06 16:27:47 +00:00
|
|
|
|
2015-02-05 21:57:04 +00:00
|
|
|
private:
|
|
|
|
|
const uint16_t type_;
|
|
|
|
|
const std::string value_;
|
2015-02-07 10:35:29 -08:00
|
|
|
std::list<TLVNode*> children_;
|
2015-02-05 21:57:04 +00:00
|
|
|
};
|