| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | namespace IceRpc.Ice.Codec.Internal; |
| | | 4 | | |
| | | 5 | | /// <summary>Enumerations and constants used by the Ice encoding.</summary> |
| | | 6 | | internal static class IceEncodingDefinitions |
| | | 7 | | { |
| | | 8 | | internal const byte TagEndMarker = 0xFF; |
| | | 9 | | |
| | | 10 | | /// <summary>The first byte of each encoded class or exception slice.</summary> |
| | | 11 | | /// <remarks>The first 2 bits of SliceFlags represent the TypeIdKind, which can be extracted using |
| | | 12 | | /// <see cref="SliceFlagsExtensions.GetTypeIdKind" />.</remarks> |
| | | 13 | | [Flags] |
| | | 14 | | internal enum SliceFlags : byte |
| | | 15 | | { |
| | | 16 | | TypeIdMask = 3, |
| | | 17 | | HasTaggedFields = 4, |
| | | 18 | | HasIndirectionTable = 8, |
| | | 19 | | HasSliceSize = 16, |
| | | 20 | | IsLastSlice = 32 |
| | | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary>The first 2 bits of the <see cref="SliceFlags" />.</summary> |
| | | 24 | | internal enum TypeIdKind : byte |
| | | 25 | | { |
| | | 26 | | None = 0, |
| | | 27 | | String = 1, |
| | | 28 | | Index = 2, |
| | | 29 | | CompactId = 3, |
| | | 30 | | } |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | internal static class SliceFlagsExtensions |
| | | 34 | | { |
| | | 35 | | /// <summary>Extracts the <see cref="IceEncodingDefinitions.TypeIdKind" /> of a <see cref="IceEncodingDefinitions.Sl |
| | | 36 | | /// /> value.</summary> |
| | | 37 | | /// <param name="sliceFlags">The <see cref="IceEncodingDefinitions.SliceFlags" /> value.</param> |
| | | 38 | | /// <returns>The <see cref="IceEncodingDefinitions.TypeIdKind" /> encoded in sliceFlags.</returns> |
| | | 39 | | internal static IceEncodingDefinitions.TypeIdKind GetTypeIdKind(this IceEncodingDefinitions.SliceFlags sliceFlags) = |
| | 296 | 40 | | (IceEncodingDefinitions.TypeIdKind)(sliceFlags & IceEncodingDefinitions.SliceFlags.TypeIdMask); |
| | | 41 | | } |