cmdlinefiles.cc 8.66 KB
Newer Older
1
2
/*! \file cmdlinefiles.cc
 * \brief containers for data files with file specific command line parameters (implementation)
thomas.forbriger's avatar
thomas.forbriger committed
3
4
5
 * 
 * ----------------------------------------------------------------------------
 * 
6
 * $Id: $
thomas.forbriger's avatar
thomas.forbriger committed
7
 * \author Thomas Forbriger
8
9
 * \since 31/01/2007
 * \date 30/01/2014
thomas.forbriger's avatar
thomas.forbriger committed
10
 * 
11
 * containers for data files with file specific command line parameters
thomas.forbriger's avatar
GPL    
thomas.forbriger committed
12
 * (implementation)
13
14
 * 
 * Copyright (c) 2007, 2010, 2011, 2014 by Thomas Forbriger (BFO Schiltach) 
thomas.forbriger's avatar
GPL    
thomas.forbriger committed
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 *
 * ----
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
31
 *
thomas.forbriger's avatar
thomas.forbriger committed
32
 * REVISIONS and CHANGES 
33
34
 *  - 30/01/2014   V1.0   Thomas Forbriger (thof):
 *                        copied from readtsdata.cc
thomas.forbriger's avatar
thomas.forbriger committed
35
36
37
 * 
 * ============================================================================
 */
38
39
40
41
42
#define TSIO_CMDLINEFILES_CC_VERSION \
  "TF_CMDLINEFILES_CC   2014/01/30"
#define TSIO_CMDLINEFILES_CC_CVSID \
  "$Id: $"

43
44
45
46
#include <fstream>
#include <tsioxx/cmdlinefiles.h>
#include <tsioxx/inputoperators.h>
#include <tfxx/rangestring.h>
thomas.forbriger's avatar
thomas.forbriger committed
47

48
namespace ts {
thomas.forbriger's avatar
thomas.forbriger committed
49

50
  namespace sff {
thomas.forbriger's avatar
thomas.forbriger committed
51

thomas.forbriger's avatar
thomas.forbriger committed
52
53
54
    //! read complete SFF file
    SFile readSSFF(const std::string& filename,
                   const bool& verbose,
55
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
56
57
58
59
60
    {
      Ttracelist rangelist;
      return (readSSFF(filename, rangelist, verbose, format));
    }

thomas.forbriger's avatar
thomas.forbriger committed
61
    //! read complete SFF file
thomas.forbriger's avatar
thomas.forbriger committed
62
63
    DFile readDSFF(const std::string& filename,
                   const bool& verbose,
64
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
65
    {
thomas.forbriger's avatar
thomas.forbriger committed
66
67
      Ttracelist rangelist;
      return (readDSFF(filename, rangelist, verbose, format));
thomas.forbriger's avatar
thomas.forbriger committed
68
69
70
71
    }

    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
72
73
74
75
    //! read complete SFF file with trace selection
    SFile readSSFF(const std::string& filename,
                   const Ttracelist& selection,
                   const bool& verbose,
76
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
77
78
79
80
81
82
83
    {
      SFile retval;
      retval.arguments.name=filename;
      if (verbose) 
      { 
        std::cout << "open input file " << filename << std::endl;
      }
thomas.forbriger's avatar
thomas.forbriger committed
84
85
      std::ifstream ifs(filename.c_str(), 
                        datrw::ianystream::openmode(format));
86
      datrw::ianystream is(ifs, format);
thomas.forbriger's avatar
thomas.forbriger committed
87
88
89
90
      retval.data.read(is.idatstream(), selection, verbose);
      return(retval);
    }

thomas.forbriger's avatar
thomas.forbriger committed
91
92
    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
93
94
    //! read complete SFF file with trace selection
    DFile readDSFF(const std::string& filename,
thomas.forbriger's avatar
thomas.forbriger committed
95
                   const Ttracelist& selection,
thomas.forbriger's avatar
thomas.forbriger committed
96
                   const bool& verbose,
97
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
98
99
100
101
102
103
104
    {
      DFile retval;
      retval.arguments.name=filename;
      if (verbose) 
      { 
        std::cout << "open input file " << filename << std::endl;
      }
thomas.forbriger's avatar
thomas.forbriger committed
105
106
      std::ifstream ifs(filename.c_str(),
                        datrw::ianystream::openmode(format));
107
      datrw::ianystream is(ifs, format);
thomas.forbriger's avatar
thomas.forbriger committed
108
109
110
111
112
113
      retval.data.read(is.idatstream(), selection, verbose);
      return(retval);
    }

    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
114
115
116
117
    //! read complete SFF file with trace selection
    SFile readSSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose,
                   Ttracelistkey tracekey,
118
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
119
120
121
122
123
124
125
126
    {
      Ttracelist selection=
        tfxx::string::rangelist<Ttracelist::Tvalue>(filename.value(tracekey));
      SFile retval=readSSFF(filename.name, selection, verbose, format);
      retval.arguments=filename;
      return(retval);
    }

thomas.forbriger's avatar
thomas.forbriger committed
127
128
129
130
    //! read complete SFF file with trace selection
    DFile readDSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose,
                   Ttracelistkey tracekey,
131
                   const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
132
    {
thomas.forbriger's avatar
thomas.forbriger committed
133
134
      Ttracelist selection=
        tfxx::string::rangelist<Ttracelist::Tvalue>(filename.value(tracekey));
thomas.forbriger's avatar
thomas.forbriger committed
135
136
137
138
139
140
141
      DFile retval=readDSFF(filename.name, selection, verbose, format);
      retval.arguments=filename;
      return(retval);
    }

    /*----------------------------------------------------------------------*/

thomas.forbriger's avatar
thomas.forbriger committed
142
143
144
145
    //! read complete list of SFF files with trace selection
    TSFileList readSSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose,
                        Ttracelistkey tracekey,
146
                        const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
147
148
149
150
151
152
153
154
155
156
157
    {
      TSFileList retval;
      tfxx::cmdline::Tparsed::const_iterator file=flist.begin();
      while (file != flist.end())
      {
        retval.push_back(readSSFF(*file, verbose, tracekey, format));
        ++file;
      }
      return(retval);
    }

thomas.forbriger's avatar
thomas.forbriger committed
158
159
160
161
    //! read complete list of SFF files with trace selection
    TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose,
                        Ttracelistkey tracekey,
162
                        const std::string& format)
thomas.forbriger's avatar
thomas.forbriger committed
163
164
165
166
167
168
169
170
171
172
173
    {
      TDFileList retval;
      tfxx::cmdline::Tparsed::const_iterator file=flist.begin();
      while (file != flist.end())
      {
        retval.push_back(readDSFF(*file, verbose, tracekey, format));
        ++file;
      }
      return(retval);
    }

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
    /*======================================================================*/

    //! read complete SFF file
    SFile readSSFF(const std::string& filename,
                   const bool& verbose,
                   const datrw::Eformat& format)
    {
      return (readSSFF(filename, verbose, datrw::anyID(format)));
    }

    //! read complete SFF file
    DFile readDSFF(const std::string& filename,
                   const bool& verbose,
                   const datrw::Eformat& format)
    {
      return (readDSFF(filename, verbose, datrw::anyID(format)));
    }

    /*----------------------------------------------------------------------*/

    //! read complete SFF file with trace selection
    SFile readSSFF(const std::string& filename,
                   const Ttracelist& selection,
                   const bool& verbose,
                   const datrw::Eformat& format)
    {
      return (readSSFF(filename, selection, verbose, datrw::anyID(format)));
    }

    /*----------------------------------------------------------------------*/

    //! read complete SFF file with trace selection
    DFile readDSFF(const std::string& filename,
                   const Ttracelist& selection,
                   const bool& verbose,
                   const datrw::Eformat& format)
    {
      return (readDSFF(filename, selection, verbose, datrw::anyID(format)));
    }

    /*----------------------------------------------------------------------*/

    //! read complete SFF file with trace selection
    SFile readSSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose,
                   Ttracelistkey tracekey,
                   const datrw::Eformat& format)
    {
      return (readSSFF(filename, verbose, tracekey, datrw::anyID(format)));
    }

    //! read complete SFF file with trace selection
    DFile readDSFF(const tfxx::cmdline::Filename& filename,
                   const bool& verbose,
                   Ttracelistkey tracekey,
                   const datrw::Eformat& format)
    {
      return (readDSFF(filename, verbose, tracekey, datrw::anyID(format)));
    }

    /*----------------------------------------------------------------------*/

    //! read complete list of SFF files with trace selection
    TSFileList readSSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose,
                        Ttracelistkey tracekey,
                        const datrw::Eformat& format)
    {
      return (readSSFF(flist, verbose, tracekey, datrw::anyID(format)));
    }

    //! read complete list of SFF files with trace selection
    TDFileList readDSFF(const tfxx::cmdline::Tparsed& flist,
                        const bool& verbose,
                        Ttracelistkey tracekey,
                        const datrw::Eformat& format)
    {
      return (readDSFF(flist, verbose, tracekey, datrw::anyID(format)));
    }

254
255
  } // namespace sff
} // namespace ts
thomas.forbriger's avatar
thomas.forbriger committed
256

257
/* ----- END OF cmdlinefiles.cc ----- */