// 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); }
// 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; //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; default: return(base.CreateValueNode(typeCode)); } result.TypeCode = typeCode; return(result); }
// create public virtual EsfNode CreateValueNode(EsfType typeCode, bool optimize = true) { EsfNode result = null; 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, WriteUtf16); break; case EsfType.ANGLE: result = new UShortNode(); break; default: throw new InvalidDataException(string.Format("Invalid type code {0:x}", typeCode)); } result.TypeCode = typeCode; return(result); }
public override EsfNode CreateValueNode(EsfType typeCode, bool optimize = true) { EsfNode esfNode; switch (typeCode) { case EsfType.BOOL: case EsfType.BOOL_TRUE: case EsfType.BOOL_FALSE: if (optimize) { return(new OptimizedBoolNode()); } esfNode = 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()); } esfNode = new FloatNode(); break; case EsfType.UNKNOWN_23: esfNode = new SByteNode(); break; case EsfType.UNKNOWN_24: esfNode = new ShortNode(); break; default: return(base.CreateValueNode(typeCode, optimize: false)); } esfNode.TypeCode = typeCode; return(esfNode); }
public virtual EsfNode CreateValueNode(EsfType typeCode, bool optimize = true) { EsfNode esfNode = null; switch (typeCode) { case EsfType.BOOL: esfNode = new BoolNode(); break; case EsfType.INT8: esfNode = new SByteNode(); break; case EsfType.INT16: esfNode = new ShortNode(); break; case EsfType.INT32: esfNode = new IntNode(); break; case EsfType.INT64: esfNode = new LongNode(); break; case EsfType.UINT8: esfNode = new ByteNode(); break; case EsfType.UINT16: esfNode = new UShortNode(); break; case EsfType.UINT32: esfNode = new UIntNode(); break; case EsfType.UINT64: esfNode = new ULongNode(); break; case EsfType.SINGLE: esfNode = new FloatNode(); break; case EsfType.DOUBLE: esfNode = new DoubleNode(); break; case EsfType.COORD2D: esfNode = new Coordinate2DNode(); break; case EsfType.COORD3D: esfNode = new Coordinates3DNode(); break; case EsfType.UTF16: esfNode = new StringNode(ReadUtf16, WriteUtf16); break; case EsfType.ASCII: esfNode = new StringNode(ReadAscii, WriteAscii); break; case EsfType.ANGLE: esfNode = new UShortNode(); break; default: esfNode = new BoolNode(); break; } esfNode.TypeCode = typeCode; return(esfNode); }