예제 #1
0
        public void CheckDeletedKeys(DeleteChecker deleteChecker)
        {
            Prepare();

            if (clear)
            {
                UnaryTable.Iter it = table.GetIter();
                while (!it.Done())
                {
                    int surr = it.Get();
                    if (Array.SortedArrayContains(insertList, insertCount, surr))
                    {
                        deleteChecker.WasDeleted(surr);
                    }
                    it.Next();
                }
            }
            else
            {
                for (int i = 0; i < deleteCount; i++)
                {
                    int surr = deleteList[i];
                    if (Array.SortedArrayContains(insertList, insertCount, surr))
                    {
                        deleteChecker.WasDeleted(surr);
                    }
                }
            }
        }
예제 #2
0
        public static void Write(DataWriter writer, int fieldSymbId, UnaryTable[] tables, int indentation, bool indentFirstLine, bool writeSeparator)
        {
            string baseWs  = new string(Array.Repeat(' ', indentation));
            string entryWs = new string(Array.Repeat(' ', indentation + 2));

            int count = 0;

            for (int i = 0; i < tables.Length; i++)
            {
                count += tables[i].Size();
            }

            if (indentFirstLine)
            {
                writer.Write(baseWs);
            }
            writer.Write(SymbObj.IdxToStr(fieldSymbId));
            writer.Write(": [");

            if (count > 0)
            {
                writer.Write("\n");

                int written = 0;
                for (int i = 0; i < tables.Length; i++)
                {
                    UnaryTable      table  = tables[i];
                    SurrObjMapper   mapper = table.mapper;
                    UnaryTable.Iter it     = table.GetIter();
                    while (!it.Done())
                    {
                        writer.Write(entryWs);
                        Obj obj = mapper(it.Get());
                        ObjPrinter.PrintNoFlush(obj, writer);
                        written++;
                        writer.Write(written < count ? ",\n" : "\n");
                        it.Next();
                    }
                }
                Debug.Assert(written == count);

                writer.Write(baseWs);
            }

            writer.Write(writeSeparator ? "],\n" : "]\n");
        }
예제 #3
0
        private void CheckTargetClear()
        {
            Debug.Assert(target.WasCleared());

            if (source.clear)
            {
                return;
            }

            UnaryTable.Iter it = source.table.GetIter();
            while (!it.Done())
            {
                int elt = it.Get();
                if (source.Contains(elt) && !target.Contains1(elt))
                {
                    throw DeletionForeignKeyViolationException(elt, target.AnyDeletedArg2(elt));
                }
                it.Next();
            }
        }