public StringIdDesc(GenerateIdMethod method, int index_bit_count, int set_bit_count, int length_bit_count) { //Contract.Requires(ValidateIndexBitCount(index_bit_count)); //Contract.Requires(ValidateSetBitCount(set_bit_count)); //Contract.Requires(ValidateLengthBitCount(length_bit_count)); mHandle = 0; // satisfy the compiler, this must come first so we don't f**k up the values Initialize(method, index_bit_count, set_bit_count, length_bit_count); }
void Initialize(GenerateIdMethod method, int index_bc, int set_bc, int length_bc) { var encoder = new HandleBitEncoder(); encoder.Encode32((uint)index_bc, kIndexMask); encoder.Encode32((uint)set_bc, kSetMask); encoder.Encode32((uint)length_bc, kLengthMask); { uint index = 0; encoder.Encode32(index, kSidIndexBitIndexMask); index += (uint)index_bc; encoder.Encode32(index, kSidSetBitIndexMask); index += (uint)set_bc; encoder.Encode32(index, kSidLengthBitIndexMask); } encoder.Encode32(method, TypeExtensions.BitEncoders.GenerateIdMethod); mHandle = encoder.GetHandle32(); }
public static void Serialize(IO.XmlStream s /*, System.IO.FileAccess stream_mode*/, ref StringIdDesc desc) { int index_bc = desc.IndexBitCount; int set_bc = desc.SetBitCount; int length_bc = desc.LengthBitCount; GenerateIdMethod method = desc.Method; s.ReadAttribute("method", ref method); s.ReadAttribute("indexBitCount", 10, ref index_bc); s.ReadAttribute("setBitCount", 10, ref set_bc); s.ReadAttribute("lengthBitCount", 10, ref length_bc); //if (stream_mode == System.IO.FileAccess.Read) { //Contract.Assert(ValidateIndexBitCount(index_bc)); //Contract.Assert(ValidateSetBitCount(set_bc)); //Contract.Assert(ValidateLengthBitCount(length_bc)); desc = new StringIdDesc(method, index_bc, set_bc, length_bc); } }