Clone() public method

public Clone ( ) : SNode
return SNode
Ejemplo n.º 1
0
        protected void ShareAdd(SNode obj)
        {
            if (ShareMap == null || ShareObj == null)
            {
                throw new ParseException("Uninitialized share");
            }
            if (ShareCursor >= ShareCount)
            {
                throw new ParseException("cursor out of range");
            }
            int shareid = ShareMap[ShareCursor];

            if (shareid > ShareCount)
            {
                throw new ParseException("shareid out of range");
            }


            ShareObj[shareid] = obj.Clone();

            ShareCursor++;
        }
Ejemplo n.º 2
0
        protected SNode GetDBRow()
        {
            SNode nhead = ParseOne();
            // get header
            SObject head = nhead as SObject;

            if (head == null)
            {
                throw new ParseException("The DBRow header isn't present...");
            }

            if (head.Name != "blue.DBRowDescriptor")
            {
                throw new ParseException("Bad descriptor name");
            }

            STuple fields = head.Members[0].Members[1].Members[0] as STuple;

            int len = GetLength();

            byte[] olddata = Reader.ReadBytes(len);

            List <byte> newdata = new List <byte>();

            rle_unpack(olddata, newdata);
            SNode body = new SDBRow(17, newdata);

            CacheFileReader blob = new CacheFileReader(newdata.ToArray());

            SDict dict = new SDict(999999);             // TODO: need dynamic sized dict
            int   step = 1;

            while (step < 6)
            {
                foreach (SNode field in fields.Members)
                {
                    SNode fieldName    = field.Members[0];
                    SInt  fieldType    = field.Members[1] as SInt;
                    int   fieldTypeInt = fieldType.Value;

                    byte  boolcount = 0;
                    byte  boolbuf   = 0;
                    SNode obj       = null;
                    switch (fieldTypeInt)
                    {
                    case 2:                             // 16bit int
                        if (step == 3)
                        {
                            obj = new SInt(blob.ReadShort());
                        }
                        break;

                    case 3:                             // 32bit int
                        if (step == 2)
                        {
                            obj = new SInt(blob.ReadInt());
                        }
                        break;

                    case 4:
                        obj = new SReal(blob.ReadFloat());
                        break;

                    case 5:                             // double
                        if (step == 1)
                        {
                            obj = new SReal(blob.ReadDouble());
                        }
                        break;

                    case 6:                             // currency
                        if (step == 1)
                        {
                            obj = new SLong(blob.ReadLong());
                        }
                        break;

                    case 11:                             // boolean
                        if (step == 5)
                        {
                            if (boolcount == 0)
                            {
                                boolbuf   = blob.ReadByte();
                                boolcount = 0x1;
                            }
                            if (boolbuf != 0 && boolcount != 0)
                            {
                                obj = new SInt(1);
                            }
                            else
                            {
                                obj = new SInt(0);
                            }
                            boolcount <<= 1;
                        }
                        break;

                    case 16:
                        obj = new SInt(blob.ReadByte());
                        break;

                    case 17:
                        goto case 16;

                    case 18:                             // 16bit int
                        goto case 2;

                    case 19:                             // 32bit int
                        goto case 3;

                    case 20:                             // 64bit int
                        goto case 6;

                    case 21:                             // 64bit int
                        goto case 6;

                    case 64:                             // timestamp
                        goto case 6;

                    case 128:                             // string types
                    case 129:
                    case 130:
                        obj = new SString("I can't parse strings yet - be patient");
                        break;

                    default:
                        throw new ParseException("Unhandled ADO type " + fieldTypeInt);
                    }

                    if (obj != null)
                    {
                        dict.AddMember(obj);
                        dict.AddMember(fieldName.Clone());
                    }
                }

                step++;
            }

            SNode fakerow = new STuple(3);

            fakerow.AddMember(head);
            fakerow.AddMember(body);
            fakerow.AddMember(dict);
            return(fakerow);
        }
Ejemplo n.º 3
0
		protected void ShareAdd(SNode obj)
		{
			if (ShareMap == null || ShareObj == null)
				throw new ParseException("Uninitialized share");
			if (ShareCursor >= ShareCount)
				throw new ParseException("cursor out of range");
			int shareid = ShareMap[ShareCursor];
			if (shareid > ShareCount)
				throw new ParseException("shareid out of range");

			
			ShareObj[shareid] = obj.Clone();

			ShareCursor++;
		}