TSIO++ Time series input/output
cmdlinefiles.cc
Go to the documentation of this file.
1 
37 #define TSIO_CMDLINEFILES_CC_VERSION \
38  "TF_CMDLINEFILES_CC 2014/01/30"
39 
40 #include <fstream>
41 #include <tsioxx/cmdlinefiles.h>
42 #include <tsioxx/sfftsfileread.h>
43 #include <tsioxx/inputoperators.h>
44 #include <tfxx/rangestring.h>
45 
46 namespace ts {
47 
48  namespace sff {
49 
51  SFile readSSFF(const std::string& filename,
52  const bool& verbose,
53  const std::string& format)
54  {
55  Ttracelist rangelist;
56  return (readSSFF(filename, rangelist, verbose, format));
57  }
58 
60  DFile readDSFF(const std::string& filename,
61  const bool& verbose,
62  const std::string& format)
63  {
64  Ttracelist rangelist;
65  return (readDSFF(filename, rangelist, verbose, format));
66  }
67 
68  /*----------------------------------------------------------------------*/
69 
71  SFile readSSFF(const std::string& filename,
72  const Ttracelist& selection,
73  const bool& verbose,
74  const std::string& format)
75  {
76  SFile retval;
77  retval.arguments.name=filename;
78  if (verbose)
79  {
80  std::cout << "open input file " << filename << std::endl;
81  }
82  std::ifstream ifs(filename.c_str(),
83  datrw::ianystream::openmode(format));
84  datrw::ianystream is(ifs, format);
85  retval.data.read(is.idatstream(), selection, verbose);
86  return(retval);
87  }
88 
89  /*----------------------------------------------------------------------*/
90 
92  DFile readDSFF(const std::string& filename,
93  const Ttracelist& selection,
94  const bool& verbose,
95  const std::string& format)
96  {
97  DFile retval;
98  retval.arguments.name=filename;
99  if (verbose)
100  {
101  std::cout << "open input file " << filename << std::endl;
102  }
103  std::ifstream ifs(filename.c_str(),
104  datrw::ianystream::openmode(format));
105  datrw::ianystream is(ifs, format);
106  retval.data.read(is.idatstream(), selection, verbose);
107  return(retval);
108  }
109 
110  /*----------------------------------------------------------------------*/
111 
113  SFile readSSFF(const tfxx::cmdline::Filename& filename,
114  const bool& verbose,
115  Ttracelistkey tracekey,
116  const std::string& format)
117  {
118  Ttracelist selection=
119  tfxx::string::rangelist<Ttracelist::Tvalue>(filename.value(tracekey));
120  SFile retval=readSSFF(filename.name, selection, verbose, format);
121  retval.arguments=filename;
122  return(retval);
123  }
124 
126  DFile readDSFF(const tfxx::cmdline::Filename& filename,
127  const bool& verbose,
128  Ttracelistkey tracekey,
129  const std::string& format)
130  {
131  Ttracelist selection=
132  tfxx::string::rangelist<Ttracelist::Tvalue>(filename.value(tracekey));
133  DFile retval=readDSFF(filename.name, selection, verbose, format);
134  retval.arguments=filename;
135  return(retval);
136  }
137 
138  /*----------------------------------------------------------------------*/
139 
141  TSFileList readSSFF(const tfxx::cmdline::Tparsed& flist,
142  const bool& verbose,
143  Ttracelistkey tracekey,
144  const std::string& format)
145  {
146  TSFileList retval;
147  tfxx::cmdline::Tparsed::const_iterator file=flist.begin();
148  while (file != flist.end())
149  {
150  retval.push_back(readSSFF(*file, verbose, tracekey, format));
151  ++file;
152  }
153  return(retval);
154  }
155 
157  TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
158  const bool& verbose,
159  Ttracelistkey tracekey,
160  const std::string& format)
161  {
162  TDFileList retval;
163  tfxx::cmdline::Tparsed::const_iterator file=flist.begin();
164  while (file != flist.end())
165  {
166  retval.push_back(readDSFF(*file, verbose, tracekey, format));
167  ++file;
168  }
169  return(retval);
170  }
171 
172  /*======================================================================*/
173 
175  SFile readSSFF(const std::string& filename,
176  const bool& verbose,
177  const datrw::Eformat& format)
178  {
179  return (readSSFF(filename, verbose, datrw::anyID(format)));
180  }
181 
183  DFile readDSFF(const std::string& filename,
184  const bool& verbose,
185  const datrw::Eformat& format)
186  {
187  return (readDSFF(filename, verbose, datrw::anyID(format)));
188  }
189 
190  /*----------------------------------------------------------------------*/
191 
193  SFile readSSFF(const std::string& filename,
194  const Ttracelist& selection,
195  const bool& verbose,
196  const datrw::Eformat& format)
197  {
198  return (readSSFF(filename, selection, verbose, datrw::anyID(format)));
199  }
200 
201  /*----------------------------------------------------------------------*/
202 
204  DFile readDSFF(const std::string& filename,
205  const Ttracelist& selection,
206  const bool& verbose,
207  const datrw::Eformat& format)
208  {
209  return (readDSFF(filename, selection, verbose, datrw::anyID(format)));
210  }
211 
212  /*----------------------------------------------------------------------*/
213 
215  SFile readSSFF(const tfxx::cmdline::Filename& filename,
216  const bool& verbose,
217  Ttracelistkey tracekey,
218  const datrw::Eformat& format)
219  {
220  return (readSSFF(filename, verbose, tracekey, datrw::anyID(format)));
221  }
222 
224  DFile readDSFF(const tfxx::cmdline::Filename& filename,
225  const bool& verbose,
226  Ttracelistkey tracekey,
227  const datrw::Eformat& format)
228  {
229  return (readDSFF(filename, verbose, tracekey, datrw::anyID(format)));
230  }
231 
232  /*----------------------------------------------------------------------*/
233 
235  TSFileList readSSFF(const tfxx::cmdline::Tparsed& flist,
236  const bool& verbose,
237  Ttracelistkey tracekey,
238  const datrw::Eformat& format)
239  {
240  return (readSSFF(flist, verbose, tracekey, datrw::anyID(format)));
241  }
242 
244  TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
245  const bool& verbose,
246  Ttracelistkey tracekey,
247  const datrw::Eformat& format)
248  {
249  return (readDSFF(flist, verbose, tracekey, datrw::anyID(format)));
250  }
251 
252  } // namespace sff
253 } // namespace ts
254 
255 /* ----- END OF cmdlinefiles.cc ----- */
structure to contain file data together with command line arguments.
Definition: cmdlinefiles.h:126
containers for data files with file specific command line parameters (prototypes).
DFile readDSFF(const std::string &filename, const bool &verbose, const std::string &format)
read complete SFF file
Definition: cmdlinefiles.cc:60
define ts::sff::File<C>::read function (implementation)
void read(datrw::idatstream &is, const bool &verbose=false)
Read a complete file with all traces.
Definition: sfftsfileread.h:57
std::list< DFile > TDFileList
complete list of files.
Definition: cmdlinefiles.h:144
input operators for SFF TimeSeries traces and files for libdatrwxx streams (prototypes).
ts::sff::File< Tseries > data
container to hold data headers and samples
Definition: cmdlinefiles.h:136
structure to contain file data together with command line arguments (single precision).
Definition: cmdlinefiles.h:103
Outer namespace.
Definition: cmdlinefiles.cc:46
tfxx::cmdline::Filename arguments
command line arguments
Definition: cmdlinefiles.h:134
const char * Ttracelistkey
type of trace selection key.
Definition: cmdlinefiles.h:90
std::list< SFile > TSFileList
complete list of files (single precision version).
Definition: cmdlinefiles.h:151
ts::sff::File< Tseries > data
container to hold data headers and samples
Definition: cmdlinefiles.h:113
SFile readSSFF(const std::string &filename, const bool &verbose, const std::string &format)
read complete SFF file
Definition: cmdlinefiles.cc:51
tfxx::RangeList< int > Ttracelist
type of trace selection list.
Definition: cmdlinefiles.h:83
tfxx::cmdline::Filename arguments
command line arguments
Definition: cmdlinefiles.h:111