Blame gio/giomm/pollableoutputstream.h

Packit 306c40
// Generated by gmmproc 2.54.1 -- DO NOT MODIFY!
Packit 306c40
#ifndef _GIOMM_POLLABLEOUTPUTSTREAM_H
Packit 306c40
#define _GIOMM_POLLABLEOUTPUTSTREAM_H
Packit 306c40
Packit 306c40
Packit 306c40
#include <glibmm/ustring.h>
Packit 306c40
#include <sigc++/sigc++.h>
Packit 306c40
Packit 306c40
/* Copyright (C) 2012 The giomm Development Team
Packit 306c40
 *
Packit 306c40
 * This library is free software; you can redistribute it and/or
Packit 306c40
 * modify it under the terms of the GNU Lesser General Public
Packit 306c40
 * License as published by the Free Software Foundation; either
Packit 306c40
 * version 2.1 of the License, or (at your option) any later version.
Packit 306c40
 *
Packit 306c40
 * This library is distributed in the hope that it will be useful,
Packit 306c40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 306c40
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 306c40
 * Lesser General Public License for more details.
Packit 306c40
 *
Packit 306c40
 * You should have received a copy of the GNU Lesser General Public
Packit 306c40
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
Packit 306c40
 */
Packit 306c40
Packit 306c40
#include <glibmm/interface.h>
Packit 306c40
Packit 306c40
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
typedef struct _GPollableOutputStreamInterface GPollableOutputStreamInterface;
Packit 306c40
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Packit 306c40
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
using GPollableOutputStream = struct _GPollableOutputStream;
Packit 306c40
using GPollableOutputStreamClass = struct _GPollableOutputStreamClass;
Packit 306c40
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Packit 306c40
Packit 306c40
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
namespace Gio
Packit 306c40
{ class PollableOutputStream_Class; } // namespace Gio
Packit 306c40
#endif // DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
Packit 306c40
namespace Gio
Packit 306c40
{
Packit 306c40
Packit 306c40
class Cancellable;
Packit 306c40
Packit 306c40
//TODO: Instead derive from OutputStream, when we can break ABI,
Packit 306c40
//because the GPollableOutputStream interface requires the GOutputStream interface.
Packit 306c40
//LoadableIcon does a similar thing correctly, for instance.
Packit 306c40
Packit 306c40
/** PollableOutputStream - Interface for pollable output streams.
Packit 306c40
 * PollableOutputStream is implemented by OutputStreams that can be polled for
Packit 306c40
 * readiness to write. This can be used when interfacing with a non-GIO API
Packit 306c40
 * that expects UNIX-file-descriptor-style asynchronous I/O rather than
Packit 306c40
 * GIO-style.
Packit 306c40
 * @newin{2,34}
Packit 306c40
 */
Packit 306c40
Packit 306c40
class PollableOutputStream : public Glib::Interface
Packit 306c40
{
Packit 306c40
  
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
Packit 306c40
public:
Packit 306c40
  using CppObjectType = PollableOutputStream;
Packit 306c40
  using CppClassType = PollableOutputStream_Class;
Packit 306c40
  using BaseObjectType = GPollableOutputStream;
Packit 306c40
  using BaseClassType = GPollableOutputStreamInterface;
Packit 306c40
Packit 306c40
  // noncopyable
Packit 306c40
  PollableOutputStream(const PollableOutputStream&) = delete;
Packit 306c40
  PollableOutputStream& operator=(const PollableOutputStream&) = delete;
Packit 306c40
Packit 306c40
private:
Packit 306c40
  friend class PollableOutputStream_Class;
Packit 306c40
  static CppClassType pollableoutputstream_class_;
Packit 306c40
Packit 306c40
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Packit 306c40
protected:
Packit 306c40
  /**
Packit 306c40
   * You should derive from this class to use it.
Packit 306c40
   */
Packit 306c40
  PollableOutputStream();
Packit 306c40
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
  /** Called by constructors of derived classes. Provide the result of
Packit 306c40
   * the Class init() function to ensure that it is properly
Packit 306c40
   * initialized.
Packit 306c40
   *
Packit 306c40
   * @param interface_class The Class object for the derived type.
Packit 306c40
   */
Packit 306c40
  explicit PollableOutputStream(const Glib::Interface_Class& interface_class);
Packit 306c40
Packit 306c40
public:
Packit 306c40
  // This is public so that C++ wrapper instances can be
Packit 306c40
  // created for C instances of unwrapped types.
Packit 306c40
  // For instance, if an unexpected C type implements the C interface.
Packit 306c40
  explicit PollableOutputStream(GPollableOutputStream* castitem);
Packit 306c40
Packit 306c40
protected:
Packit 306c40
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Packit 306c40
Packit 306c40
public:
Packit 306c40
Packit 306c40
  PollableOutputStream(PollableOutputStream&& src) noexcept;
Packit 306c40
  PollableOutputStream& operator=(PollableOutputStream&& src) noexcept;
Packit 306c40
Packit 306c40
  ~PollableOutputStream() noexcept override;
Packit 306c40
Packit 306c40
  static void add_interface(GType gtype_implementer);
Packit 306c40
Packit 306c40
  /** Get the GType for this class, for use with the underlying GObject type system.
Packit 306c40
   */
Packit 306c40
  static GType get_type()      G_GNUC_CONST;
Packit 306c40
Packit 306c40
#ifndef DOXYGEN_SHOULD_SKIP_THIS
Packit 306c40
  static GType get_base_type() G_GNUC_CONST;
Packit 306c40
#endif
Packit 306c40
Packit 306c40
  ///Provides access to the underlying C GObject.
Packit 306c40
  GPollableOutputStream*       gobj()       { return reinterpret_cast<GPollableOutputStream*>(gobject_); }
Packit 306c40
Packit 306c40
  ///Provides access to the underlying C GObject.
Packit 306c40
  const GPollableOutputStream* gobj() const { return reinterpret_cast<GPollableOutputStream*>(gobject_); }
Packit 306c40
Packit 306c40
private:
Packit 306c40
Packit 306c40
Packit 306c40
public:
Packit 306c40
  
Packit 306c40
  /** Checks if @a stream is actually pollable. Some classes may implement
Packit 306c40
   * PollableOutputStream but have only certain instances of that
Packit 306c40
   * class be pollable. If this method returns <tt>false</tt>, then the behavior
Packit 306c40
   * of other PollableOutputStream methods is undefined.
Packit 306c40
   * 
Packit 306c40
   * For any given stream, the value returned by this method is constant;
Packit 306c40
   * a stream cannot switch from pollable to non-pollable or vice versa.
Packit 306c40
   * 
Packit 306c40
   * @newin{2,28}
Packit 306c40
   * 
Packit 306c40
   * @return <tt>true</tt> if @a stream is pollable, <tt>false</tt> if not.
Packit 306c40
   */
Packit 306c40
  bool can_poll() const;
Packit 306c40
  
Packit 306c40
  /** Checks if @a stream can be written.
Packit 306c40
   * 
Packit 306c40
   * Note that some stream types may not be able to implement this 100%
Packit 306c40
   * reliably, and it is possible that a call to g_output_stream_write()
Packit 306c40
   * after this returns <tt>true</tt> would still block. To guarantee
Packit 306c40
   * non-blocking behavior, you should always use
Packit 306c40
   * g_pollable_output_stream_write_nonblocking(), which will return a
Packit 306c40
   * IO_ERROR_WOULD_BLOCK error rather than blocking.
Packit 306c40
   * 
Packit 306c40
   * @newin{2,28}
Packit 306c40
   * 
Packit 306c40
   * @return <tt>true</tt> if @a stream is writable, <tt>false</tt> if not. If an error
Packit 306c40
   * has occurred on @a stream, this will result in
Packit 306c40
   * g_pollable_output_stream_is_writable() returning <tt>true</tt>, and the
Packit 306c40
   * next attempt to write will return the error.
Packit 306c40
   */
Packit 306c40
  bool is_writable() const;
Packit 306c40
Packit 306c40
  //TODO: _WRAP_METHOD(Glib::RefPtr<Source> create_source(const Glib::RefPtr<Cancellable>& cancellable), g_pollable_output_stream_create_source)
Packit 306c40
Packit 306c40
  
Packit 306c40
  /** Attempts to write up to @a count bytes from @a buffer to @a stream, as
Packit 306c40
   * with g_output_stream_write(). If @a stream is not currently writable,
Packit 306c40
   * this will immediately return IO_ERROR_WOULD_BLOCK, and you can
Packit 306c40
   * use g_pollable_output_stream_create_source() to create a Source
Packit 306c40
   * that will be triggered when @a stream is writable.
Packit 306c40
   * 
Packit 306c40
   * Note that since this method never blocks, you cannot actually
Packit 306c40
   * use @a cancellable to cancel it. However, it will return an error
Packit 306c40
   * if @a cancellable has already been cancelled when you call, which
Packit 306c40
   * may happen if you call this method after a source triggers due
Packit 306c40
   * to having been cancelled.
Packit 306c40
   * 
Packit 306c40
   * Also note that if IO_ERROR_WOULD_BLOCK is returned some underlying
Packit 306c40
   * transports like D/TLS require that you send the same @a buffer and @a count.
Packit 306c40
   * 
Packit 306c40
   * Virtual: write_nonblocking
Packit 306c40
   * 
Packit 306c40
   * @param buffer A buffer to write
Packit 306c40
   * data from.
Packit 306c40
   * @param count The number of bytes you want to write.
Packit 306c40
   * @param cancellable A Cancellable, or <tt>nullptr</tt>.
Packit 306c40
   * @return The number of bytes written, or -1 on error (including
Packit 306c40
   * IO_ERROR_WOULD_BLOCK).
Packit 306c40
   * 
Packit 306c40
   * @throws Glib::Error
Packit 306c40
   */
Packit 306c40
  gssize write_nonblocking(const void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable);
Packit 306c40
Packit 306c40
  /// A write_nonblocking() convenience overload.
Packit 306c40
  gssize write_nonblocking(const void* buffer, gsize count);
Packit 306c40
Packit 306c40
    virtual bool can_poll_vfunc() const;
Packit 306c40
Packit 306c40
    virtual bool is_writable_vfunc() const;
Packit 306c40
Packit 306c40
Packit 306c40
  //TODO:_WRAP_VFUNC(Glib::RefPtr<Source> create_source(const Glib::RefPtr<Cancellable>& cancellable), "create_source")
Packit 306c40
Packit 306c40
  /// @throws Glib::Error.
Packit 306c40
  virtual gssize write_nonblocking_vfunc(const void* buffer, gsize count);
Packit 306c40
Packit 306c40
Packit 306c40
public:
Packit 306c40
Packit 306c40
public:
Packit 306c40
  //C++ methods used to invoke GTK+ virtual functions:
Packit 306c40
Packit 306c40
protected:
Packit 306c40
  //GTK+ Virtual Functions (override these to change behaviour):
Packit 306c40
Packit 306c40
  //Default Signal Handlers::
Packit 306c40
Packit 306c40
Packit 306c40
};
Packit 306c40
Packit 306c40
} // namespace Gio
Packit 306c40
Packit 306c40
Packit 306c40
namespace Glib
Packit 306c40
{
Packit 306c40
  /** A Glib::wrap() method for this object.
Packit 306c40
   *
Packit 306c40
   * @param object The C instance.
Packit 306c40
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
Packit 306c40
   * @result A C++ instance that wraps this C instance.
Packit 306c40
   *
Packit 306c40
   * @relates Gio::PollableOutputStream
Packit 306c40
   */
Packit 306c40
  Glib::RefPtr<Gio::PollableOutputStream> wrap(GPollableOutputStream* object, bool take_copy = false);
Packit 306c40
Packit 306c40
} // namespace Glib
Packit 306c40
Packit 306c40
Packit 306c40
#endif /* _GIOMM_POLLABLEOUTPUTSTREAM_H */
Packit 306c40