internal void BeginNestedType(string typeName) { IfcType ifcType = IfcMetaData.IfcType(typeName); _currentInstance = new Part21Entity((IPersistIfc)Activator.CreateInstance(ifcType.Type)); _processStack.Push(_currentInstance); }
public XbimParserState(IPersistEntity entity, ILogger logger = null) { _logger = logger ?? XbimLogging.CreateLogger <EsentModel>(); _currentInstance = new Part21Entity(entity); _processStack.Push(_currentInstance); _metadata = entity.Model.Metadata; }
protected override void EndEntity() { // Check if stack is empty to avoid exception if (0 == _processStack.Count) { Logger.LogError("Stack is empty"); return; } var p21 = _processStack.Pop(); //Debug.Assert(_processStack.Count == 0); CurrentInstance = null; if (p21.Entity != null) { try { _entities.Add(p21.EntityLabel, p21.Entity); } catch (Exception ex) { var msg = string.Format("Duplicate entity label: #{0}", p21.EntityLabel); Logger?.LogError(msg, ex); } } // Console.WriteLine("EndEntity - " + CurrentSemanticValue.strVal); }
public XbimParserState(IPersistEntity entity, ILogger logger = null) { _currentInstance = new Part21Entity(entity); _processStack.Push(_currentInstance); _logger = logger; _metadata = entity.Model.Metadata; }
protected override void EndHeaderEntity() { _processStack.Pop(); CurrentInstance = null; // Console.WriteLine("EndHeaderEntity - " + CurrentSemanticValue.strVal); }
protected override void NewEntity(string entityLabel) { CurrentInstance = new Part21Entity(entityLabel); // Console.WriteLine(CurrentSemanticValue.strVal); _processStack.Push(CurrentInstance); if (_streamSize == -1 || ProgressStatus == null) { return; } var sc = (Scanner)Scanner; double pos = sc.Buffer.Pos; var newPercentage = Convert.ToInt32(pos / _streamSize * 100.0); if (newPercentage <= _percentageParsed) { return; } _percentageParsed = newPercentage; ProgressStatus(_percentageParsed, "Parsing"); if (Cancel) { YYAccept(); } }
protected void EndEntity() { var p21 = _processStack.Pop(); //Debug.Assert(_processStack.Count == 0); CurrentInstance = null; if (!_inHeader && p21.Entity != null) { try { Entities.Add(p21.EntityLabel, p21.Entity); } catch (ArgumentException) { var exist = Entities[p21.EntityLabel]; var existType = exist.GetType().Name.ToUpperInvariant(); var duplType = p21.Entity.GetType().Name.ToUpperInvariant(); if (!string.Equals(existType, duplType, StringComparison.Ordinal)) { Logger?.LogError(LogEventIds.FailedEntity, $"Duplicate entity label #{p21.EntityLabel} with different types: ({existType}/{duplType})"); ErrorCount++; } else { Logger?.LogWarning(LogEventIds.FailedEntity, $"Duplicate entity label #{p21.EntityLabel}={existType}"); } } } }
protected override void NewEntity(string entityLabel) { _currentInstance = new Part21Entity(entityLabel); _processStack.Push(_currentInstance); _entityCount++; _indexKeyValues.Clear(); _currentLabel = Convert.ToInt32(entityLabel.TrimStart('#')); var data = _binaryWriter.BaseStream as MemoryStream; if (data != null) { data.SetLength(0); } if (_streamSize == -1 || ProgressStatus == null) { return; } var sc = (Scanner)Scanner; double pos = sc.Buffer.Pos; var newPercentage = Convert.ToInt32(pos / _streamSize * 100.0); if (newPercentage <= _percentageParsed) { return; } _percentageParsed = newPercentage; ProgressStatus(_percentageParsed, "Parsing"); }
protected override void SetType(string entityTypeName) { if (InHeader) { int[] reqParams; // instantiates an empty IPersist from the header information var t = EntityCreate(entityTypeName, null, InHeader, out reqParams); // then attaches it to a new Part21Entity, this will be processed later from the _processStack // to debug value initialisation place a breakpoint on the Parse() function of // StepFileName, StepFileSchema or StepFileDescription classes. CurrentInstance = new Part21Entity(t) { RequiredParameters = reqParams }; if (CurrentInstance != null) { _processStack.Push(CurrentInstance); } } else { var p21 = _processStack.Peek(); int[] reqProps; p21.Entity = EntityCreate(entityTypeName, p21.EntityLabel, InHeader, out reqProps); p21.RequiredParameters = reqProps; } if (Cancel) { YYAccept(); } }
internal void BeginNestedType(string typeName) { var type = _metadata.ExpressType(typeName); _currentInstance = new Part21Entity((IPersist)Activator.CreateInstance(type.Type)); _processStack.Push(_currentInstance); }
public void EndList() { _listNestLevel--; Part21Entity p21 = _processStack.Peek(); p21.CurrentParamIndex++; //Console.WriteLine("EndList"); }
internal void EndNestedType() { _propertyValue.Init(_processStack.Pop().Entity); _currentInstance = _processStack.Peek(); if (_currentInstance.Entity != null) _currentInstance.ParameterSetter(_currentInstance.CurrentParamIndex, _propertyValue); if (_listNestLevel == 0) _currentInstance.CurrentParamIndex++; }
protected void BeginNestedType(string value) { if (EntityCreate != null) { CurrentInstance = new Part21Entity(EntityCreate(value, null, _inHeader)); } _processStack.Push(CurrentInstance); _isInNestedType = true; }
public void BeginList() { Part21Entity p21 = _processStack.Peek(); if (p21.CurrentParamIndex == -1) { p21.CurrentParamIndex++; //first time in take the first argument } _listNestLevel++; }
protected override void BeginNestedType(string value) { if (EntityCreate != null) { CurrentInstance = new Part21Entity(EntityCreate(value, null, InHeader, out int[] reqProps)); } _processStack.Push(CurrentInstance); if (Cancel) { YYAccept(); } }
internal void EndNestedType() { _propertyValue.Init(_processStack.Pop().Entity); _currentInstance = _processStack.Peek(); if (_currentInstance.Entity != null) { _currentInstance.ParameterSetter(_currentInstance.CurrentParamIndex, _propertyValue); } if (_listNestLevel == 0) { _currentInstance.CurrentParamIndex++; } }
protected override void EndEntity() { var p21 = _processStack.Pop(); //Debug.Assert(_processStack.Count == 0); CurrentInstance = null; if (p21.Entity != null) { _entities.Add(p21.EntityLabel, p21.Entity); } // Console.WriteLine("EndEntity - " + CurrentSemanticValue.strVal); }
protected void EndEntity() { var p21 = _processStack.Pop(); //Debug.Assert(_processStack.Count == 0); CurrentInstance = null; if (!_inHeader && p21.Entity != null) { try { _entities.Add(p21.EntityLabel, p21.Entity); } catch (Exception) { Logger?.LogError(LogEventIds.FailedEntity, $"Duplicate entity label: #{p21.EntityLabel}"); ErrorCount++; } } }
protected override void EndEntity() { var p21 = _processStack.Pop(); Debug.Assert(_processStack.Count == 0); _currentInstance = null; if (_currentType != null) { _binaryWriter.Write((byte)P21ParseAction.EndEntity); var type = _modelCache.Model.Metadata.ExpressType(_currentType); var data = _binaryWriter.BaseStream as MemoryStream; var bytes = data.ToArray(); var keys = new List <int>(_indexKeyValues); _toStore.Add(new Tuple <int, short, List <int>, byte[], bool>(_currentLabel, type.TypeId, keys, bytes, type.IndexedClass)); if (this._modelCache.IsCaching) { _toProcess.Add(new Tuple <int, Type, byte[]>(_currentLabel, type.Type, bytes)); } } }
protected bool SetType(string entityTypeName) { try { if (_inHeader) { // instantiates an empty IPersist from the header information var t = EntityCreate(entityTypeName, null, _inHeader); // then attaches it to a new Part21Entity, this will be processed later from the _processStack // to debug value initialisation place a breakpoint on the Parse() function of // StepFileName, StepFileSchema or StepFileDescription classes. CurrentInstance = new Part21Entity(t); if (CurrentInstance != null) { _processStack.Push(CurrentInstance); } } else { if (ListNestLevel == -1) { var p21 = _processStack.Peek(); p21.Entity = EntityCreate(entityTypeName, p21.EntityLabel, _inHeader); } else { BeginNestedType(entityTypeName); } } return(true); } catch (Exception e) { if (_errors.AddTypeNotCreated(entityTypeName)) { Logger?.LogError(LogEventIds.FailedEntity, e, $"Could not create type {entityTypeName}"); ErrorCount++; } return(false); } }
private void NewEntity(int entityLabel) { CurrentInstance = new Part21Entity(entityLabel); // Console.WriteLine(CurrentSemanticValue.strVal); _processStack.Push(CurrentInstance); if (_streamSize < 0 || _progressStatus == null) { return; } if (_reportEntityCount++ < 500) { return; } double pos = _scanner.Buffer.Pos; var percentage = Convert.ToInt32(pos / _streamSize * 100.0); _reportEntityCount = 0; _progressStatus?.Invoke(percentage, "Parsing"); }
protected void EndNestedType() { _isInNestedType = false; try { PropertyValue.Init(_processStack.Pop().Entity); CurrentInstance = _processStack.Peek(); if (CurrentInstance.Entity != null) { CurrentInstance.Entity.Parse(CurrentInstance.CurrentParamIndex, PropertyValue, NestedIndex); } } catch (Exception e) { // return silently if this kind of error has already been reported if (!_errors.AddPropertyNotSet(CurrentInstance.Entity, CurrentInstance.CurrentParamIndex, PropertyValue, e)) { return; } var mainEntity = _processStack.Last(); if (mainEntity != null) { Logger?.LogError(LogEventIds.FailedEntity, e, "Entity #{0,-5} {1}, error at parameter {2}", mainEntity.EntityLabel, mainEntity.Entity.GetType().Name.ToUpper(), mainEntity.CurrentParamIndex + 1 ); } else { Logger?.LogError(LogEventIds.FailedEntity, e, "Unhandled Parser error, in Parser.cs EndNestedType"); } ErrorCount++; } if (ListNestLevel == 0) { CurrentInstance.CurrentParamIndex++; _deferListItems = false; } }
protected override void EndNestedType(string value) { try { PropertyValue.Init(_processStack.Pop().Entity); CurrentInstance = _processStack.Peek(); if (CurrentInstance.Entity != null) { CurrentInstance.ParameterSetter(CurrentInstance.CurrentParamIndex, PropertyValue, NestedIndex); } } catch (Exception) { if (ErrorCount > MaxErrorCount) { throw new XbimParserException("Too many errors in file, parser execution terminated"); } ErrorCount++; var mainEntity = _processStack.Last(); if (mainEntity != null) { var expressType = Metadata.ExpressType(mainEntity.Entity); Logger.ErrorFormat("Entity #{0,-5} {1}, error at parameter {2}-{3} value = {4}", mainEntity.EntityLabel, mainEntity.Entity.GetType().Name.ToUpper(), mainEntity.CurrentParamIndex + 1, expressType.Properties[mainEntity.CurrentParamIndex + 1].PropertyInfo.Name, value); } else { Logger.Error("Unhandled Parser error, in Parser.cs EndNestedType"); } } if (ListNestLevel == 0) { CurrentInstance.CurrentParamIndex++; _deferListItems = false; } }
protected override void SetType(string entityTypeName) { if (InHeader) { IPersist currentHeaderEntity; switch (entityTypeName) { case "FILE_DESCRIPTION": currentHeaderEntity = _header.FileDescription; break; case "FILE_NAME": currentHeaderEntity = _header.FileName; break; case "FILE_SCHEMA": currentHeaderEntity = _header.FileSchema; break; default: throw new ArgumentException(string.Format("Invalid Header entity type {0}", entityTypeName)); } _currentInstance = new Part21Entity(currentHeaderEntity); _processStack.Push(_currentInstance); } else { _currentType = entityTypeName; var type = _modelCache.Model.Metadata.ExpressType(_currentType); if (type == null) { throw new ArgumentException(string.Format("Invalid entity type {0}", _currentType)); } _indexKeys = type.IndexedValues; } }
internal override void SetType(string entityTypeName) { if (InHeader) { IPersistIfc currentHeaderEntity; switch (entityTypeName) { case "FILE_DESCRIPTION": currentHeaderEntity = _header.FileDescription; break; case "FILE_NAME": currentHeaderEntity = _header.FileName; break; case "FILE_SCHEMA": currentHeaderEntity = _header.FileSchema; break; default: throw new ArgumentException(string.Format("Invalid Header entity type {0}", entityTypeName)); } _currentInstance = new Part21Entity(currentHeaderEntity); _processStack.Push(_currentInstance); } else { _currentType = entityTypeName; IfcType ifcType = IfcMetaData.IfcType(_currentType); _indexKeys = ifcType.IndexedValues; } }
internal override void NewEntity(string entityLabel) { _currentInstance = new Part21Entity(entityLabel); // Console.WriteLine(CurrentSemanticValue.strVal); _processStack.Push(_currentInstance); if (_streamSize != -1 && ProgressStatus != null) { Scanner sc = (Scanner) this.Scanner; double pos = sc.Buffer.Pos; int newPercentage = Convert.ToInt32(pos/_streamSize*100.0); if (newPercentage > _percentageParsed) { _percentageParsed = newPercentage; ProgressStatus(_percentageParsed, "Parsing"); } } }
internal override void EndNestedType(string value) { try { _propertyValue.Init(_processStack.Pop().Entity); _currentInstance = _processStack.Peek(); if (_currentInstance.Entity != null) _currentInstance.ParameterSetter(_currentInstance.CurrentParamIndex, _propertyValue); } catch (Exception ) { if (_errorCount > MaxErrorCount) throw new Exception("Too many errors in file, parser execution terminated"); _errorCount++; Part21Entity mainEntity = _processStack.Last(); if (mainEntity != null) { IfcType ifcType = IfcMetaData.IfcType(mainEntity.Entity); Logger.ErrorFormat("Entity #{0,-5} {1}, error at parameter {2}-{3} value = {4}", mainEntity.EntityLabel, mainEntity.Entity.GetType().Name.ToUpper(), mainEntity.CurrentParamIndex + 1, ifcType.IfcProperties[mainEntity.CurrentParamIndex + 1].PropertyInfo.Name, value); } else { Logger.Error("Unhandled Parser error, in Parser.cs EndNestedType"); } } if (_listNestLevel == 0) { _currentInstance.CurrentParamIndex++; _deferListItems = false; } }
internal override void EndEntity() { Part21Entity p21 = _processStack.Pop(); //Debug.Assert(_processStack.Count == 0); _currentInstance = null; if (p21.Entity != null) _entities.Add(p21.EntityLabel, p21.Entity); // Console.WriteLine("EndEntity - " + CurrentSemanticValue.strVal); }
internal override void EndHeaderEntity() { _processStack.Pop(); _currentInstance = null; // Console.WriteLine("EndHeaderEntity - " + CurrentSemanticValue.strVal); }
internal override void SetType(string entityTypeName) { Scanner sc = (Scanner) this.Scanner; if (InHeader) { int[] reqParams; _currentInstance = new Part21Entity(EntityCreate(entityTypeName, null, InHeader, out reqParams)); _currentInstance.RequiredParameters = reqParams; _processStack.Push(_currentInstance); } else { Part21Entity p21 = _processStack.Peek(); int[] reqProps; p21.Entity = EntityCreate(entityTypeName, p21.EntityLabel, InHeader, out reqProps); p21.RequiredParameters = reqProps; } }
internal override void BeginNestedType(string value) { int[] reqProps; _currentInstance = new Part21Entity(EntityCreate(value, null, InHeader, out reqProps)); _currentInstance.RequiredParameters = reqProps; _processStack.Push(_currentInstance); }
internal override void EndEntity() { Part21Entity p21 = _processStack.Pop(); Debug.Assert(_processStack.Count == 0); _currentInstance = null; if (_currentType != null) { _binaryWriter.Write((byte)P21ParseAction.EndEntity); IfcType ifcType = IfcMetaData.IfcType(_currentType); MemoryStream data = _binaryWriter.BaseStream as MemoryStream; byte[] bytes = data.ToArray(); List<int> keys = new List<int>(_indexKeyValues); toStore.Add(new Tuple<int, short, List<int>, byte[], bool>(_currentLabel, ifcType.TypeId, keys, bytes, ifcType.IndexedClass)); if (this.modelCache.IsCaching) toProcess.Add(new Tuple<int, Type, byte[]>(_currentLabel, ifcType.Type, bytes)); } }
internal override void EndHeaderEntity() { _processStack.Pop(); _currentInstance = null; }
internal override void NewEntity(string entityLabel) { _currentInstance = new Part21Entity(entityLabel); _processStack.Push(_currentInstance); _entityCount++; _indexKeyValues.Clear(); _currentLabel = Convert.ToInt32(entityLabel.TrimStart('#')); MemoryStream data = _binaryWriter.BaseStream as MemoryStream; data.SetLength(0); if (_streamSize != -1 && ProgressStatus != null) { Scanner sc = (Scanner)this.Scanner; double pos = sc.Buffer.Pos; int newPercentage = Convert.ToInt32(pos / _streamSize * 100.0); if (newPercentage > _percentageParsed) { _percentageParsed = newPercentage; ProgressStatus(_percentageParsed, "Parsing"); } } }
public XbimParserState(IPersistIfcEntity entity) { _currentInstance = new Part21Entity(entity); _processStack.Push(_currentInstance); }
protected override void EndHeaderEntity() { _processStack.Pop(); _currentInstance = null; }