| 1 |
/* |
|---|
| 2 |
* This file is part of gtkD. |
|---|
| 3 |
* |
|---|
| 4 |
* gtkD is free software; you can redistribute it and/or modify |
|---|
| 5 |
* it under the terms of the GNU Lesser General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 3 |
|---|
| 7 |
* of the License, or (at your option) any later version, with |
|---|
| 8 |
* some exceptions, please read the COPYING file. |
|---|
| 9 |
* |
|---|
| 10 |
* gtkD 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 |
|---|
| 13 |
* GNU Lesser General Public License for more details. |
|---|
| 14 |
* |
|---|
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
|---|
| 16 |
* along with gtkD; if not, write to the Free Software |
|---|
| 17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
// generated automatically - do not change |
|---|
| 21 |
// find conversion definition on APILookup.txt |
|---|
| 22 |
// implement new conversion functionalities on the wrap.utils pakage |
|---|
| 23 |
|
|---|
| 24 |
/* |
|---|
| 25 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GMemoryOutputStream.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = MemoryOutputStream |
|---|
| 29 |
* strct = GMemoryOutputStream |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct=GOutputStream |
|---|
| 32 |
* clss = MemoryOutputStream |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: Yes |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* - SeekableIF |
|---|
| 40 |
* prefixes: |
|---|
| 41 |
* - g_memory_output_stream_ |
|---|
| 42 |
* omit structs: |
|---|
| 43 |
* omit prefixes: |
|---|
| 44 |
* omit code: |
|---|
| 45 |
* omit signals: |
|---|
| 46 |
* imports: |
|---|
| 47 |
* - gio.SeekableT |
|---|
| 48 |
* - gio.SeekableIF |
|---|
| 49 |
* structWrap: |
|---|
| 50 |
* module aliases: |
|---|
| 51 |
* local aliases: |
|---|
| 52 |
* overrides: |
|---|
| 53 |
*/ |
|---|
| 54 |
|
|---|
| 55 |
module gio.MemoryOutputStream; |
|---|
| 56 |
|
|---|
| 57 |
public import gtkc.giotypes; |
|---|
| 58 |
|
|---|
| 59 |
private import gtkc.gio; |
|---|
| 60 |
private import glib.ConstructionException; |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
private import gio.SeekableT; |
|---|
| 64 |
private import gio.SeekableIF; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
private import gio.OutputStream; |
|---|
| 69 |
|
|---|
| 70 |
/** |
|---|
| 71 |
* Description |
|---|
| 72 |
* GMemoryOutputStream is a class for using arbitrary |
|---|
| 73 |
* memory chunks as output for GIO streaming output operations. |
|---|
| 74 |
*/ |
|---|
| 75 |
public class MemoryOutputStream : OutputStream, SeekableIF |
|---|
| 76 |
{ |
|---|
| 77 |
|
|---|
| 78 |
/** the main Gtk struct */ |
|---|
| 79 |
protected GMemoryOutputStream* gMemoryOutputStream; |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
public GMemoryOutputStream* getMemoryOutputStreamStruct() |
|---|
| 83 |
{ |
|---|
| 84 |
return gMemoryOutputStream; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
/** the main Gtk struct as a void* */ |
|---|
| 89 |
protected override void* getStruct() |
|---|
| 90 |
{ |
|---|
| 91 |
return cast(void*)gMemoryOutputStream; |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
/** |
|---|
| 95 |
* Sets our main struct and passes it to the parent class |
|---|
| 96 |
*/ |
|---|
| 97 |
public this (GMemoryOutputStream* gMemoryOutputStream) |
|---|
| 98 |
{ |
|---|
| 99 |
if(gMemoryOutputStream is null) |
|---|
| 100 |
{ |
|---|
| 101 |
this = null; |
|---|
| 102 |
return; |
|---|
| 103 |
} |
|---|
| 104 |
//Check if there already is a D object for this gtk struct |
|---|
| 105 |
void* ptr = getDObject(cast(GObject*)gMemoryOutputStream); |
|---|
| 106 |
if( ptr !is null ) |
|---|
| 107 |
{ |
|---|
| 108 |
this = cast(MemoryOutputStream)ptr; |
|---|
| 109 |
return; |
|---|
| 110 |
} |
|---|
| 111 |
super(cast(GOutputStream*)gMemoryOutputStream); |
|---|
| 112 |
this.gMemoryOutputStream = gMemoryOutputStream; |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
protected override void setStruct(GObject* obj) |
|---|
| 116 |
{ |
|---|
| 117 |
super.setStruct(obj); |
|---|
| 118 |
gMemoryOutputStream = cast(GMemoryOutputStream*)obj; |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
// add the Seekable capabilities |
|---|
| 122 |
mixin SeekableT!(GMemoryOutputStream); |
|---|
| 123 |
|
|---|
| 124 |
/** |
|---|
| 125 |
*/ |
|---|
| 126 |
|
|---|
| 127 |
/** |
|---|
| 128 |
* Creates a new GMemoryOutputStream. |
|---|
| 129 |
* If data is non-NULL, the stream will use that for its internal storage. |
|---|
| 130 |
* If realloc_fn is non-NULL, it will be used for resizing the internal |
|---|
| 131 |
* storage when necessary. To construct a fixed-size output stream, |
|---|
| 132 |
* pass NULL as realloc_fn. |
|---|
| 133 |
* $(DDOC_COMMENT example) |
|---|
| 134 |
* Params: |
|---|
| 135 |
* data = pointer to a chunk of memory to use, or NULL |
|---|
| 136 |
* size = the size of data |
|---|
| 137 |
* reallocFunction = a function with realloc() semantics (like g_realloc()) |
|---|
| 138 |
* to be called when data needs to be grown, or NULL |
|---|
| 139 |
* destroyFunction = a function to be called on data when the stream is |
|---|
| 140 |
* finalized, or NULL |
|---|
| 141 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 142 |
*/ |
|---|
| 143 |
public this (void* data, gsize size, GReallocFunc reallocFunction, GDestroyNotify destroyFunction) |
|---|
| 144 |
{ |
|---|
| 145 |
// GOutputStream * g_memory_output_stream_new (gpointer data, gsize size, GReallocFunc realloc_function, GDestroyNotify destroy_function); |
|---|
| 146 |
auto p = g_memory_output_stream_new(data, size, reallocFunction, destroyFunction); |
|---|
| 147 |
if(p is null) |
|---|
| 148 |
{ |
|---|
| 149 |
throw new ConstructionException("null returned by g_memory_output_stream_new(data, size, reallocFunction, destroyFunction)"); |
|---|
| 150 |
} |
|---|
| 151 |
this(cast(GMemoryOutputStream*) p); |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
/** |
|---|
| 155 |
* Gets any loaded data from the ostream. |
|---|
| 156 |
* Note that the returned pointer may become invalid on the next |
|---|
| 157 |
* write or truncate operation on the stream. |
|---|
| 158 |
* Returns: pointer to the stream's data. [transfer none] |
|---|
| 159 |
*/ |
|---|
| 160 |
public void* getData() |
|---|
| 161 |
{ |
|---|
| 162 |
// gpointer g_memory_output_stream_get_data (GMemoryOutputStream *ostream); |
|---|
| 163 |
return g_memory_output_stream_get_data(gMemoryOutputStream); |
|---|
| 164 |
} |
|---|
| 165 |
|
|---|
| 166 |
/** |
|---|
| 167 |
* Gets the size of the currently allocated data area (available from |
|---|
| 168 |
* g_memory_output_stream_get_data()). If the stream isn't |
|---|
| 169 |
* growable (no realloc was passed to g_memory_output_stream_new()) then |
|---|
| 170 |
* this is the maximum size of the stream and further writes |
|---|
| 171 |
* will return G_IO_ERROR_NO_SPACE. |
|---|
| 172 |
* Note that for growable streams the returned size may become invalid on |
|---|
| 173 |
* the next write or truncate operation on the stream. |
|---|
| 174 |
* If you want the number of bytes currently written to the stream, use |
|---|
| 175 |
* g_memory_output_stream_get_data_size(). |
|---|
| 176 |
* Returns: the number of bytes allocated for the data buffer |
|---|
| 177 |
*/ |
|---|
| 178 |
public gsize getSize() |
|---|
| 179 |
{ |
|---|
| 180 |
// gsize g_memory_output_stream_get_size (GMemoryOutputStream *ostream); |
|---|
| 181 |
return g_memory_output_stream_get_size(gMemoryOutputStream); |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
/** |
|---|
| 185 |
* Returns the number of bytes from the start up |
|---|
| 186 |
* to including the last byte written in the stream |
|---|
| 187 |
* that has not been truncated away. |
|---|
| 188 |
* Since 2.18 |
|---|
| 189 |
* Returns: the number of bytes written to the stream |
|---|
| 190 |
*/ |
|---|
| 191 |
public gsize getDataSize() |
|---|
| 192 |
{ |
|---|
| 193 |
// gsize g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream); |
|---|
| 194 |
return g_memory_output_stream_get_data_size(gMemoryOutputStream); |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
/** |
|---|
| 198 |
* Gets any loaded data from the ostream. Ownership of the data |
|---|
| 199 |
* is transferred to the caller; when no longer needed it must be |
|---|
| 200 |
* freed using the free function set in ostream's |
|---|
| 201 |
* "destroy-function" property. |
|---|
| 202 |
* ostream must be closed before calling this function. |
|---|
| 203 |
* Since 2.26 |
|---|
| 204 |
* Returns: the stream's data. [transfer full] |
|---|
| 205 |
*/ |
|---|
| 206 |
public void* stealData() |
|---|
| 207 |
{ |
|---|
| 208 |
// gpointer g_memory_output_stream_steal_data (GMemoryOutputStream *ostream); |
|---|
| 209 |
return g_memory_output_stream_steal_data(gMemoryOutputStream); |
|---|
| 210 |
} |
|---|
| 211 |
} |
|---|