1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/***********************************************/
/**
* @file fileArcList.cpp
*
* @brief Read/write Arc list.
*
* @author Torsten Mayer-Guerr
* @date 2013-02-07
*
*/
/***********************************************/
#define DOCSTRING_FILEFORMAT_ArcList
#include "base/import.h"
#include "inputOutput/fileArchive.h"
#include "files/fileFormatRegister.h"
#include "files/fileArcList.h"
GROOPS_REGISTER_FILEFORMAT(ArcList, "arcList")
/***********************************************/
void writeFileArcList(const FileName &fileName, const std::vector<UInt> &arcsInterval, const std::vector<Time> ×Interval)
{
try
{
OutFileArchive file(fileName, FILE_ARCLIST_TYPE, FILE_ARCLIST_VERSION);
file<<nameValue("intervalCount", arcsInterval.size());
file.comment("time [MJD] first arc");
file.comment("==================================");
for(UInt i=0; i<arcsInterval.size(); i++)
{
file<<beginGroup("interval");
file<<nameValue("time", timesInterval.at(i));
file<<nameValue("arc", arcsInterval.at(i));
file<<endGroup("interval");
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
void readFileArcList(const FileName &fileName, std::vector<UInt> &arcsInterval, std::vector<Time> ×Interval)
{
try
{
InFileArchive file(fileName, FILE_ARCLIST_TYPE, FILE_ARCLIST_VERSION);
if(file.version() < 20200123)
{
file>>nameValue("arcList", arcsInterval);
file>>nameValue("times", timesInterval);
return;
}
UInt count;
file>>nameValue("intervalCount", count);
arcsInterval.resize(count);
timesInterval.resize(count);
for(UInt i=0; i<count; i++)
{
file>>beginGroup("interval");
file>>nameValue("time", timesInterval.at(i));
file>>nameValue("arc", arcsInterval.at(i));
file>>endGroup("interval");
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
|