/// <summary> /// Checks relations. /// </summary> /// <param name="lObjectInterface">ObjectInterface.</param> /// <param name="NextElement">Next element we are going to parse.</param> /// <param name="CallCalback">Do we have to call callback?</param> /// <returns>FunctionIO with return parameters like ret value and parse count.</returns> public override FunctionIO CheckRelations(ref ObjectInterfacePrototipe lObjectInterface, ParserPrimitives NextElement, bool CallCalback) { ObjectAttributeEvaluation Evaluation = GetEvaluation(); bool More = true; int TotalMove = 0; int StartOffset = lObjectInterface.GetOffset(); bool eof = false; while (More) { int Positives = 0; int CurrentMove = 0; if (NextElement != null) { FunctionIO ret = NextElement.CheckRelations(ref lObjectInterface, NextElement.GetNextPrimitive(), false); if (ret["RetVal"].Value) break; } int RecallOffset = lObjectInterface.GetOffset(); List<ParserPrimitives> SubPrimitives = cParserObjectRelation.GetSubParserPrimitives(); for (int x = 0; x < SubPrimitives.Count; x++) { CurrentMove = 0; FunctionIO ret = SubPrimitives[x].CheckRelations(ref lObjectInterface, x + 1 == SubPrimitives.Count ? null : SubPrimitives[x + 1], false); if (ret["RetVal"].Value) { CurrentMove = ((ObjectAttributeEvaluation)ret["ParseCount"]).Value; Positives++; } else//End execution if we fail break; eof = lObjectInterface.MoveByOffset(CurrentMove); TotalMove += CurrentMove; if (eof) break; } if (CallCalback && Positives == SubPrimitives.Count) { lObjectInterface.SetOffset(RecallOffset); for (int x = 0; x < SubPrimitives.Count; x++) { CurrentMove = 0; FunctionIO ret = SubPrimitives[x].CheckRelations(ref lObjectInterface, x + 1 == SubPrimitives.Count ? null : SubPrimitives[x + 1], CallCalback); CurrentMove = ((ObjectAttributeEvaluation)ret["ParseCount"]).Value; eof = lObjectInterface.MoveByOffset(CurrentMove); } } if (eof || Positives != SubPrimitives.Count) { break; } } if (!Evaluation.Evaluate(TotalMove)) return new FunctionIO(RetVal.False); lObjectInterface.SetOffset(StartOffset); return new FunctionIO(Evaluation, RetVal.True); }
public override FunctionIO CheckRelations(ref ObjectInterfacePrototipe lObjectInterface, ParserPrimitives NextElement, bool CallCalback) { FunctionIO ReturnContainer = new FunctionIO(); ObjectAttributeInt ReturnValue1 = new ObjectAttributeInt("ret", 1); ObjectAttributeInt ReturnValue0 = new ObjectAttributeInt("ret", 0); ObjectAttributeEvaluation Evaluation = null; if (cFunctionParameters == null || cFunctionParameters.GetFunctionParameterByName("ParseCount") == null) { Evaluation = new ObjectAttributeEvaluation(); Evaluation.SetAttributeName("ParseCount"); } else Evaluation = (ObjectAttributeEvaluation)cFunctionParameters.GetFunctionParameterByName("ParseCount"); bool More = true; int TotalMove= 0; int StartOffset = lObjectInterface.GetOffset(); bool eof = false; while (More) { int Positives = 0; int CurrentMove = 0; if (NextElement != null) { FunctionIO ret = NextElement.CheckRelations(ref lObjectInterface, NextElement.GetNextPrimitive(), false); if (((ObjectAttributeInt)ret.GetFunctionParameterByName("ret")).GetAttributeValue() == 1) { break; } } List<ParserPrimitives> SubPrimitives = cParserObjectRelation.GetSubParserPrimitives(); for (int x = 0; x < SubPrimitives.Count; x++) { ParserPrimitives tPrimitives; if (SubPrimitives.Count == x + 1) tPrimitives = null; else tPrimitives = SubPrimitives[x + 1]; FunctionIO ret = SubPrimitives[x].CheckRelations(ref lObjectInterface, tPrimitives, CallCalback); if (((ObjectAttributeInt)ret.GetFunctionParameterByName("ret")).GetAttributeValue() == 1) { CurrentMove += ((ObjectAttributeEvaluation)ret.GetFunctionParameterByName("ParseCount")).GetEvaluationValue(); Positives++; } eof=lObjectInterface.MoveByOffset(CurrentMove); } TotalMove += CurrentMove; if (Positives != SubPrimitives.Count || eof) { More = false; } } if (!Evaluation.EvaluateNext(TotalMove)) { ReturnContainer.AddFunctionParameter((ObjectAttribute)ReturnValue0); return ReturnContainer; } lObjectInterface.SetOffset(StartOffset); ReturnContainer.AddFunctionParameter(Evaluation); ReturnContainer.AddFunctionParameter((ObjectAttribute)ReturnValue1); return ReturnContainer; }