Exemplo n.º 1
0
		public virtual void ReadTypeInfo(Transaction trans, IReadBuffer buffer, ArrayInfo
			 info, int classID)
		{
			BitMap4 typeInfoBitmap = new BitMap4(buffer.ReadByte());
			info.Primitive(typeInfoBitmap.IsTrue(0));
			info.Nullable(typeInfoBitmap.IsTrue(1));
		}
Exemplo n.º 2
0
		public virtual void WriteTypeInfo(IWriteContext context, ArrayInfo info)
		{
			BitMap4 typeInfoBitmap = new BitMap4(2);
			typeInfoBitmap.Set(0, info.Primitive());
			typeInfoBitmap.Set(1, info.Nullable());
			context.WriteByte(typeInfoBitmap.GetByte(0));
		}
Exemplo n.º 3
0
 private void TBit(BitMap4 map, int bit)
 {
     map.SetTrue(bit);
     Assert.IsTrue(map.IsTrue(bit));
     map.SetFalse(bit);
     Assert.IsFalse(map.IsTrue(bit));
     map.SetTrue(bit);
     Assert.IsTrue(map.IsTrue(bit));
 }
Exemplo n.º 4
0
		public RawFieldSpec(AspectType aspectType, string name, int fieldTypeID, byte attribs
			)
		{
			_type = aspectType;
			_name = name;
			_fieldTypeID = fieldTypeID;
			BitMap4 bitmap = new BitMap4(attribs);
			_isPrimitive = bitmap.IsTrue(0);
			_isArray = bitmap.IsTrue(1);
			_isNArray = bitmap.IsTrue(2);
			_isVirtual = false;
			_indexID = 0;
		}
Exemplo n.º 5
0
		public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference
			 @ref, IUpdateDepth updateDepth, bool isNew)
		{
			// YapClass ID
			// Marshaller Version
			// number of fields
			_transaction = trans;
			_reference = @ref;
			_nullBitMap = new BitMap4(AspectCount());
			_updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth);
			_isNew = isNew;
			_writeBuffer = new MarshallingBuffer();
			_currentBuffer = _writeBuffer;
		}
Exemplo n.º 6
0
 public virtual void Test()
 {
     var buffer = new byte[100];
     for (var i = 0; i < 17; i++)
     {
         var map = new BitMap4(i);
         map.WriteTo(buffer, 11);
         var reReadMap = new BitMap4(buffer, 11, i);
         for (var j = 0; j < i; j++)
         {
             TBit(map, j);
             TBit(reReadMap, j);
         }
     }
 }
Exemplo n.º 7
0
		public virtual void Test()
		{
			byte[] buffer = new byte[100];
			for (int i = 0; i < 17; i++)
			{
				BitMap4 map = new BitMap4(i);
				map.WriteTo(buffer, 11);
				BitMap4 reReadMap = new BitMap4(buffer, 11, i);
				for (int j = 0; j < i; j++)
				{
					TBit(map, j);
					TBit(reReadMap, j);
				}
			}
		}
Exemplo n.º 8
0
		public virtual BitMap4 ReadBitMap(int bitCount)
		{
			BitMap4 map = new BitMap4(_buffer, _offset, bitCount);
			_offset += map.MarshalledLength();
			return map;
		}
Exemplo n.º 9
0
		public void WriteBitMap(BitMap4 nullBitMap)
		{
			nullBitMap.WriteTo(_buffer, _offset);
			_offset += nullBitMap.MarshalledLength();
		}
Exemplo n.º 10
0
		public ObjectHeaderAttributes(ByteArrayBuffer reader)
		{
			_fieldCount = reader.ReadInt();
			_nullBitMap = reader.ReadBitMap(_fieldCount);
		}
Exemplo n.º 11
0
		protected virtual BitMap4 NullItemsMap(IReflectArray reflector, object array)
		{
			int arrayLength = reflector.GetLength(array);
			BitMap4 nullBitMap = new BitMap4(arrayLength);
			for (int i = 0; i < arrayLength; i++)
			{
				if (reflector.Get(array, i) == null)
				{
					nullBitMap.Set(i, true);
				}
			}
			return nullBitMap;
		}
Exemplo n.º 12
0
		private void WriteNullBitmap(IWriteBuffer context, BitMap4 bitMap)
		{
			context.WriteBytes(bitMap.Bytes());
		}
Exemplo n.º 13
0
		private int ReducedCountForNullBitMap(int count, BitMap4 bitMap)
		{
			int nullCount = 0;
			for (int i = 0; i < count; i++)
			{
				if (bitMap.IsTrue(i))
				{
					nullCount++;
				}
			}
			return nullCount;
		}
Exemplo n.º 14
0
		public virtual BitMap4 ReadBitMap(int bitCount)
		{
			BitMap4 map = new BitMap4(_current._buffer, _current._offset, bitCount);
			_current.Seek(_current.Offset() + map.MarshalledLength());
			return map;
		}
Exemplo n.º 15
0
		public override void Write(Transaction trans, ClassMetadata clazz, ClassAspect aspect
			, ByteArrayBuffer writer)
		{
			writer.WriteShortString(trans, aspect.GetName());
			if (!(aspect is FieldMetadata))
			{
				return;
			}
			FieldMetadata field = (FieldMetadata)aspect;
			field.Alive();
			if (field.IsVirtual())
			{
				return;
			}
			ITypeHandler4 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());
			BitMap4 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));
		}
Exemplo n.º 16
0
 protected override void WriteElements(IWriteContext context, object obj, ArrayInfo
     info)
 {
     var objects = AllElements(Container(context), obj);
     if (HasNullBitmap(info))
     {
         var nullBitMap = new BitMap4(info.ElementCount());
         var nullBitMapBuffer = context.Reserve(nullBitMap.MarshalledLength());
         var currentElement = 0;
         while (objects.MoveNext())
         {
             var current = objects.Current;
             if (current == null)
             {
                 nullBitMap.SetTrue(currentElement);
             }
             else
             {
                 context.WriteObject(DelegateTypeHandler(), current);
             }
             currentElement++;
         }
         nullBitMapBuffer.WriteBytes(nullBitMap.Bytes());
     }
     else
     {
         while (objects.MoveNext())
         {
             context.WriteObject(DelegateTypeHandler(), objects.Current);
         }
     }
 }