| | | 1 | | // Copyright (c) ZeroC, Inc. |
| | | 2 | | |
| | | 3 | | namespace ZeroC.Slice.Internal; |
| | | 4 | | |
| | | 5 | | /// <summary>Enumerations and constants used by Slice1.</summary> |
| | | 6 | | internal static class Slice1Definitions |
| | | 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="Slice1Definitions.TypeIdKind" /> of a <see cref="Slice1Definitions.SliceFlags" |
| | | 36 | | /// /> value.</summary> |
| | | 37 | | /// <param name="sliceFlags">The <see cref="Slice1Definitions.SliceFlags" /> value.</param> |
| | | 38 | | /// <returns>The <see cref="Slice1Definitions.TypeIdKind" /> encoded in sliceFlags.</returns> |
| | | 39 | | internal static Slice1Definitions.TypeIdKind GetTypeIdKind(this Slice1Definitions.SliceFlags sliceFlags) => |
| | 297 | 40 | | (Slice1Definitions.TypeIdKind)(sliceFlags & Slice1Definitions.SliceFlags.TypeIdMask); |
| | | 41 | | } |