public ILittleEndianOutput CreateDelayedOutput(int size) { CheckPosition(size); ILittleEndianOutput result = new LittleEndianByteArrayOutputStream(_buf, _writeIndex, size); _writeIndex += size; return(result); }
public override int Serialize(int offset, byte[] data) { ILittleEndianOutput leo = new LittleEndianByteArrayOutputStream(data, offset); ContinuableRecordOutput out1 = new ContinuableRecordOutput(leo, this.Sid); Serialize(out1); out1.Terminate(); return out1.TotalSize; }
public override byte[] GetBytes() { byte[] bytes = new byte[NPOI.SS.Util.CellRangeAddress.ENCODED_SIZE]; ILittleEndianOutput leo = new LittleEndianByteArrayOutputStream(bytes, 0); this.Record.Serialize(leo); return bytes; }
public override int Serialize(int offset, byte[] data) { int dataSize = DataSize; int recSize = 4 + dataSize; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize); out1.WriteShort(this.Sid); out1.WriteShort(dataSize); Serialize(out1); if (out1.WriteIndex - offset != recSize) { throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): " + "Incorrect number of bytes written - expected " + recSize + " but got " + (out1.WriteIndex - offset)); } return recSize; }
/** * Writes the ptgs to the data buffer, starting at the specified offset. * * <br/> * The 2 byte encode Length field is <b>not</b> written by this method. * @return number of bytes written */ public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset) { int size = ptgs.Length; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset); ArrayList arrayPtgs = null; for (int k = 0; k < size; k++) { Ptg ptg = ptgs[k]; ptg.Write(out1); if (ptg is ArrayPtg) { if (arrayPtgs == null) { arrayPtgs = new ArrayList(5); } arrayPtgs.Add(ptg); } } if (arrayPtgs != null) { for (int i = 0; i < arrayPtgs.Count; i++) { ArrayPtg p = (ArrayPtg)arrayPtgs[i]; p.WriteTokenValueBytes(out1); } } return out1.WriteIndex - offset; ; }
public override int Serialize(int offset, byte[] data) { LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset,this.RecordSize); int result=this.Serialize(out1); if (out1.WriteIndex - offset != this.RecordSize) { throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): " + "Incorrect number of bytes written - expected " + this.RecordSize + " but got " + (out1.WriteIndex - offset)); } return result; }
public override int Serialize(int offset, byte [] data) { int recSize = RecordSize; int dataSize = recSize - 4; LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize); out1.WriteShort(sid); out1.WriteShort(dataSize); if (_uninterpretedData == null) { for (int i = 0; i < subrecords.Count; i++) { SubRecord record = subrecords[i]; record.Serialize(out1); } int expectedEndIx = offset + dataSize; // padding while (out1.WriteIndex < expectedEndIx) { out1.WriteByte(0); } } else { out1.Write(_uninterpretedData); } return recSize; }
public ILittleEndianOutput CreateDelayedOutput(int size) { CheckPosition(size); ILittleEndianOutput result = new LittleEndianByteArrayOutputStream(_buf, _writeIndex, size); _writeIndex += size; return result; }
public void TestExtRstEqualsAndHashCode() { byte[] buf = new byte[200]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); String str = "\u1d02\u1d12\u1d22"; bos.WriteShort(1); bos.WriteShort(5 * LittleEndianConsts.SHORT_SIZE + str.Length * 2 + 3 * LittleEndianConsts.SHORT_SIZE + 2); // data size bos.WriteShort(0x4711); bos.WriteShort(0x0815); bos.WriteShort(1); bos.WriteShort(str.Length); bos.WriteShort(str.Length); StringUtil.PutUnicodeLE(str, bos); bos.WriteShort(1); bos.WriteShort(1); bos.WriteShort(3); bos.WriteShort(42); LittleEndianByteArrayInputStream in1 = new LittleEndianByteArrayInputStream(buf, 0, bos.WriteIndex); UnicodeString.ExtRst extRst1 = new UnicodeString.ExtRst(in1, bos.WriteIndex); in1 = new LittleEndianByteArrayInputStream(buf, 0, bos.WriteIndex); UnicodeString.ExtRst extRst2 = new UnicodeString.ExtRst(in1, bos.WriteIndex); Assert.AreEqual(extRst1, extRst2); Assert.AreEqual(extRst1.GetHashCode(), extRst2.GetHashCode()); }