示例#1
0
static inline wbExport_t wbExport_open(const char *file, wbExportKind_t kind) {
  wbExport_t exprt;

  if (file == NULL) {
    wbLog(ERROR, "Go NULL for file value.");
    wbExit();
  }

  wbExport_setFile(exprt, NULL);
  wbExport_setKind(exprt, kind);

  if (kind == wbExportKind_raw) {
    wbExportRaw_t raw = wbExportRaw_new();
    wbExportRaw_setFile(raw, file);
    wbExport_setRaw(exprt, raw);
  } else if (kind == wbExportKind_tsv || kind == wbExportKind_csv) {
    wbExportCSV_t csv = wbExportCSV_new();
    if (kind == wbExportKind_csv) {
      wbExportCSV_setSeperator(csv, ',');
    } else {
      wbExportCSV_setSeperator(csv, '\t');
    }
    wbExportCSV_setFile(csv, file);
    wbExport_setCSV(exprt, csv);
  } else if (kind == wbExportKind_ppm) {
    wbExport_setFile(exprt, wbString_duplicate(file));
  } else {
    wbLog(ERROR, "Invalid export type.");
    wbExit();
  }

  return exprt;
}
示例#2
0
文件: wbExport.cpp 项目: abduld/libwb
static inline void wbExport_close(wbExport_t exprt) {
  wbExportKind_t kind;

  kind = wbExport_getKind(exprt);

  if (wbExport_getFile(exprt)) {
    wbDelete(wbExport_getFile(exprt));
  }

  if (kind == wbExportKind_tsv || kind == wbExportKind_csv) {
    wbExportCSV_t csv = wbExport_getCSV(exprt);
    wbExportCSV_delete(csv);
    wbExport_setCSV(exprt, NULL);
  } else if (kind == wbExportKind_raw) {
    wbExportRaw_t raw = wbExport_getRaw(exprt);
    wbExportRaw_delete(raw);
    wbExport_setRaw(exprt, NULL);
  } else if (kind == wbExportKind_text) {
    wbExportText_t text = wbExport_getText(exprt);
    wbExportText_delete(text);
    wbExport_setText(exprt, NULL);
  } else if (kind == wbExportKind_ppm) {
  } else {
    wbLog(ERROR, "Invalid export type.");
    wbExit();
  }
  return;
}