Plasma.plVarDescriptor.Read C# (CSharp) Method

Read() public method

public Read ( Plasma.hsStream s ) : void
s Plasma.hsStream
return void
        public virtual void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad VarDescriptor IO Version");

            fName = s.ReadSafeString();
            string displayOptions = s.ReadStdString(); // TODO
            fCount = s.ReadInt();
            fType = (plAtomicType)s.ReadByte();
            Default = s.ReadSafeString();
            fFlags = (Flags)s.ReadInt();

            // Derived class in Cyan's code, but this is cleaner
            if (IsStateDesc) {
                fDescName = s.ReadSafeString();
                fVersion = (int)s.ReadShort();
            } else {
                fAtomicCount = (int)s.ReadShort();
                fAtomicType = (plAtomicType)s.ReadByte();
            }
        }

Usage Example

Example #1
0
        public void Read(hsStream s)
        {
            if (s.ReadByte() != kIoVersion)
                throw new NotSupportedException("Bad StateDescriptor IO Version");

            fName = s.ReadSafeString();
            fVersion = (int)s.ReadShort();

            short count = s.ReadShort();
            fVariables.Capacity = count; // Optimization
            for (short i = 0; i < count; i++) {
                plVarDescriptor var = new plVarDescriptor(s.ReadBool()
                    ? plAtomicType.kStateDescriptor : plAtomicType.kNone);
                var.Read(s);
                fVariables.Add(var);
            }
        }