TimeTableCatalogUtil.hh 1.51 KB
/*
 * TimeTableCatalogUtil.hh
 *
 *  Created on: 6 août 2013
 *      Author: CS
 */

#ifndef TIMETABLECATALOGUTIL_HH_
#define TIMETABLECATALOGUTIL_HH_

#include <string>
#include "TimeTable.hh"

/**
 * Some convenient method to handle ISO time representations.
 */
namespace TimeTableCatalog {

/**
 * Gets ISO time format, with or without msk.
 */
TimeTable::TIME_FORMAT getTimeFormat(const std::string& ptime, int& size);

/**
 * Reads an ISO time, automatically detect time format.
 */
double readISOTime(const std::string& ptime);

/**
 * Reads an ISO time of the given format.
 */
double readISOTime(const std::string& ptime,
		const TimeTable::TIME_FORMAT pformat);

/**
 * Writes an ISO time to a given stream with a given format.
 */
void writeISOTime(const double pTime, const TimeTable::TIME_FORMAT pFormat, std::ostream& pOut);

/**
 * Writes an time into a stream with a given format.
 */
void writeTimeData(const double pTime, const AMDA::OutputFormatTime pFormat, std::ostream& pOut);


/**
 * Checks a line contains or not a metadata keyword.
 */
bool contains(const std::string & pline, const std::string & pkeyword, const std::string& pprefix=std::string());

/**
 * Extracts a metadata value (a metadata is formated as key:value).
 */
void extractvalue(const std::string & pline, std::string& pvalue);

/**
 * Splits a string around a given delimiter.
 */
std::vector<std::string> &split(const std::string &s, char delim,
		std::vector<std::string> &elems);

} /* namespace TimeTableCatalog */
#endif /* TIMETABLECATALOGUTIL_HH_ */