libzypp: zypp/base/InputStream.h Source File

libzypp 17.25.10

InputStream.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_INPUTSTREAM_H
13 #define ZYPP_BASE_INPUTSTREAM_H
14
15 #include <iosfwd>
16
17 #include <zypp/base/PtrTypes.h>
18 #include <zypp/base/DefaultIntegral.h>
19 #include <zypp/Pathname.h>
20
22 namespace zypp
23 {
24
26 //
27 // CLASS NAME : InputStream
28 //
56 class InputStream
57 {
58 public:
60 InputStream();
61
63 InputStream( std::istream & stream_r,
64 const std::string & name_r = std::string() );
65
67 InputStream( const Pathname & file_r );
68
70 InputStream( const Pathname & file_r,
71 const std::string & name_r );
72
74 InputStream( const std::string & file_r );
75
77 InputStream( const std::string & file_r,
78 const std::string & name_r );
79
81 InputStream( const char * file_r );
82
84 InputStream( const char * file_r,
85 const std::string & name_r );
86
88 ~InputStream();
89
93 std::istream & stream() const
94 { return *_stream; }
95
97 operator std::istream &() const
98 { return *_stream; }
99
107 const std::string & name() const
108 { return _name; }
109
111 const Pathname & path() const
112 { return _path; }
113
118 std::streamoff size() const
119 { return _size; }
120
127 void setSize( std::streamoff val_r )
128 { _size = val_r; }
129
130 private:
131 Pathname _path;
132 shared_ptr<std::istream> _stream;
133 std::string _name;
134 DefaultIntegral<std::streamoff,-1> _size;
135 };
137
139 std::ostream & operator<<( std::ostream & str, const InputStream & obj );
140
142 } // namespace zypp
144 #endif // ZYPP_BASE_INPUTSTREAM_H
DefaultIntegral.h
Pathname.h
PtrTypes.h
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition: DefaultIntegral.h:42
zypp::InputStream
Helper to create and pass std::istream.
Definition: InputStream.h:57
zypp::InputStream::_size
DefaultIntegral< std::streamoff,-1 > _size
Definition: InputStream.h:134
zypp::InputStream::stream
std::istream & stream() const
The std::istream.
Definition: InputStream.h:93
zypp::InputStream::name
const std::string & name() const
Name of the std::istream.
Definition: InputStream.h:107
zypp::InputStream::size
std::streamoff size() const
Size of the input stream (informal).
Definition: InputStream.h:118
zypp::InputStream::path
const Pathname & path() const
Path to the input file or empty if no file.
Definition: InputStream.h:111
zypp::InputStream::~InputStream
~InputStream()
Dtor.
Definition: InputStream.cc:158
zypp::InputStream::_path
Pathname _path
Definition: InputStream.h:131
zypp::InputStream::_stream
shared_ptr< std::istream > _stream
Definition: InputStream.h:132
zypp::InputStream::_name
std::string _name
Definition: InputStream.h:133
zypp::InputStream::InputStream
InputStream()
Default ctor providing std::cin.
Definition: InputStream.cc:62
zypp::InputStream::setSize
void setSize(std::streamoff val_r)
Set the size of the input stream.
Definition: InputStream.h:127
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147