Esempio n. 1
0
        /// <summary>Align the stream's position by a certain page boundry</summary>
        /// <param name="alignmentBit">log2 size of the alignment (ie, 1&lt;&lt;bit)</param>
        /// <returns>True if any alignment had to be performed, false if otherwise</returns>
        public bool AlignToBoundry(int alignmentBit)
        {
            int align_size = IntegerMath.PaddingRequired(alignmentBit, (uint)BaseStream.Position);

            if (align_size > 0)
            {
                BaseStream.Seek(align_size, SeekOrigin.Current);
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
            public uint CalculatePadding(uint offset)
            {
                const int kAlignmentBit = IntegerMath.kInt32AlignmentBit;

                PrePadSize = 0;

                if (Type != XmbVariantType.String)
                {
                    PrePadSize = (byte)IntegerMath.PaddingRequired(kAlignmentBit, offset);
                }

                return(PrePadSize);
            }
Esempio n. 3
0
        /// <summary>Align the stream's position by a certain page boundry</summary>
        /// <param name="alignmentBit">log2 size of the alignment (ie, 1&lt;&lt;bit)</param>
        /// <returns>True if any alignment had to be performed, false if otherwise</returns>
        public bool AlignToBoundry(int alignmentBit)
        {
            int align_size = IntegerMath.PaddingRequired(alignmentBit, (uint)BaseStream.Position);

            if (align_size > 0)
            {
                while (align_size-- > 0)
                {
                    BaseStream.WriteByte(byte.MinValue);
                }
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
            public uint CalculatePadding(uint offset, bool willWriteSizeToo)
            {
                PrePadSize = 0;

                int alignment_bit = System.Math.Max(TypeDesc.AlignmentBit, IntegerMath.kInt32AlignmentBit);

                if (Type != BinaryDataTreeVariantType.String)
                {
                    PrePadSize = (byte)IntegerMath.PaddingRequired(alignment_bit, offset);
                }

                if (willWriteSizeToo)
                {
                    PrePadSize += sizeof(uint);
                }

                return(PrePadSize);
            }