Commit bec5971d authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Add INT16 and INT64 types to FileSchema

parent cdf53f21
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ HDFFile* HDFFile::from_schema(
  herr_t status;
  string *rec_types = schema.get_record_types();
  string *rec_names = schema.get_record_names();
  string known_types[] = {"INT32", "FLOAT64", "COMPLEX128"};
  string known_types[] = {"INT32", "FLOAT64", "COMPLEX128", "INT64", "INT16"};
  int rec_num = schema.get_record_number();
  regex re;
  smatch m;
@@ -113,8 +113,10 @@ HDFFile* HDFFile::from_schema(
	if (type_index == 1) data_type = H5Tcopy(H5T_NATIVE_INT);
	else if (type_index == 2) data_type = H5Tcopy(H5T_NATIVE_DOUBLE);
	else if (type_index == 3) data_type = H5Tcopy(H5T_NATIVE_DOUBLE);
	else if (type_index == 4) data_type = H5Tcopy(H5T_NATIVE_LONG);
	else if (type_index == 5) data_type = H5Tcopy(H5T_NATIVE_SHORT);
      }
      if (type_index == 3) break;
      if (type_index == 5) break;
    }
    if (found_type) {
      re = regex("[0-9]+");
@@ -161,7 +163,7 @@ herr_t HDFFile::read(
		     hid_t mem_space_id, hid_t file_space_id, hid_t dapl_id,
		     hid_t dxpl_id
) {
  string known_types[] = {"INT32", "FLOAT64"};
  string known_types[] = {"INT32", "FLOAT64", "COMPLEX128", "INT64", "INT16"};
  regex re;
  smatch m;
  bool found_type = false;
@@ -169,7 +171,7 @@ herr_t HDFFile::read(
  while (!found_type) {
    re = regex(known_types[type_index++]);
    found_type = regex_search(data_type, m, re);
    if (type_index == 2) break;
    if (type_index == 5) break;
  }
  if (found_type) {
    hid_t dataset_id = H5Dopen2(file_id, dataset_name.c_str(), dapl_id);
@@ -179,6 +181,12 @@ herr_t HDFFile::read(
      mem_type_id = H5T_NATIVE_INT; break;
    case 2:
      mem_type_id = H5T_NATIVE_DOUBLE; break;
    case 3:
      mem_type_id = H5T_NATIVE_DOUBLE; break;
    case 4:
      mem_type_id = H5T_NATIVE_LONG; break;
    case 5:
      mem_type_id = H5T_NATIVE_SHORT; break;
    default:
      throw UnrecognizedParameterException("unrecognized data type \"" + data_type + "\"");
    }
@@ -200,7 +208,7 @@ herr_t HDFFile::write(
		      hid_t mem_space_id, hid_t file_space_id, hid_t dapl_id,
		      hid_t dxpl_id
) {
  string known_types[] = {"INT32", "FLOAT64", "COMPLEX128"};
  string known_types[] = {"INT32", "FLOAT64", "COMPLEX128", "INT64", "INT16"};
  regex re;
  smatch m;
  bool found_type = false;
@@ -208,7 +216,7 @@ herr_t HDFFile::write(
  while (!found_type) {
    re = regex(known_types[type_index++]);
    found_type = regex_search(data_type, m, re);
    if (type_index == 3) break;
    if (type_index == 5) break;
  }
  if (found_type) {
    hid_t dataset_id = H5Dopen2(file_id, dataset_name.c_str(), dapl_id);
@@ -220,6 +228,10 @@ herr_t HDFFile::write(
      mem_type_id = H5T_NATIVE_DOUBLE; break;
    case 3:
      mem_type_id = H5T_NATIVE_DOUBLE; break;
    case 4:
      mem_type_id = H5T_NATIVE_LONG; break;
    case 5:
      mem_type_id = H5T_NATIVE_SHORT; break;
    default:
      throw UnrecognizedParameterException("unrecognized data type \"" + data_type + "\"");
    }