#include "stdafx.h"

#include "xtr/io/ModelExporter.h"

#include "xtr/io/ModelDataExchange.h"

#include "ccl/tools/JSON.h"

namespace xtr::io {

BOOL ModelExporter::Export(const CString fileName, const FileType type) {
  switch (type) {
  default: return FALSE;

  case FileType::xlsx:  return io::RSMDataX::ExportModel(target);
  case FileType::json: {
    std::ofstream file(fileName);
    if (!file.is_open()) {
      return FALSE;
    } else {
      file << std::setw(4) << nlohmann::ordered_json(target);
      file.close();
      return TRUE;
    }
  }
  }
}

} // namespace xtr::io