newDataEncoder constructs a dataEncoder.
(t dataEncoderType)
| 116 | |
| 117 | // newDataEncoder constructs a dataEncoder. |
| 118 | func newDataEncoder(t dataEncoderType) *dataEncoder { |
| 119 | d := &dataEncoder{} |
| 120 | |
| 121 | switch t { |
| 122 | case dataEncoderType1To9: |
| 123 | d = &dataEncoder{ |
| 124 | minVersion: 1, |
| 125 | maxVersion: 9, |
| 126 | numericModeIndicator: bitset.New(b0, b0, b0, b1), |
| 127 | alphanumericModeIndicator: bitset.New(b0, b0, b1, b0), |
| 128 | byteModeIndicator: bitset.New(b0, b1, b0, b0), |
| 129 | numNumericCharCountBits: 10, |
| 130 | numAlphanumericCharCountBits: 9, |
| 131 | numByteCharCountBits: 8, |
| 132 | } |
| 133 | case dataEncoderType10To26: |
| 134 | d = &dataEncoder{ |
| 135 | minVersion: 10, |
| 136 | maxVersion: 26, |
| 137 | numericModeIndicator: bitset.New(b0, b0, b0, b1), |
| 138 | alphanumericModeIndicator: bitset.New(b0, b0, b1, b0), |
| 139 | byteModeIndicator: bitset.New(b0, b1, b0, b0), |
| 140 | numNumericCharCountBits: 12, |
| 141 | numAlphanumericCharCountBits: 11, |
| 142 | numByteCharCountBits: 16, |
| 143 | } |
| 144 | case dataEncoderType27To40: |
| 145 | d = &dataEncoder{ |
| 146 | minVersion: 27, |
| 147 | maxVersion: 40, |
| 148 | numericModeIndicator: bitset.New(b0, b0, b0, b1), |
| 149 | alphanumericModeIndicator: bitset.New(b0, b0, b1, b0), |
| 150 | byteModeIndicator: bitset.New(b0, b1, b0, b0), |
| 151 | numNumericCharCountBits: 14, |
| 152 | numAlphanumericCharCountBits: 13, |
| 153 | numByteCharCountBits: 16, |
| 154 | } |
| 155 | default: |
| 156 | log.Panic("Unknown dataEncoderType") |
| 157 | } |
| 158 | |
| 159 | return d |
| 160 | } |
| 161 | |
| 162 | // encode data as one or more segments and return the encoded data. |
| 163 | // |
searching dependent graphs…