Exemplo n.º 1
0
        private void P_EndBlock()
        {
            if (P_TableStack.Count > 0 | false)
            {
                P_ThrowError(1);
            }

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

            // Clear up broken business
            P_TableStack.Clear();
            P_ValueParser_StringMode   = false;
            P_EscapedInString          = 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;
        }
Exemplo n.º 2
0
        public static String EncodeTable(TableValue Value)
        {
            // Figure out how to turn the table into text
            TableDigested DigestedTable = Value.DigestTable();

            // Begin result bracket thing.
            StringBuilder Result = new StringBuilder("[");

            // Turn everything into text.
            foreach (var item in DigestedTable.AutoIntArray)
            {
                Result.Append(EncoderStream.EncodeValue(item));
                Result.Append(';');
            }
            foreach (var item in DigestedTable.ManualIntDictionary)
            {
                ValueBase v = item.Value;
                Result.Append(item.Key.ToString());
                Result.Append(':');
                Result.Append(EncoderStream.EncodeValue(v));
                Result.Append(';');
            }
            foreach (var item in DigestedTable.MiscKeyDictionary)
            {
                Result.Append(item.Key.EncodeIntoValue());
                Result.Append(':');
                ValueBase v = item.Value;
                Result.Append(EncoderStream.EncodeValue(v));
                Result.Append(';');
            }

            // Close the plain-text table and return it.
            Result.Append(']');
            return(Result.ToString());
        }
Exemplo n.º 3
0
        public TableValue ToTable()
        {
            TableValue Result = new TableValue();

            foreach (var item in ManualIntDictionary)
            {
                Result.Dictionary.Add(new IntValue(item.Key), item.Value);
            }
            // We only added manual integer entries yet, so we only need look at that table
            int CurrentInt = 0;

            foreach (var item in AutoIntArray)
            {
                CurrentInt++;

                ValueBase TryOutput = null;
                while (ManualIntDictionary.TryGetValue(CurrentInt, out TryOutput))
                {
                    CurrentInt++;
                }

                Result.Dictionary.Add(new IntValue(CurrentInt), item);
            }
            // We don't care about what these keys are, so we add them.
            foreach (var item in MiscKeyDictionary)
            {
                Result.Dictionary.Add(item.Key, item.Value);
            }

            return(Result);
        }
Exemplo n.º 4
0
        public bool Compare(TableValue OtherTable)
        {
            TableValue that = OtherTable; // It's weird to use this as a parameter name.

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

            // Store refs to save performance.
            Dictionary <ValueBase, ValueBase> ThisDictionary = this.Dictionary;
            Dictionary <ValueBase, ValueBase> ThatDictionary = that.Dictionary;

            // Compare the Tables!
            foreach (var item in ThisDictionary)
            {
                ValueBase v = null;
                if (!(ThatDictionary.TryGetValue(item.Key, out v) && v == item.Value))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        public static TableValue ArrayToTable(IEnumerable <ValueBase> array)
        {
            TableValue Result = new TableValue();
            int        i      = 0;
            Dictionary <ValueBase, ValueBase> ResultD = Result.Dictionary;

            foreach (ValueBase item in array)
            {
                i++;
                ResultD.Add(new IntValue(i), item);
            }
            return(Result);
        }