//appendVPack(VPackSlice value) void AppendVPack(VPackSlice value) { byte[] vpack = value.GetRawVPack(); EnsureCapacity(size + vpack.Length); System.Buffer.BlockCopy(vpack, 0, buffer, size, vpack.Length); size += vpack.Length; }
public override bool Equals(object obj) { if (this == obj) { return(true); } if (obj == null) { return(false); } if (GetType() != obj.GetType()) { return(false); } VPackSlice other = (VPackSlice)obj; if (start != other.start) { return(false); } if (!GetRawVPack().SequenceEqual(other.GetRawVPack())) { return(false); } return(true); }
VPackBuilder WrapAdd(string attribute, object value, Action append) { if (attribute != null) { bool haveReported = false; if (stack.Count != 0) { byte head = Head(); if (head != 0x0b && head != 0x14) { throw new VPackBuilderNeedOpenObjectException(); } if (keyWritten) { throw new VPackBuilderKeyAlreadyWrittenException(); } ReportAdd(); haveReported = true; } try { if (VelocyPack.VPackSlice.attributeTranslator != null) { VPackSlice translate = VelocyPack.VPackSlice.attributeTranslator.Translate(attribute); if (translate != null) { byte[] trValue = translate.GetRawVPack(); EnsureCapacity(size + trValue.Length); for (int i = 0; i < trValue.Length; i++) { WriteUnchecked(trValue[i]); } keyWritten = true; if (value == null) { AppendNull(); } else { append(); } return(this); } // otherwise fall through to regular behavior } AppendString(attribute); keyWritten = true; if (value == null) { AppendNull(); } else { append(); } } catch (VPackBuilderException e) { // clean up in case of an exception if (haveReported) { CleanupAdd(); } throw e; } finally { keyWritten = false; } } else { WrapAdd(value, append); } return(this); }