1// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
3/* Copyright (C) 2007 The gtkmm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <giomm/fileinfo.h>
20#include <giomm/iostream.h>
21#include <giomm/seekable.h>
22
23_DEFS(giomm,gio)
24_PINCLUDE(giomm/private/iostream_p.h)
25
26namespace Gio
27{
28
29/** FileIOStream provides input streams that take their content from a file.
30 *
31 * FileInputStream implements Seekable, which allows the input stream to jump to arbitrary positions in the file,
32 * provided the file system of the file allows it.
33 * Use the methods of the Seekable base class for seeking and positioning.
34 *
35 * @ingroup Streams
36 *
37 * @newin{2,22}
38 */
39class GIOMM_API FileIOStream
40: public Gio::IOStream,
41    public Gio::Seekable
42{
43  _CLASS_GOBJECT(FileIOStream, GFileIOStream, G_FILE_IO_STREAM, Gio::IOStream, GIOStream, , , GIOMM_API)
44  _IMPLEMENTS_INTERFACE(Seekable)
45
46public:
47
48  /** Queries a file input stream the given @a attributes. This function blocks
49   * while querying the stream. For the asynchronous (non-blocking) version
50   * of this function, see query_info_async(). While the
51   * stream is blocked, the stream will set the pending flag internally, and
52   * any other operations on the stream will throw a Gio::Error with PENDING.
53   *
54   * @param attributes A file attribute query string.
55   * @param cancellable A Cancellable object.
56   * @return A FileInfo, or an empty RefPtr on error.
57   */
58  Glib::RefPtr<FileInfo> query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*");
59
60  /** Queries a file input stream the given @a attributes. This function blocks
61   * while querying the stream. For the asynchronous (non-blocking) version
62   * of this function, see query_info_async(). While the
63   * stream is blocked, the stream will set the pending flag internally, and
64   * any other operations on the stream will throw a Gio::Error with PENDING.
65   *
66   * @param attributes A file attribute query string.
67   * @return A FileInfo, or an empty RefPtr on error.
68   */
69  Glib::RefPtr<FileInfo> query_info(const std::string& attributes = "*");
70  _IGNORE(g_file_io_stream_query_info)
71
72
73  /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
74   *
75   * The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled,
76   * a Gio::Error with CANCELLED will be thrown.
77   *
78   * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
79   *
80   * @param slot A callback slot which will be called when the request is satisfied.
81   * @param cancellable A Cancellable object which can be used to cancel the operation.
82   * @param attributes A file attribute query string.
83   * @param io_priority The I/O priority of the request.
84   */
85  void query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
86
87  /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
88   *
89   * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
90   *
91   * @param slot A callback slot which will be called when the request is satisfied.
92   * @param attributes A file attribute query string.
93   * @param io_priority The I/O priority of the request.
94   */
95  void query_info_async(const SlotAsyncReady& slot, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
96
97  _IGNORE(g_file_io_stream_query_info_async)
98
99  _WRAP_METHOD(Glib::RefPtr<FileInfo> query_info_finish(const Glib::RefPtr<AsyncResult>& result),
100               g_file_io_stream_query_info_finish,
101               errthrow)
102  _WRAP_METHOD(std::string get_etag() const, g_file_io_stream_get_etag)
103
104};
105
106} // namespace Gio
107
108