Exemple #1
0
 internal override object Read1(ByteArrayBuffer a_bytes)
 {
     var b1 = a_bytes.ReadByte();
     var b2 = a_bytes.ReadByte();
     var ret = (char) ((b1 & unchecked(0xff)) | ((b2 & unchecked(0xff))
                                                 << 8));
     return ret;
 }
Exemple #2
0
        internal override object Read1(ByteArrayBuffer a_bytes)
        {
            byte b1  = a_bytes.ReadByte();
            byte b2  = a_bytes.ReadByte();
            char ret = (char)((b1 & unchecked ((int)(0xff))) | ((b2 & unchecked ((int)(0xff)))
                                                                << 8));

            return(ret);
        }
Exemple #3
0
 protected virtual bool SignatureMatches(ByteArrayBuffer reader, byte[] signature,
                                         byte version)
 {
     for (int i = 0; i < signature.Length; i++)
     {
         if (reader.ReadByte() != signature[i])
         {
             return(false);
         }
     }
     return(reader.ReadByte() == version);
 }
Exemple #4
0
        public virtual void TestGrandChildren()
        {
            MarshallingBuffer buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            MarshallingBuffer child = buffer.AddChild();

            child.WriteInt(Data3);
            child.WriteInt(Data4);
            MarshallingBuffer grandChild = child.AddChild();

            grandChild.WriteInt(Data5);
            buffer.MergeChildren(null, 0, 0);
            ByteArrayBuffer content = InspectContent(buffer);

            Assert.AreEqual(Data1, content.ReadInt());
            Assert.AreEqual(Data2, content.ReadByte());
            int address = content.ReadInt();

            content.Seek(address);
            Assert.AreEqual(Data3, content.ReadInt());
            Assert.AreEqual(Data4, content.ReadInt());
            address = content.ReadInt();
            content.Seek(address);
            Assert.AreEqual(Data5, content.ReadInt());
        }
Exemple #5
0
        public virtual void TestLinkOffset()
        {
            var linkOffset = 7;
            var buffer     = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            var child = buffer.AddChild();

            child.WriteInt(Data3);
            child.WriteInt(Data4);
            var grandChild = child.AddChild();

            grandChild.WriteInt(Data5);
            buffer.MergeChildren(null, 0, linkOffset);
            var content        = InspectContent(buffer);
            var extendedBuffer = new ByteArrayBuffer(content.Length() + linkOffset
                                                     );

            content.CopyTo(extendedBuffer, 0, linkOffset, content.Length());
            extendedBuffer.Seek(linkOffset);
            Assert.AreEqual(Data1, extendedBuffer.ReadInt());
            Assert.AreEqual(Data2, extendedBuffer.ReadByte());
            var address = extendedBuffer.ReadInt();

            extendedBuffer.Seek(address);
            Assert.AreEqual(Data3, extendedBuffer.ReadInt());
            Assert.AreEqual(Data4, extendedBuffer.ReadInt());
            address = extendedBuffer.ReadInt();
            extendedBuffer.Seek(address);
            Assert.AreEqual(Data5, extendedBuffer.ReadInt());
        }
Exemple #6
0
        protected override void Read(LocalObjectContainer container, ByteArrayBuffer reader
                                     )
        {
            NewTimerFileLock(container);
            OldEncryptionOff(container);
            CheckThreadFileLock(container, reader);
            reader.Seek(BlocksizeOffset);
            container.BlockSizeReadFromFile(reader.ReadInt());
            SystemData systemData = container.SystemData();

            systemData.ClassCollectionID(reader.ReadInt());
            container.SystemData().IdSystemType(reader.ReadByte());
            _variablePart = CreateVariablePart(container);
            int variablePartAddress = reader.ReadInt();
            int variablePartLength  = reader.ReadInt();

            _variablePart.Read(variablePartAddress, variablePartLength);
            _transactionPointerAddress = reader.ReadInt();
            if (_transactionPointerAddress != 0)
            {
                ByteArrayBuffer buffer = new ByteArrayBuffer(TransactionPointerLength);
                buffer.Read(container, _transactionPointerAddress, 0);
                systemData.TransactionPointer1(buffer.ReadInt());
                systemData.TransactionPointer2(buffer.ReadInt());
            }
        }
Exemple #7
0
 protected Db4objects.Db4o.Internal.Transaction CheckParentTransaction(Db4objects.Db4o.Internal.Transaction
                                                                       a_trans, ByteArrayBuffer reader)
 {
     if (reader.ReadByte() == Const4.SystemTrans && a_trans.ParentTransaction() != null)
     {
         return(a_trans.ParentTransaction());
     }
     return(a_trans);
 }
 public virtual void ReadThis(ByteArrayBuffer buffer)
 {
     SystemData().ConverterVersion(buffer.ReadInt());
     SystemData().FreespaceSystem(buffer.ReadByte());
     buffer.ReadInt();
     // was BTreeFreespaceId, converted to slot, can no longer be used
     SystemData().IdentityId(buffer.ReadInt());
     SystemData().LastTimeStampID(buffer.ReadLong());
     SystemData().UuidIndexId(buffer.ReadInt());
 }
Exemple #9
0
        private void ReadNodeHeader(ByteArrayBuffer reader)
        {
            _count = reader.ReadInt();
            byte leafByte = reader.ReadByte();

            _isLeaf     = (leafByte == 1);
            _parentID   = reader.ReadInt();
            _previousID = reader.ReadInt();
            _nextID     = reader.ReadInt();
        }
 public virtual void ReadThis(ByteArrayBuffer buffer)
 {
     SystemData().ConverterVersion(buffer.ReadInt());
     SystemData().FreespaceSystem(buffer.ReadByte());
     buffer.ReadInt();
     // was BTreeFreespaceId, converted to slot, can no longer be used
     SystemData().IdentityId(buffer.ReadInt());
     SystemData().LastTimeStampID(buffer.ReadLong());
     SystemData().UuidIndexId(buffer.ReadInt());
 }
Exemple #11
0
        internal virtual void ReadThis()
        {
            Write(Msg.GetClasses.GetWriter(SystemTransaction()));
            ByteArrayBuffer bytes = ExpectedBufferResponse(Msg.GetClasses);

            ClassCollection().SetID(bytes.ReadInt());
            byte stringEncoding = bytes.ReadByte();

            CreateStringIO(stringEncoding);
            ClassCollection().Read(SystemTransaction());
        }
Exemple #12
0
        public virtual void TestWrite()
        {
            MarshallingBuffer buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            buffer.WriteByte(Data2);
            ByteArrayBuffer content = InspectContent(buffer);

            Assert.AreEqual(Data1, content.ReadInt());
            Assert.AreEqual(Data2, content.ReadByte());
        }
        public virtual void TestCopy()
        {
            ByteArrayBuffer from = new ByteArrayBuffer(Readerlength);

            for (int i = 0; i < Readerlength; i++)
            {
                from.WriteByte((byte)i);
            }
            ByteArrayBuffer to = new ByteArrayBuffer(Readerlength - 1);

            from.CopyTo(to, 1, 2, 10);
            Assert.AreEqual(0, to.ReadByte());
            Assert.AreEqual(0, to.ReadByte());
            for (int i = 1; i <= 10; i++)
            {
                Assert.AreEqual((byte)i, to.ReadByte());
            }
            for (int i = 12; i < Readerlength - 1; i++)
            {
                Assert.AreEqual(0, to.ReadByte());
            }
        }
Exemple #14
0
 internal override object Read1(ByteArrayBuffer a_bytes)
 {
     var ret = a_bytes.ReadByte();
     if (ret == True)
     {
         return true;
     }
     if (ret == False)
     {
         return false;
     }
     return null;
 }
Exemple #15
0
        internal override object Read1(ByteArrayBuffer a_bytes)
        {
            byte ret = a_bytes.ReadByte();

            if (ret == True)
            {
                return(true);
            }
            if (ret == False)
            {
                return(false);
            }
            return(null);
        }
        protected virtual void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent
                                          )
        {
            buffer.IncrementOffset(ChecksumLength);
            SystemData systemData = SystemData();

            systemData.IdSystemSlot(ReadSlot(buffer, false));
            systemData.InMemoryFreespaceSlot(ReadSlot(buffer, !versionsAreConsistent));
            systemData.BTreeFreespaceId(buffer.ReadInt());
            systemData.ConverterVersion(buffer.ReadInt());
            systemData.UuidIndexId(buffer.ReadInt());
            systemData.IdentityId(buffer.ReadInt());
            systemData.LastTimeStampID(buffer.ReadLong());
            systemData.FreespaceSystem(buffer.ReadByte());
        }
Exemple #17
0
        public virtual void TestTransferLastWrite()
        {
            MarshallingBuffer buffer = new MarshallingBuffer();

            buffer.WriteInt(Data1);
            int lastOffset = Offset(buffer);

            buffer.WriteByte(Data2);
            MarshallingBuffer other = new MarshallingBuffer();

            buffer.TransferLastWriteTo(other, true);
            Assert.AreEqual(lastOffset, Offset(buffer));
            ByteArrayBuffer content = InspectContent(other);

            Assert.AreEqual(Data2, content.ReadByte());
        }
Exemple #18
0
 protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase
     stream, ByteArrayBuffer reader)
 {
     var name = StringHandler.ReadStringNoDebug(stream.Transaction.Context(), reader
         );
     if (!aspectType.IsFieldMetadata())
     {
         return new RawFieldSpec(aspectType, name);
     }
     if (name.IndexOf(Const4.VirtualFieldPrefix) == 0)
     {
         if (stream._handlers.VirtualFieldByName(name) != null)
         {
             return new RawFieldSpec(aspectType, name);
         }
     }
     var fieldTypeID = reader.ReadInt();
     var attribs = reader.ReadByte();
     return new RawFieldSpec(aspectType, name, fieldTypeID, attribs);
 }
Exemple #19
0
        protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase
                                                 stream, ByteArrayBuffer reader)
        {
            var name = StringHandler.ReadStringNoDebug(stream.Transaction.Context(), reader
                                                       );

            if (!aspectType.IsFieldMetadata())
            {
                return(new RawFieldSpec(aspectType, name));
            }
            if (name.IndexOf(Const4.VirtualFieldPrefix) == 0)
            {
                if (stream._handlers.VirtualFieldByName(name) != null)
                {
                    return(new RawFieldSpec(aspectType, name));
                }
            }
            var fieldTypeID = reader.ReadInt();
            var attribs     = reader.ReadByte();

            return(new RawFieldSpec(aspectType, name, fieldTypeID, attribs));
        }
Exemple #20
0
 protected override void Read(LocalObjectContainer container, ByteArrayBuffer reader
     )
 {
     NewTimerFileLock(container);
     OldEncryptionOff(container);
     CheckThreadFileLock(container, reader);
     reader.Seek(BlocksizeOffset);
     container.BlockSizeReadFromFile(reader.ReadInt());
     var systemData = container.SystemData();
     systemData.ClassCollectionID(reader.ReadInt());
     container.SystemData().IdSystemType(reader.ReadByte());
     _variablePart = CreateVariablePart(container);
     var variablePartAddress = reader.ReadInt();
     var variablePartLength = reader.ReadInt();
     _variablePart.Read(variablePartAddress, variablePartLength);
     _transactionPointerAddress = reader.ReadInt();
     if (_transactionPointerAddress != 0)
     {
         var buffer = new ByteArrayBuffer(TransactionPointerLength);
         buffer.Read(container, _transactionPointerAddress, 0);
         systemData.TransactionPointer1(buffer.ReadInt());
         systemData.TransactionPointer2(buffer.ReadInt());
     }
 }
Exemple #21
0
 internal override object Read1(ByteArrayBuffer a_bytes)
 {
     var ret = a_bytes.ReadByte();
     return ret;
 }
Exemple #22
0
 protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase
     stream, ByteArrayBuffer reader)
 {
     return base.ReadSpec(AspectType.ForByte(reader.ReadByte()), stream, reader);
 }
Exemple #23
0
 protected virtual bool SignatureMatches(ByteArrayBuffer reader, byte[] signature,
     byte version)
 {
     for (var i = 0; i < signature.Length; i++)
     {
         if (reader.ReadByte() != signature[i])
         {
             return false;
         }
     }
     return reader.ReadByte() == version;
 }
Exemple #24
0
 protected override RawFieldSpec ReadSpec(AspectType aspectType, ObjectContainerBase
                                          stream, ByteArrayBuffer reader)
 {
     return(base.ReadSpec(AspectType.ForByte(reader.ReadByte()), stream, reader));
 }
 protected virtual void ReadBuffer(ByteArrayBuffer buffer, bool versionsAreConsistent
     )
 {
     buffer.IncrementOffset(ChecksumLength);
     var systemData = SystemData();
     systemData.IdSystemSlot(ReadSlot(buffer, false));
     systemData.InMemoryFreespaceSlot(ReadSlot(buffer, !versionsAreConsistent));
     systemData.BTreeFreespaceId(buffer.ReadInt());
     systemData.ConverterVersion(buffer.ReadInt());
     systemData.UuidIndexId(buffer.ReadInt());
     systemData.IdentityId(buffer.ReadInt());
     systemData.LastTimeStampID(buffer.ReadLong());
     systemData.FreespaceSystem(buffer.ReadByte());
 }
Exemple #26
0
 private void ReadNodeHeader(ByteArrayBuffer reader)
 {
     _count = reader.ReadInt();
     var leafByte = reader.ReadByte();
     _isLeaf = (leafByte == 1);
     _parentID = reader.ReadInt();
     _previousID = reader.ReadInt();
     _nextID = reader.ReadInt();
 }
Exemple #27
0
 public virtual byte ReadByte()
 {
     return(_current.ReadByte());
 }
Exemple #28
0
        internal override object Read1(ByteArrayBuffer a_bytes)
        {
            var ret = a_bytes.ReadByte();

            return(ret);
        }