private void ParseEncodingMessage(IBitIterator it, MessageMode mode) { if (!it.EndReached) { this.charCountIndicatorSymbolCode = CodeSymbolCode <CharCountIndicatorSymbol> .BuildInstance(it, new CharCountIndicatorSymbolFactory(mode)); this.characterCount = charCountIndicatorSymbolCode.GetSymbolAt(0).GetCharacterCount(); if (!it.EndReached) { switch (mode.Mode) { case MessageMode.EncodingMode.Byte: this.Message = CodeSymbolCode <ByteEncodingSymbol> .BuildInstance(it, new ByteEncodingSymbolFactory(characterCount)); break; case MessageMode.EncodingMode.Alphanumeric: this.Message = CodeSymbolCode <AlphaNumericEncodingSymbol> .BuildInstance(it, new AlphaNumericEncodingSymbolFactory(characterCount)); break; case MessageMode.EncodingMode.Numeric: this.Message = CodeSymbolCode <NumericEncodingSymbol> .BuildInstance(it, new NumericEncodingSymbolFactory(characterCount)); break; default: throw new NotImplementedException($"{mode.Mode} decoding not implemented"); } } } }
internal static CodeSymbolCode <T2> BuildInstance <T2>(IBitIterator it, ICodeSymbolFactory <T2> symbolFactory) where T2 : IBuildableCodeSymbol { var codeSymbolList = new List <T2>(); var sym = symbolFactory.GenerateCodeSymbol(); while (!it.EndReached && sym != null) { char c = it.CurrentChar; if (c != '0' && c != '1' && c != 'u') { throw new NotImplementedException("Bit value " + c + " was not defined."); } sym.AddBit(c, it.Position); if (sym.CurrentSymbolLength == sym.MaxSymbolLength) { codeSymbolList.Add(sym); sym = symbolFactory.GenerateCodeSymbol(); } it.NextBit(); } //ToDo handle remainder bits or error: if(!wd.IsComplete){ if(wd.CurrentSymbolLength > 0) or: if(wd.CurrentSymbolLength != number of remainder bits) for QRCodeBitIterator return(new CodeSymbolCode <T2>(codeSymbolList)); }
internal EncodedMessage(IBitIterator it, MessageMode setMode, CodeSymbolCode <MessageModeSymbol> setMessageModeSymbolCode) { this.MessageModeSymbolCode = setMessageModeSymbolCode; this.mode = setMode; this.ParseEncodingMessage(it, mode); }