TimeTableCatalogUtil.hh 1.36 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 qith a given format.
 */
void writeISOTime(const double ptime, const TimeTable::TIME_FORMAT 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_ */