예제 #1
0
        /// <param name="bytes">An array of bytes to create a string representation for.</param>
        /// <param name="offset">Offset of the start index.</param>
        /// <inheritdoc cref="BinaryStringUtility.ToCharsInternal(byte*, int, char)"/>
        /// /// <inheritdoc cref="ValidationUtility.CheckArrayOffsetAndCount{T}(T[], string, int, int)"/>
        public static unsafe char[] ToChars(byte[] bytes, int offset, int count, char delimeter = kNoDelimeter)
        {
            ValidationUtility.CheckArrayOffsetAndCount(bytes, nameof(bytes), offset, count);

            if (count == 0)
                return(Array.Empty <char>());

            fixed(byte *ptr = bytes)
            return(ToCharsInternal(ptr + offset, count, delimeter));
        }
예제 #2
0
        /// <inheritdoc cref="ValidationUtility.CheckArrayOffsetAndCount{T}(T[], string, int, int)"/>
        public unsafe Binary64(byte[] buffer, int offset)
        {
            ValidationUtility.CheckArrayOffsetAndCount(buffer, nameof(buffer), offset, kByteCount);

            fixed(byte *bufferPtr = buffer)
            {
                var offsetPtr = bufferPtr + offset;

                this = new Binary64(offsetPtr);
            }
        }
예제 #3
0
        /// <param name="bytes">An array of bytes for which to reverse the endianness.</param>
        /// <param name="offset">Offset of the start index.</param>
        /// <inheritdoc cref="EndiannessUtility.ReverseEndiannessInternal(byte*, int)"/>
        /// /// <inheritdoc cref="ValidationUtility.CheckArrayOffsetAndCount{T}(T[], string, int, int)"/>
        public static unsafe void ReverseEndianness(byte[] bytes, int offset, int count)
        {
            ValidationUtility.CheckArrayOffsetAndCount(bytes, nameof(bytes), offset, count);

            if (offset == 0 && count == bytes.Length)
            {
                Array.Reverse(bytes);
            }
            else
            {
                fixed(byte *ptr = bytes)
                ReverseEndiannessInternal(ptr + offset, count);
            }
        }