Input.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 /*
32  * Time.h
33  *
34  * Created on: Aug 31, 2010
35  * Author: mpeura
36  */
37 
38 #include <string>
39 #include <iostream>
40 #include <fstream>
41 
42 #ifndef DRAIN_INPUT_H_
43 #define DRAIN_INPUT_H_
44 
45 #include <drain/Log.h>
46 
47 namespace drain {
48 
50 
55 class Input {
56 
57 public:
58 
60  Input(const std::string & filename, Logger::level_t errorSensivity = LOG_ERR);
61 
63  ~Input();
64 
65  operator std::istream & ();
66 
67  inline
68  operator bool (){
69  return static_cast<bool>(ifstr);
70  };
71 
72  void open(const std::string & filename, Logger::level_t errorSensivity = LOG_ERR);
73 
74 
75 protected:
76 
77  std::ifstream ifstr;
78 
79 };
80 
81 } // drain::
82 
83 
84 #endif /* DRAIN_InPUT_H_ */
85 
Input utility. Opens stdIn with "-". Closes upon destruction.
Definition: Input.h:55
Input(const std::string &filename, Logger::level_t errorSensivity=LOG_ERR)
Opens stdIn with "-".
Definition: Input.cpp:39
~Input()
Closes upon destruction.
Definition: Input.cpp:57
Definition: DataSelector.cpp:1277