public ushort IndexToID(uint Index) { CSmartValue Value = new CSmartValue(); if (m_pData == null) { return(0); } uint HeadIndex = m_StartIndex; uint TailIndex = m_StartIndex + GetDataLen(); ushort MemberID = 0; HeadIndex += sizeof(byte) + sizeof(uint); while (HeadIndex + sizeof(ushort) < TailIndex) { MemberID = BitConverter.ToUInt16(m_pData, (int)HeadIndex); if (Index == 0) { return(MemberID); } HeadIndex += sizeof(ushort); if (!Value.Attach(m_pData, HeadIndex, TailIndex - HeadIndex, CSmartValue.SMART_VALUE_TYPE.VT_UNKNOWN)) { break; } HeadIndex += Value.GetDataLen(); Index--; } return(0); }
public CSmartValue GetMemberByIndex(uint Index) { CSmartValue Value = new CSmartValue(); if (m_pData == null) { return(Value); } uint HeadIndex = m_StartIndex; uint TailIndex = m_StartIndex + GetDataLen(); HeadIndex += sizeof(byte) + sizeof(uint); while (HeadIndex + sizeof(ushort) < TailIndex) { HeadIndex += sizeof(ushort); if (!Value.Attach(m_pData, HeadIndex, TailIndex - HeadIndex, CSmartValue.SMART_VALUE_TYPE.VT_UNKNOWN)) { break; } HeadIndex += Value.GetDataLen(); if (Index == 0) { return(Value); } Index--; } Value.Destory(); return(Value); }
public CSmartValue GetMember(ushort ID) { CSmartValue Value = new CSmartValue(); if (m_pData == null) { return(Value); } uint HeadIndex = m_StartIndex; uint TailIndex = m_StartIndex + GetDataLen(); HeadIndex += sizeof(byte) + sizeof(uint); while (HeadIndex + sizeof(ushort) < TailIndex) { ushort MemberID = BitConverter.ToUInt16(m_pData, (int)HeadIndex); HeadIndex += sizeof(ushort); if (!Value.Attach(m_pData, HeadIndex, TailIndex - HeadIndex, CSmartValue.SMART_VALUE_TYPE.VT_UNKNOWN)) { break; } if (MemberID == ID) { return(Value); } HeadIndex += Value.GetDataLen(); } Value.Destory(); return(Value); }
public bool AddMember(ushort ID, CSmartValue Value) { uint BufferSize = 0; int StartIndex = PrepareMember(ref BufferSize); if (StartIndex >= 0) { CSmartValue SmartValue = new CSmartValue(); if (SmartValue.Attach(m_pData, (uint)StartIndex, BufferSize, CSmartValue.SMART_VALUE_TYPE.VT_STRUCT)) { if (SmartValue.SetValue(Value)) { return(FinishMember(ID, SmartValue.GetDataLen())); } } } return(false); }
public CSmartValue GetNextMember(ref int Pos, ref ushort MemberID) { CSmartValue Value = new CSmartValue(); if (m_pData == null) { Pos = 0; return(Value); } if (Pos != 0) { uint HeadIndex = (uint)Pos; uint TailIndex = m_StartIndex + GetDataLen(); MemberID = BitConverter.ToUInt16(m_pData, (int)HeadIndex); HeadIndex += sizeof(ushort); if (HeadIndex >= TailIndex) { Pos = 0; } else { if (!Value.Attach(m_pData, HeadIndex, TailIndex - HeadIndex, CSmartValue.SMART_VALUE_TYPE.VT_UNKNOWN)) { Pos = 0; return(Value); } Pos = (int)(HeadIndex + Value.GetDataLen()); if (Pos >= (int)TailIndex) { Pos = 0; } } } return(Value); }