File tree Expand file tree Collapse file tree 5 files changed +267
-159
lines changed
include/RTC/TestSerializable Expand file tree Collapse file tree 5 files changed +267
-159
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ namespace RTC
7979 * must include padding if needed).
8080 */
8181 static Chunk* Parse (const uint8_t * data, size_t len, bool exactLen);
82+
8283 static const std::string& ChunkType2String (ChunkType chunkType);
8384
8485 private:
Original file line number Diff line number Diff line change 33
44#include " common.hpp"
55#include " RTC/Serializable.hpp"
6+ #include < string>
7+ #include < unordered_map>
68
79using namespace RTC ;
810
@@ -30,16 +32,27 @@ using namespace RTC;
3032class FooItem : public Serializable
3133{
3234public:
35+ /* *
36+ * Item Id.
37+ */
38+ enum class ItemId : uint8_t
39+ {
40+ NONE = 0x0 ,
41+ DATA = 0x1 ,
42+ EVENT = 0x2 ,
43+ CONTROL = 0x3 ,
44+ };
45+
3346 /* *
3447 * Struct of a the FooItem Header.
3548 */
3649 struct ItemHeader
3750 {
3851#if defined(MS_LITTLE_ENDIAN)
3952 uint8_t flags : 4 ;
40- uint8_t id : 4 ;
53+ ItemId id : 4 ;
4154#elif defined(MS_BIG_ENDIAN)
42- uint8_t id : 4 ;
55+ ItemId id : 4 ;
4356 uint8_t flags : 4 ;
4457#endif
4558 uint8_t valueLength;
@@ -60,11 +73,16 @@ class FooItem : public Serializable
6073 static std::unique_ptr<FooItem> Factory (
6174 const uint8_t * buffer,
6275 size_t bufferLength,
63- uint8_t id,
76+ ItemId id,
6477 uint8_t flags,
6578 const uint8_t * value,
6679 uint8_t valueLength);
6780
81+ static const std::string& ItemId2String (ItemId id);
82+
83+ private:
84+ static std::unordered_map<ItemId, std::string> itemId2String;
85+
6886private:
6987 /* *
7088 * Constructor is private because we only want to create FooItem instances
@@ -79,12 +97,12 @@ class FooItem : public Serializable
7997
8098 std::unique_ptr<Serializable> Clone (const uint8_t * buffer, size_t bufferLength) const override ;
8199
82- uint8_t GetId () const
100+ ItemId GetId () const
83101 {
84102 return GetHeaderPointer ()->id ;
85103 }
86104
87- void SetId (uint8_t id)
105+ void SetId (ItemId id)
88106 {
89107 GetHeaderPointer ()->id = id;
90108 }
You can’t perform that action at this time.
0 commit comments