コード例 #1
0
        public override void Write(object a_object, ByteArrayBuffer a_bytes)
        {
            char char_ = ((char)a_object);

            a_bytes.WriteByte((byte)(char_ & unchecked ((int)(0xff))));
            a_bytes.WriteByte((byte)(char_ >> 8));
        }
コード例 #2
0
ファイル: FieldMarshaller0.cs プロジェクト: pondyond/db4o
        public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
                                   , ByteArrayBuffer writer)
        {
            writer.WriteShortString(trans, aspect.GetName());
            if (!(aspect is FieldMetadata))
            {
                return;
            }
            var field = (FieldMetadata)aspect;

            field.Alive();
            if (field.IsVirtual())
            {
                return;
            }
            var handler = field.GetHandler();

            if (handler is StandardReferenceTypeHandler)
            {
                // TODO: ensure there is a test case, to make this happen
                if (((StandardReferenceTypeHandler)handler).ClassMetadata().GetID() == 0)
                {
                    trans.Container().NeedsUpdate(clazz);
                }
            }
            writer.WriteInt(field.FieldTypeID());
            var bitmap = new BitMap4(3);

            bitmap.Set(0, field.IsPrimitive());
            bitmap.Set(1, Handlers4.HandlesArray(handler));
            bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler));
            // keep the order
            writer.WriteByte(bitmap.GetByte(0));
        }
コード例 #3
0
 public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer)
 {
     a_writer.WriteByte(BtreeVersion);
     a_writer.WriteInt(_size);
     a_writer.WriteInt(NodeSize());
     a_writer.WriteIDOf(trans, _root);
 }
コード例 #4
0
        public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer)
        {
            ByteArrayBuffer buffer = new ByteArrayBuffer(pointer.Length());

            _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset());
            WriteObjectClassID(buffer, ClassMetadata().GetID());
            buffer.WriteByte(HandlerRegistry.HandlerVersion);
            buffer.WriteInt(AspectCount());
            buffer.WriteBitMap(_nullBitMap);
            _writeBuffer.TransferContentTo(buffer);
            return(buffer);
        }
コード例 #5
0
        public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
        {
            int      count       = 0;
            int      startOffset = buffer._offset;
            IContext context     = trans.Context();

            buffer.IncrementOffset(CountLeafAnd3LinkLength);
            if (_isLeaf)
            {
                for (int i = 0; i < _count; i++)
                {
                    object obj = InternalKey(trans, i);
                    if (obj != No4.Instance)
                    {
                        count++;
                        KeyHandler().WriteIndexEntry(context, buffer, obj);
                    }
                }
            }
            else
            {
                for (int i = 0; i < _count; i++)
                {
                    if (ChildCanSupplyFirstKey(i))
                    {
                        Db4objects.Db4o.Internal.Btree.BTreeNode child = (Db4objects.Db4o.Internal.Btree.BTreeNode
                                                                          )_children[i];
                        object childKey = child.FirstKey(trans);
                        if (childKey != No4.Instance)
                        {
                            count++;
                            KeyHandler().WriteIndexEntry(context, buffer, childKey);
                            buffer.WriteIDOf(trans, child);
                        }
                    }
                    else
                    {
                        count++;
                        KeyHandler().WriteIndexEntry(context, buffer, Key(i));
                        buffer.WriteIDOf(trans, _children[i]);
                    }
                }
            }
            int endOffset = buffer._offset;

            buffer._offset = startOffset;
            buffer.WriteInt(count);
            buffer.WriteByte(_isLeaf ? (byte)1 : (byte)0);
            buffer.WriteInt(_parentID);
            buffer.WriteInt(_previousID);
            buffer.WriteInt(_nextID);
            buffer._offset = endOffset;
        }
コード例 #6
0
        public void TestWriteByte()
        {
            var backingBytes = new byte[100];

            using (var buffer = new ByteArrayBuffer(backingBytes, 10, 80, false))
            {
                Assert.AreEqual(0, backingBytes[30]);
                Assert.AreEqual(0, backingBytes[31]);
                buffer.WriteByte(20, 1);
                Assert.AreEqual(1, backingBytes[30]);
                Assert.AreEqual(0, backingBytes[31]);
            }
        }
コード例 #7
0
        public void TestWriteByte()
        {
            var backingBytes = new byte[100];

            using (var buffer = new ByteArrayBuffer(backingBytes, 0, 0, false))
            {
                Assert.AreEqual(0, backingBytes[0]);
                Assert.AreEqual(0, backingBytes[1]);
                buffer.WriteByte(1);
                Assert.AreEqual(1, backingBytes[0]);
                Assert.AreEqual(0, backingBytes[1]);
                Assert.AreEqual(1, buffer.Position);
                Assert.AreEqual(1, buffer.Length);
            }
        }
コード例 #8
0
        protected virtual void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
        {
            SystemData systemData = SystemData();

            WriteSlot(buffer, systemData.IdSystemSlot(), false);
            WriteSlot(buffer, systemData.InMemoryFreespaceSlot(), !shuttingDown);
            buffer.WriteInt(systemData.BTreeFreespaceId());
            buffer.WriteInt(systemData.ConverterVersion());
            buffer.WriteInt(systemData.UuidIndexId());
            Db4oDatabase identity = systemData.Identity();

            buffer.WriteInt(identity == null ? 0 : identity.GetID(_container.SystemTransaction
                                                                      ()));
            buffer.WriteLong(systemData.LastTimeStampID());
            buffer.WriteByte(systemData.FreespaceSystem());
        }
コード例 #9
0
        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());
            }
        }
コード例 #10
0
        public Msg ReplyFromServer()
        {
            lock (ContainerLock())
            {
                try
                {
                    // Since every new Client reads the class
                    // collection from the file, we have to
                    // make sure, it has been written.
                    Container().ClassCollection().Write(Transaction());
                }
                catch (Exception)
                {
                }
            }
            MsgD message = Msg.GetClasses.GetWriterForLength(Transaction(), Const4.IntLength
                                                             + 1);
            ByteArrayBuffer writer = message.PayLoad();

            writer.WriteInt(Container().ClassCollection().GetID());
            writer.WriteByte(Container().StringIO().EncodingByte());
            return(message);
        }
コード例 #11
0
 public override void Write(object obj, ByteArrayBuffer buffer)
 {
     buffer.WriteByte(GetEncodedByteValue(obj));
 }
コード例 #12
0
ファイル: BTree.cs プロジェクト: masroore/db4o
 public override void WriteThis(Transaction trans, ByteArrayBuffer a_writer)
 {
     a_writer.WriteByte(BtreeVersion);
     a_writer.WriteInt(_size);
     a_writer.WriteInt(NodeSize());
     a_writer.WriteIDOf(trans, _root);
 }
コード例 #13
0
ファイル: MarshallingContext.cs プロジェクト: masroore/db4o
 public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer)
 {
     var buffer = new ByteArrayBuffer(pointer.Length());
     _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset());
     WriteObjectClassID(buffer, ClassMetadata().GetID());
     buffer.WriteByte(HandlerRegistry.HandlerVersion);
     buffer.WriteInt(AspectCount());
     buffer.WriteBitMap(_nullBitMap);
     _writeBuffer.TransferContentTo(buffer);
     return buffer;
 }
コード例 #14
0
 public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
                            , ByteArrayBuffer writer)
 {
     writer.WriteByte(aspect.AspectType()._id);
     base.Write(trans, clazz, aspect, writer);
 }
コード例 #15
0
ファイル: ByteHandler.cs プロジェクト: masroore/db4o
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     a_bytes.WriteByte(((byte) a_object));
 }
コード例 #16
0
ファイル: FieldMarshaller0.cs プロジェクト: masroore/db4o
 public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
     , ByteArrayBuffer writer)
 {
     writer.WriteShortString(trans, aspect.GetName());
     if (!(aspect is FieldMetadata))
     {
         return;
     }
     var field = (FieldMetadata) aspect;
     field.Alive();
     if (field.IsVirtual())
     {
         return;
     }
     var handler = field.GetHandler();
     if (handler is StandardReferenceTypeHandler)
     {
         // TODO: ensure there is a test case, to make this happen 
         if (((StandardReferenceTypeHandler) handler).ClassMetadata().GetID() == 0)
         {
             trans.Container().NeedsUpdate(clazz);
         }
     }
     writer.WriteInt(field.FieldTypeID());
     var bitmap = new BitMap4(3);
     bitmap.Set(0, field.IsPrimitive());
     bitmap.Set(1, Handlers4.HandlesArray(handler));
     bitmap.Set(2, Handlers4.HandlesMultidimensionalArray(handler));
     // keep the order
     writer.WriteByte(bitmap.GetByte(0));
 }
コード例 #17
0
 protected virtual void WriteBuffer(ByteArrayBuffer buffer, bool shuttingDown)
 {
     var systemData = SystemData();
     WriteSlot(buffer, systemData.IdSystemSlot(), false);
     WriteSlot(buffer, systemData.InMemoryFreespaceSlot(), !shuttingDown);
     buffer.WriteInt(systemData.BTreeFreespaceId());
     buffer.WriteInt(systemData.ConverterVersion());
     buffer.WriteInt(systemData.UuidIndexId());
     var identity = systemData.Identity();
     buffer.WriteInt(identity == null
         ? 0
         : identity.GetID(_container.SystemTransaction
             ()));
     buffer.WriteLong(systemData.LastTimeStampID());
     buffer.WriteByte(systemData.FreespaceSystem());
 }
コード例 #18
0
ファイル: BTreeNode.cs プロジェクト: masroore/db4o
 public override void WriteThis(Transaction trans, ByteArrayBuffer buffer)
 {
     var count = 0;
     var startOffset = buffer._offset;
     var context = trans.Context();
     buffer.IncrementOffset(CountLeafAnd3LinkLength);
     if (_isLeaf)
     {
         for (var i = 0; i < _count; i++)
         {
             var obj = InternalKey(trans, i);
             if (obj != No4.Instance)
             {
                 count++;
                 KeyHandler().WriteIndexEntry(context, buffer, obj);
             }
         }
     }
     else
     {
         for (var i = 0; i < _count; i++)
         {
             if (ChildCanSupplyFirstKey(i))
             {
                 var child = (BTreeNode
                     ) _children[i];
                 var childKey = child.FirstKey(trans);
                 if (childKey != No4.Instance)
                 {
                     count++;
                     KeyHandler().WriteIndexEntry(context, buffer, childKey);
                     buffer.WriteIDOf(trans, child);
                 }
             }
             else
             {
                 count++;
                 KeyHandler().WriteIndexEntry(context, buffer, Key(i));
                 buffer.WriteIDOf(trans, _children[i]);
             }
         }
     }
     var endOffset = buffer._offset;
     buffer._offset = startOffset;
     buffer.WriteInt(count);
     buffer.WriteByte(_isLeaf ? (byte) 1 : (byte) 0);
     buffer.WriteInt(_parentID);
     buffer.WriteInt(_previousID);
     buffer.WriteInt(_nextID);
     buffer._offset = endOffset;
 }
コード例 #19
0
ファイル: ByteHandler.cs プロジェクト: pondyond/db4o
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     a_bytes.WriteByte(((byte)a_object));
 }
コード例 #20
0
ファイル: FieldMarshaller2.cs プロジェクト: masroore/db4o
 public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
     , ByteArrayBuffer writer)
 {
     writer.WriteByte(aspect.AspectType()._id);
     base.Write(trans, clazz, aspect, writer);
 }
コード例 #21
0
 public virtual void WriteByte(byte b)
 {
     _current.WriteByte(b);
 }
コード例 #22
0
ファイル: CharHandler.cs プロジェクト: masroore/db4o
 public override void Write(object a_object, ByteArrayBuffer a_bytes)
 {
     var char_ = ((char) a_object);
     a_bytes.WriteByte((byte) (char_ & unchecked(0xff)));
     a_bytes.WriteByte((byte) (char_ >> 8));
 }
コード例 #23
0
ファイル: BooleanHandler.cs プロジェクト: masroore/db4o
 public override void Write(object obj, ByteArrayBuffer buffer)
 {
     buffer.WriteByte(GetEncodedByteValue(obj));
 }