| 2688 | |
| 2689 | |
| 2690 | bool cConnection::ParseMetadata(cByteBuffer & a_Buffer, AString & a_Metadata) |
| 2691 | { |
| 2692 | char x; |
| 2693 | if (!a_Buffer.ReadChar(x)) |
| 2694 | { |
| 2695 | return false; |
| 2696 | } |
| 2697 | a_Metadata.push_back(x); |
| 2698 | while (x != 0x7f) |
| 2699 | { |
| 2700 | // int Index = ((unsigned)((unsigned char)x)) & 0x1f; // Lower 5 bits = index |
| 2701 | int Type = ((unsigned)((unsigned char)x)) >> 5; // Upper 3 bits = type |
| 2702 | int Length = 0; |
| 2703 | switch (Type) |
| 2704 | { |
| 2705 | case 0: Length = 1; break; // Byte |
| 2706 | case 1: Length = 2; break; // short |
| 2707 | case 2: Length = 4; break; // int |
| 2708 | case 3: Length = 4; break; // float |
| 2709 | case 4: // UTF-8 string with VarInt length |
| 2710 | { |
| 2711 | UInt32 Len; |
| 2712 | int rs = a_Buffer.GetReadableSpace(); |
| 2713 | if (!a_Buffer.ReadVarInt(Len)) |
| 2714 | { |
| 2715 | return false; |
| 2716 | } |
| 2717 | rs = rs - a_Buffer.GetReadableSpace(); |
| 2718 | cByteBuffer LenBuf(8); |
| 2719 | LenBuf.WriteVarInt(Len); |
| 2720 | AString VarLen; |
| 2721 | LenBuf.ReadAll(VarLen); |
| 2722 | a_Metadata.append(VarLen); |
| 2723 | Length = Len; |
| 2724 | break; |
| 2725 | } |
| 2726 | case 5: |
| 2727 | { |
| 2728 | int Before = a_Buffer.GetReadableSpace(); |
| 2729 | AString ItemDesc; |
| 2730 | if (!ParseSlot(a_Buffer, ItemDesc)) |
| 2731 | { |
| 2732 | return false; |
| 2733 | } |
| 2734 | int After = a_Buffer.GetReadableSpace(); |
| 2735 | a_Buffer.ResetRead(); |
| 2736 | a_Buffer.SkipRead(a_Buffer.GetReadableSpace() - Before); |
| 2737 | Length = Before - After; |
| 2738 | break; |
| 2739 | } |
| 2740 | case 6: Length = 12; break; // 3 * int |
| 2741 | case 7: |
| 2742 | default: |
| 2743 | { |
| 2744 | ASSERT(!"Unknown metadata type"); |
| 2745 | break; |
| 2746 | } |
| 2747 | } // switch (Type) |
nothing calls this directly
no test coverage detected