/** Returns the function call to pack a given type. */ private String getPackFuncJava(Type t, Object off, Object len) { String prefix = (record != packetType) ? "pack" : "packPayload"; if (t == BOOLEAN) return prefix + "Boolean(" + off + ", val)"; if (t == BOOLNULL) return prefix + "Boolean(" + off + ", val)"; if (t == INETADDR) return prefix + "InetAddr(" + off + ", val)"; if (t == UUID) return prefix + "UUID(" + off + ", val)"; if (t == BYTE) return prefix + "Byte(" + off + ", val)"; if (t == SHORT) return prefix + "Short(" + off + ", val)"; if (t == INT) return prefix + "Int(" + off + ", val)"; if (t == LONG) return prefix + "Long(" + off + ", val)"; if (t == FLOAT) return prefix + "Float(" + off + ", val)"; if (t == DOUBLE) return prefix + "Double(" + off + ", val)"; if (t == UTCTIME) return prefix + "TimeStamp(" + off + ", val, nxm.vrt.lib.TimeStamp.IntegerMode.UTC)"; if (t == GPSTIME) return prefix + "TimeStamp(" + off + ", val, nxm.vrt.lib.TimeStamp.IntegerMode.GPS)"; if (t.isAsciiType()) return prefix + "Ascii(" + off + ", val, " + len + ")"; if (t.isUTF8Type()) return prefix + "UTF8(" + off + ", val, " + len + ")"; if (t.isAsciiTypeStr()) return prefix + "Ascii(" + off + ", val, " + len + ")"; if (t.isUTF8TypeStr()) return prefix + "UTF8(" + off + ", val, " + len + ")"; if (t.isMetadataType()) return prefix + "Metadata(" + off + ", val, " + len + ")"; if (t instanceof Record) return prefix + "Record(" + off + ", val)"; if (t instanceof Enumeration) return prefix + "Byte(" + off + ", " + t.getTypeJavaGet() + ".getValue(val))"; throw new RuntimeException("Unsupported type " + t.getTypeName()); }
/** Gets the <tt>HasFields</tt> type for C++. */ public CharSequence getCPPFieldType() { Type t = getType(); String prefix = ""; if (t.isArrayType()) { prefix = "(ValueType)-"; t = t.getArrayType(); } if (t == BOOLEAN) return prefix + "ValueType_Bool"; if (t == BOOLNULL) return prefix + "ValueType_BoolNull"; if (t == INETADDR) return prefix + "ValueType_VRTObject"; if (t == UUID) return prefix + "ValueType_VRTObject"; if (t == BYTE) return prefix + "ValueType_Int8"; if (t == SHORT) return prefix + "ValueType_Int16"; if (t == INT) return prefix + "ValueType_Int32"; if (t == LONG) return prefix + "ValueType_Int64"; if (t == FLOAT) return prefix + "ValueType_Float"; if (t == DOUBLE) return prefix + "ValueType_Double"; if (t == UTCTIME) return prefix + "ValueType_VRTObject"; if (t == GPSTIME) return prefix + "ValueType_VRTObject"; if (t.isAsciiType()) return prefix + "ValueType_String"; if (t.isUTF8Type()) return prefix + "ValueType_WString"; if (t.isAsciiTypeStr()) return prefix + "ValueType_String"; if (t.isUTF8TypeStr()) return prefix + "ValueType_WString"; if (t.isMetadataType()) return prefix + "ValueType_VRTObject"; if (t instanceof Record) return prefix + "ValueType_VRTObject"; if (t instanceof Enumeration) return prefix + "ValueType_Int8"; throw new RuntimeException("Unsupported type " + t.getTypeName()); }
/** Returns the function call to unpack a given type. */ private String getUnpackFuncCPP(Type t, Object off, Object len) { String prefix = (record != packetType) ? "unpack" : "unpackPayload"; if (t == BOOLEAN) return prefix + "Boolean(" + off + ")"; if (t == BOOLNULL) return prefix + "Boolean(" + off + ")"; if (t == INETADDR) return prefix + "InetAddr(" + off + ")"; if (t == UUID) return prefix + "UUID(" + off + ")"; if (t == BYTE) return prefix + "Byte(" + off + ")"; if (t == SHORT) return prefix + "Short(" + off + ")"; if (t == INT) return prefix + "Int(" + off + ")"; if (t == LONG) return prefix + "Long(" + off + ")"; if (t == FLOAT) return prefix + "Float(" + off + ")"; if (t == DOUBLE) return prefix + "Double(" + off + ")"; if (t == UTCTIME) return prefix + "TimeStamp(" + off + ", IntegerMode_UTC)"; if (t == GPSTIME) return prefix + "TimeStamp(" + off + ", IntegerMode_GPS)"; if (t.isAsciiType()) return prefix + "Ascii(" + off + ", " + len + ")"; if (t.isUTF8Type()) return prefix + "UTF8(" + off + ", " + len + ")"; if (t.isAsciiTypeStr()) return prefix + "Ascii(" + off + ", " + len + ")"; if (t.isUTF8TypeStr()) return prefix + "UTF8(" + off + ", " + len + ")"; if (t.isMetadataType()) return prefix + "Metadata(" + off + ", " + len + ")"; if (t instanceof Record) return prefix + "Record(" + off + ", r)"; // <-- special handling if (t instanceof Enumeration) return "(" + t.getTypeJavaGet() + ")" + prefix + "Byte(" + off + ")"; throw new RuntimeException("Unsupported type " + t.getTypeName()); }
/** Is the given type a native type in C++ (or an array of native types)? */ private boolean isCPPNativeType(Type t) { if (t.isArrayType()) return isCPPNativeType(t.getArrayType()); if (t == BOOLEAN) return true; if (t == BOOLNULL) return true; if (t == BYTE) return true; if (t == SHORT) return true; if (t == INT) return true; if (t == LONG) return true; if (t == FLOAT) return true; if (t == DOUBLE) return true; if (t.isAsciiType()) return true; // string if (t.isUTF8Type()) return true; // wstring if (t.isAsciiTypeStr()) return true; // string if (t.isUTF8TypeStr()) return true; // wstring if (t instanceof Enumeration) return true; // int8_t return false; }