protected override bool HasNext() { while (!this.hasNextCalled) { base.HasNext(); if (this.valueType != IonType.None && !this.CurrentIsNull && this.GetContainerType() == IonType.Datagram) { switch (this.valueType) { case IonType.Struct: if (this.annotations.Count > 0 && this.annotations[0].Text == SystemSymbols.IonSymbolTable) { this.currentSymtab = ReaderLocalTable.ImportReaderTable(this, this.catalog, true); this.hasNextCalled = false; } break; case IonType.Symbol: // $ion_1_0 is read as an IVM only if it is not annotated. if (this.annotations.Count == 0) { var version = this.SymbolValue().Text; if (version is null || !IvmRegex.IsMatch(version)) { break; } // New IVM found, reset all symbol tables. if (version != SystemSymbols.Ion10) { throw new UnsupportedIonVersionException(version); } this.MoveNext(); // From specs: only unquoted $ion_1_0 text can be interpreted as IVM semantics and // cause the symbol tables to be reset. if (this.valueVariant.AuthoritativeType == ScalarType.String && this.scanner.Token != TextConstants.TokenSymbolQuoted) { this.currentSymtab = this.systemSymbols; } // Even if that's not the case we still skip the IVM. this.hasNextCalled = false; } break; default: break; } } } return(!this.eof); }
protected override bool HasNext() { while (!_hasNextCalled) { base.HasNext(); if (_valueType != IonType.None && !CurrentIsNull && GetContainerType() == IonType.Datagram) { switch (_valueType) { case IonType.Struct: if (_annotations.Count > 0 && _annotations[0].Text == SystemSymbols.IonSymbolTable) { _currentSymtab = ReaderLocalTable.ImportReaderTable(this, _catalog, true); _hasNextCalled = false; } break; case IonType.Symbol: // $ion_1_0 is read as an IVM only if it is not annotated if (_annotations.Count == 0) { var version = SymbolValue().Text; if (version is null || !IvmRegex.IsMatch(version)) { break; } //new Ivm found, reset all symbol tables if (SystemSymbols.Ion10 != version) { throw new UnsupportedIonVersionException(version); } MoveNext(); // from specs: only unquoted $ion_1_0 text can be interpreted as ivm semantics and // cause the symbol tables to be reset. if (_v.AuthoritativeType == ScalarType.String && _scanner.Token != TextConstants.TokenSymbolQuoted) { _currentSymtab = _systemSymbols; } //even if that's not the case we still skip the ivm _hasNextCalled = false; } break; } } } return(!_eof); }
private void MoveNextUser() { base.HasNext(); // if we're not at the top (datagram) level or the next value is null if (this.CurrentDepth != 0 || this.valueIsNull) { return; } Debug.Assert(this.valueTid != BinaryConstants.TidTypedecl, "valueTid is Typedec1"); if (this.valueTid == BinaryConstants.TidSymbol) { // trying to read a symbol here // $ion_1_0 is read as an IVM only if it is not annotated // we already count the number of annotations if (this.Annotations.Count != 0) { return; } this.LoadOnce(); // just get it straight from the holder, no conversion needed var sid = this.valueVariant.IntValue; if (sid != SystemSymbols.Ion10Sid) { return; } this.SymbolTable = SharedSymbolTable.GetSystem(1); // user don't need to see this symbol so continue here this.moveNextNeeded = true; } else if (this.valueTid == BinaryConstants.TidStruct) { // trying to read the local symbolTable here if (this.hasSymbolTableAnnotation) { this.SymbolTable = ReaderLocalTable.ImportReaderTable(this, this.catalog, false); // user don't need to read the localsymboltable so continue this.moveNextNeeded = true; } } }
protected override bool HasNext() { while (!_hasNextCalled) { base.HasNext(); if (_valueType != IonType.None && !CurrentIsNull && GetContainerType() == IonType.Datagram) { switch (_valueType) { case IonType.Struct: if (_annotations.Count > 0 && _annotations[0].Text == SystemSymbols.IonSymbolTable) { _currentSymtab = ReaderLocalTable.ImportReaderTable(this, _catalog, true); _hasNextCalled = false; } break; case IonType.Symbol: if (_annotations.Count == 0) { // $ion_1_0 is read as an IVM only if it is not annotated var version = SymbolValue().Text; if (version is null || !IvmRegex.IsMatch(version)) { break; } //new Ivm found, reset all symbol tables if (SystemSymbols.Ion10 != version) { throw new UnsupportedIonVersionException(version); } MoveNext(); _currentSymtab = _systemSymbols; _hasNextCalled = false; } break; } } } return(!_eof); }
private bool NextHelperUser() { if (this.eof) { return false; } if (this.next != null) { return true; } this.ClearSystemValueStack(); // read values from the system // reader and if they are system values // process them. Return when we've // read all the immediate system values IonType nextType; while (true) { nextType = this.NextHelperSystem(); if (this.top == 0 && this.parent != null && this.parent.Type() == IonType.Datagram) { if (nextType == IonType.Symbol) { var sym = this.next; if (sym.IsNull) { // there are no null values that we will consume here break; } int sid = sym.SymbolValue.Sid; // if sid is unknown if (sid == -1) { string name = sym.SymbolValue.Text; if (name != null) { sid = this.systemSymbols.FindSymbolId(name); } } if (sid == Ion10Sid && this.next.GetTypeAnnotationSymbols().Count == 0) { // $ion_1_0 is read as an IVM only if it is not annotated ISymbolTable symbols = this.systemSymbols; this.PushSymbolTable(symbols); this.next = null; continue; } } else if (nextType == IonType.Struct && this.next.HasAnnotation("$ion_symbol_table")) { // read a local symbol table ISymbolTable symtab = ReaderLocalTable.ImportReaderTable(this, this.catalog, true); this.PushSymbolTable(symtab); this.next = null; continue; } } // if we get here we didn't process a system // value, if we had we would have 'continue'd // so this is a value the user gets break; } return nextType != IonType.None; }
bool NextHelperUser() { if (_eof) { return(false); } if (_next != null) { return(true); } ClearSystemValueStack(); // read values from the system // reader and if they are system values // process them. Return when we've // read all the immediate system values IonType nextType; while (true) { nextType = NextHelperSystem(); if (_top == 0 && _parent != null && _parent.Type() == IonType.Datagram) { if (IonType.Symbol == nextType) { var sym = _next; if (sym.IsNull) { // there are no null values we will consume here break; } int sid = sym.SymbolValue.Sid; if (sid == -1) // if sid is unknown { String name = sym.SymbolValue.Text; if (name != null) { sid = _systemSymbols.FindSymbolId(name); } } if (sid == ION_1_0_SID && _next.GetTypeAnnotations().Count == 0) { // $ion_1_0 is read as an IVM only if it is not annotated ISymbolTable symbols = _systemSymbols; _currentSymtab = symbols; PushSymbolTable(symbols); _next = null; continue; } } else if (IonType.Struct == nextType && _next.HasAnnotation("$ion_symbol_table")) { // read a local symbol table IIonReader reader = new UserTreeReader(_next, _catalog); ISymbolTable symtab = ReaderLocalTable.ImportReaderTable(this, _catalog, true); _currentSymtab = symtab; PushSymbolTable(symtab); _next = null; continue; } } // if we get here we didn't process a system // value, if we had we would have 'continue'd // so this is a value the user gets break; } return(nextType != IonType.None); }