/** * FileWriterASCIIVOTable.cc * Created on: 21 oct. 2014 * Author: AKKA */ #include "FileWriterASCIIVOTable.hh" #include "TimeUtil.hh" namespace AMDA { namespace ParamOutputImpl { namespace Download { namespace FileWriter { FileWriterASCIIVOTable::FileWriterASCIIVOTable(AMDA::Parameters::ParameterManager& pParameterManager) : FileWriterASCIIAbstract(pParameterManager) { } FileWriterASCIIVOTable::~FileWriterASCIIVOTable(void) { if (_outputFile.is_open()) writeEndFile(); } bool FileWriterASCIIVOTable::isInfoInSeparateFile(bool /* onlyOneInterval */, OutputStructure /* outputStructure */) { return false; } std::string FileWriterASCIIVOTable::getExtension(void) { return "vot"; } std::string FileWriterASCIIVOTable::getDataFillCharacter(void) { return ""; } std::string FileWriterASCIIVOTable::getNanString(void) { return "NaN"; } void FileWriterASCIIVOTable::writeBeginFile(void) { if (!_outputFile.is_open()) return; _outputFile << "" << std::endl; _outputFile << "" << std::endl; _outputFile << " " << std::endl; _outputFile << " " << std::endl; } void FileWriterASCIIVOTable::writeEndFile(void) { if (!_outputFile.is_open()) return; _outputFile << "
" << std::endl; _outputFile << "
" << std::endl; _outputFile << "
" << std::endl; } void FileWriterASCIIVOTable::writeBeginGeneralDescription(void) { if (!_outputFile.is_open()) return; _outputFile << " " << std::endl; } void FileWriterASCIIVOTable::writeEndGeneralDescription(void) { if (!_outputFile.is_open()) return; _outputFile << " " << std::endl; } void FileWriterASCIIVOTable::writeErrorInfo(std::string msg) { if (!_outputFile.is_open()) return; _outputFile << msg; } void FileWriterASCIIVOTable::writeBeginInfoGroup(std::string title, int level) { if (!_outputFile.is_open()) return; if (title.empty() || level > 0) _outputFile << std::endl; else _outputFile << "* " << title << " :" << std::endl; } void FileWriterASCIIVOTable::writeEndInfoGroup(int level) { if (!_outputFile.is_open()) return; if (level == 0) _outputFile << std::endl; } void FileWriterASCIIVOTable::writeSingleInfo(std::string key, std::string value, int level) { if (!_outputFile.is_open()) return; std::string prefix; for (int i = 0; i < level; ++i) prefix += " "; _outputFile << prefix << key << " : " << value << std::endl; } void FileWriterASCIIVOTable::writeBeginInfoList(std::string /*title*/, int /*level*/) { //nothing to do } void FileWriterASCIIVOTable::writeEndInfoList(void) { //nothing to do } void FileWriterASCIIVOTable::writeBeginFieldsDescription(void) { //nothing to do } void FileWriterASCIIVOTable::writeEndFieldsDescription(void) { //nothing to do } void FileWriterASCIIVOTable::writeFieldDescription(std::string paramId) { if (!_outputFile.is_open()) return; _outputFile << " 1) { _outputFile << "x"; _outputFile << _fieldInfoMap[paramId].dimSize2; } } _outputFile << "\""; _outputFile << "/>" << std::endl; } void FileWriterASCIIVOTable::writeBeginData(void) { if (!_outputFile.is_open()) return; _outputFile << " " << std::endl; _outputFile << " " << std::endl; } void FileWriterASCIIVOTable::writeEndData(void) { if (!_outputFile.is_open()) return; _outputFile << " " << std::endl; _outputFile << " " << std::endl; } void FileWriterASCIIVOTable::writeDataRecord(std::string record) { if (!_outputFile.is_open()) return; _outputFile << " " << std::endl; _outputFile << record << std::endl; _outputFile << " " << std::endl; } std::string FileWriterASCIIVOTable::getDataStartTag(bool isTimeData) { if (isTimeData) return " "; return ""; } std::string FileWriterASCIIVOTable::getDataStopTag(void) { return ""; } std::string FileWriterASCIIVOTable::getDataValueSeparator(void) { return " "; } bool FileWriterASCIIVOTable::writeTimeData(std::string paramId, double data, OutputFormatTime /*timeFormat*/, bool isFirstParam) { //force ISO format for time field if (!isFirstParam) return true; //time already write for this record, no error std::fstream *crtFile = _fieldInfoMap[paramId].file; if (crtFile == NULL) return false; (*crtFile) << getDataStartTag(true); TimeUtil::formatTimeDateInIso(data, *crtFile); (*crtFile) << "Z"; (*crtFile) << getDataStopTag(); return true; } } /* namespace FileWriter */ } /* namespace Download */ } /* namespace ParamOutputImpl */ } /* namespace AMDA */