/*- * See the file LICENSE for redistribution information. * * Copyright (c) 2009 Oracle. All rights reserved. * */ using System; using System.Collections; using System.Collections.Generic; using System.Text; namespace BerkeleyDB { /// /// A class providing access to multiple /// objects. /// public class MultipleDatabaseEntry : IEnumerable { private byte[] data; private uint ulen; internal MultipleDatabaseEntry(DatabaseEntry dbt) { data = dbt.UserData; ulen = dbt.ulen; } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return an enumerator which iterates over all /// objects represented by the /// . /// /// /// An enumerator for the /// public IEnumerator GetEnumerator() { uint pos = ulen - 4; int off = BitConverter.ToInt32(data, (int)pos); for (int i = 0; off >= 0; off = BitConverter.ToInt32(data, (int)pos), i++) { pos -= 4; int sz = BitConverter.ToInt32(data, (int)pos); byte[] arr = new byte[sz]; Array.Copy(data, off, arr, 0, sz); pos -= 4; yield return new DatabaseEntry(arr); } } // public byte[][] Data; /* No Public Constructor */ //internal MultipleDatabaseEntry(DatabaseEntry dbt) { // byte[] dat = dbt.UserData; // List tmp = new List(); // uint pos = dbt.ulen - 4; // int off = BitConverter.ToInt32(dat, (int)pos); // for (int i = 0; off > 0; off = BitConverter.ToInt32(dat, (int)pos), i++) { // pos -= 4; // int sz = BitConverter.ToInt32(dat, (int)pos); // tmp.Add(new byte[sz]); // Array.Copy(dat, off, tmp[i], 0, sz); // pos -= 4; // } // Data = tmp.ToArray(); //} } }