Beispiel #1
0
        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));
        }
Beispiel #2
0
 internal CodeSymbolCode <T2> ToCodeSymbolCode <T2>(uint startIndex, uint length, ICodeSymbolFactory <T2> codeSymbolFactory) where T2 : IBuildableCodeSymbol
 {
     return(BuildInstance(this.GetBitIterator(startIndex, length), codeSymbolFactory));
 }