(r binary.Reader, xml *xmlTree)
| 181 | } |
| 182 | |
| 183 | func decodeValue(r binary.Reader, xml *xmlTree) (typedValue, error) { |
| 184 | size := r.Uint16() |
| 185 | if size != valueSize { |
| 186 | return nil, fmt.Errorf("Value size was not as expected. Got %d, expected %d", |
| 187 | size, valueSize) |
| 188 | } |
| 189 | res0 := r.Uint8() |
| 190 | if res0 != 0 { |
| 191 | return nil, fmt.Errorf("res0 was %d, expected 0", res0) |
| 192 | } |
| 193 | ty := valueType(r.Uint8()) |
| 194 | switch ty { |
| 195 | case typeIntDec: |
| 196 | return valIntDec(r.Int32()), nil |
| 197 | case typeIntHex: |
| 198 | return valIntHex(r.Uint32()), nil |
| 199 | case typeReference: |
| 200 | return valReference(r.Uint32()), nil |
| 201 | case typeString: |
| 202 | return valStringID(xml.decodeString(r)), nil |
| 203 | case typeFloat: |
| 204 | return valFloat(r.Float32()), nil |
| 205 | case typeIntBoolean: |
| 206 | return valIntBoolean(r.Uint32() != 0), nil |
| 207 | case typeNull: |
| 208 | return valNull(r.Uint32()), nil |
| 209 | case typeDimension: |
| 210 | return decodeDimension(r) |
| 211 | default: |
| 212 | return nil, fmt.Errorf("Value type %v not implemented", ty) |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | type valueType uint8 |
| 217 |
no test coverage detected