// Adds readers for optimized values public override EsfNode CreateValueNode(EsfType typeCode, bool optimize = true) { EsfNode result; switch (typeCode) { case EsfType.BOOL: case EsfType.BOOL_TRUE: case EsfType.BOOL_FALSE: if (optimize) { return(new OptimizedBoolNode()); } else { result = new BoolNode(); } break; case EsfType.UINT32: case EsfType.UINT32_ZERO: case EsfType.UINT32_ONE: case EsfType.UINT32_BYTE: case EsfType.UINT32_SHORT: case EsfType.UINT32_24BIT: return(new OptimizedUIntNode { SingleByteMin = !optimize }); case EsfType.INT32: case EsfType.INT32_ZERO: case EsfType.INT32_BYTE: case EsfType.INT32_SHORT: case EsfType.INT32_24BIT: return(new OptimizedIntNode { SingleByteMin = !optimize }); case EsfType.SINGLE: case EsfType.SINGLE_ZERO: if (optimize) { return(new OptimizedFloatNode()); } else { result = new FloatNode(); } break; default: return(base.CreateValueNode(typeCode)); } result.TypeCode = typeCode; return(result); }
// create public virtual EsfNode CreateValueNode(EsfType typeCode, bool optimize = true) { EsfNode result; switch (typeCode) { case EsfType.BOOL: result = new BoolNode(); break; case EsfType.INT8: result = new SByteNode(); break; case EsfType.INT16: result = new ShortNode(); break; case EsfType.INT32: result = new IntNode(); break; case EsfType.INT64: result = new LongNode(); break; case EsfType.UINT8: result = new ByteNode(); break; case EsfType.UINT16: result = new UShortNode(); break; case EsfType.UINT32: result = new UIntNode(); break; case EsfType.UINT64: result = new ULongNode(); break; case EsfType.SINGLE: result = new FloatNode(); break; case EsfType.DOUBLE: result = new DoubleNode(); break; case EsfType.COORD2D: result = new Coordinate2DNode(); break; case EsfType.COORD3D: result = new Coordinates3DNode(); break; case EsfType.UTF16: result = new StringNode(ReadUtf16, WriteUtf16); break; case EsfType.ASCII: result = new StringNode(ReadAscii, WriteAscii); break; case EsfType.ANGLE: result = new UShortNode(); break; //TODO confirm intended data types of types indicated by unknown enum values case EsfType.UNKNOWN_23: result = new SByteNode(); break; case EsfType.UNKNOWN_24: result = new ShortNode(); break; case EsfType.UNKNOWN_26: result = new Type26Node(); break; default: throw new InvalidDataException(string.Format("Invalid type code {0:x}", typeCode)); } result.TypeCode = typeCode; return(result); }