Esempio n. 1
0
        public static string EncodeTable(TableValue Table)
        {
            StringBuilder r = new StringBuilder();

            // Turn everything into text.
            r.Append('[');
            List <IAbstractValue> processedKeys = new List <IAbstractValue>();

            for (int i = 1; Table.ContainsKey(i); i++)
            {
                IAbstractValue item = Table[i];
                r.Append(EncoderStream.EncodeValue(item));
                r.Append(';');
                processedKeys.Add(new IntValue(i));
                item = null;
            }
            foreach (KeyValuePair <IAbstractValue, IAbstractValue> item2 in Table.Dictionary)
            {
                if (!processedKeys.Contains(item2.Key))
                {
                    r.Append(item2.Key.EncodeIntoValue());
                    r.Append(':');
                    IAbstractValue v = item2.Value;
                    r.Append(EncoderStream.EncodeValue(v));
                    r.Append(';');
                }
            }
            r.Append(']');

            return(r.ToString());
        }
Esempio n. 2
0
        private void P_EndBlock()
        {
            if (P_TableStack.Count > 0)
            {
                P_ThrowError(1);
            }

            // Output
            if (P_ErrorCode == 0)
            {
                _output.Add(P_ValueParser_TakeValue());
            }
            else
            {
                TableValue TableResult = new TableValue();
                TableResult[1] = new StringValue("Error");
                TableResult[2] = new IntValue(P_ErrorCode);
                _output.Add(TableResult);
            }

            // Clear up broken business
            P_TableStack.Clear();
            P_ValueParser_StringMode   = false;
            P_CharEscapedInString      = false;
            P_ValueParser_ValueAtReady = null;
            P_ValueParser_ValueRaw.Clear();
            P_ValueParser_ValueType = -1;

            P_ErrorCode = 0;

            // Purge the last block from the input stream to save memory.
            _input     = _input.Substring(P_Position);
            P_Position = 0;
        }
Esempio n. 3
0
        public bool Compare(TableValue OtherTable)
        {
            TableValue that = OtherTable; // It's weird to use this as a parameter name.

            // Figure out whether they match in size. If it's not, immediate false.
            if (this.Dictionary.Count != that.Dictionary.Count)
            {
                return(false);
            }

            // Compare the Tables!
            foreach (KeyValuePair <IAbstractValue, IAbstractValue> item in this.Dictionary)
            {
                IAbstractValue v = null;
                if (!(that.Dictionary.TryGetValue(item.Key, out v) && v == item.Value)) // Out v?
                {
                    return(false);
                }
            }
            return(true);
        }