正在显示
1 个修改的文件
包含
29 行增加
和
0 行删除
| @@ -70,6 +70,35 @@ public: | @@ -70,6 +70,35 @@ public: | ||
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| 73 | + * This is a notation for handling repeated structures. These will always be encoded as an | ||
| 74 | + * int32 size containing the length N followed by N repetitions of the structure which can | ||
| 75 | + * itself be made up of other primitive types. In the BNF grammars below we will show an | ||
| 76 | + * array of a structure foo as [foo]. | ||
| 77 | + * @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Requests | ||
| 78 | + */ | ||
| 79 | +template<typename T> | ||
| 80 | +class SrsKafkaArray | ||
| 81 | +{ | ||
| 82 | +private: | ||
| 83 | + int length; | ||
| 84 | + std::vector<T*> elems; | ||
| 85 | + typedef typename std::vector<T*>::iterator SrsIterator; | ||
| 86 | +public: | ||
| 87 | + SrsKafkaArray() | ||
| 88 | + { | ||
| 89 | + length = 0; | ||
| 90 | + } | ||
| 91 | + virtual ~SrsKafkaArray() | ||
| 92 | + { | ||
| 93 | + for (SrsIterator it = elems.begin(); it != elems.end(); ++it) { | ||
| 94 | + T* elem = *it; | ||
| 95 | + srs_freep(elem); | ||
| 96 | + } | ||
| 97 | + elems.clear(); | ||
| 98 | + } | ||
| 99 | +}; | ||
| 100 | + | ||
| 101 | +/** | ||
| 73 | * the header of request, includes the size of request. | 102 | * the header of request, includes the size of request. |
| 74 | * @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Requests | 103 | * @see https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Requests |
| 75 | */ | 104 | */ |
-
请 注册 或 登录 后发表评论