Ejemplo n.º 1
0
        // 書き出す
        public void WriteToBuf(Buf b)
        {
            // 名前
            b.WriteStr(this.name, true);

            // 種類
            b.WriteInt((uint)this.type);

            // 項目数
            b.WriteInt(this.Count);

            // 値
            uint i;

            if (this.Count > Pack.MaxValueNum)
            {
                throw new OverflowException();
            }
            for (i = 0; i < this.Count; i++)
            {
                PackValue v = this.GetValue(i) !;

                v.WriteToBuf(b, this.type);
            }
        }
Ejemplo n.º 2
0
        // 読み込む
        public static PackElement CreateFromBuf(Buf b)
        {
            // 名前
            string name = b.ReadStr(true);

            // 種類
            PackValueType type = (PackValueType)b.ReadInt();

            // 項目数
            uint num = b.ReadInt();

            PackElement e = new PackElement(name, type);

            // 値
            uint i;

            for (i = 0; i < num; i++)
            {
                PackValue v = PackValue.CreateFromBuf(b, i, type) !;

                e.AddValue(v);
            }

            return(e);
        }
Ejemplo n.º 3
0
 public PackValue?GetValue(uint index, out bool exists)
 {
     if (values.ContainsKey(index) == false)
     {
         exists = false;
         return(PackValue.GetDefaultValue(index, this.type));
     }
     else
     {
         exists = true;
         return(values[index]);
     }
 }
Ejemplo n.º 4
0
        // 値の追加
        public void AddValue(PackValue value)
        {
            bool      exists;
            PackValue?existValue = GetValue(value.Index, out exists);

            if (exists)
            {
                values.Remove(value.Index);
            }

            values.Add(value.Index, value);

            if (maxIndex < value.Index)
            {
                maxIndex = value.Index;
            }
        }
Ejemplo n.º 5
0
        object data;            // データ

        // 比較
        int IComparable.CompareTo(object?obj)
        {
            PackValue v = (PackValue)obj !;

            return(this.index.CompareTo(v.index));
        }