1 /**
2 Wrapper to use a PacketPeer over a StreamPeer.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.packetpeerstream;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.packetpeer;
25 import godot.reference;
26 import godot.streampeer;
27 /**
28 Wrapper to use a PacketPeer over a StreamPeer.
29 
30 PacketStreamPeer provides a wrapper for working using packets over a stream. This allows for using packet based code with StreamPeers. PacketPeerStream implements a custom protocol over the StreamPeer, so the user should not read or write to the wrapped StreamPeer directly.
31 */
32 @GodotBaseClass struct PacketPeerStream
33 {
34 	package(godot) enum string _GODOT_internal_name = "PacketPeerStream";
35 public:
36 @nogc nothrow:
37 	union { /** */ godot_object _godot_object; /** */ PacketPeer _GODOT_base; }
38 	alias _GODOT_base this;
39 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
40 	package(godot) __gshared bool _classBindingInitialized = false;
41 	package(godot) static struct GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("get_input_buffer_max_size") GodotMethod!(long) getInputBufferMaxSize;
45 		@GodotName("get_output_buffer_max_size") GodotMethod!(long) getOutputBufferMaxSize;
46 		@GodotName("get_stream_peer") GodotMethod!(StreamPeer) getStreamPeer;
47 		@GodotName("set_input_buffer_max_size") GodotMethod!(void, long) setInputBufferMaxSize;
48 		@GodotName("set_output_buffer_max_size") GodotMethod!(void, long) setOutputBufferMaxSize;
49 		@GodotName("set_stream_peer") GodotMethod!(void, StreamPeer) setStreamPeer;
50 	}
51 	/// 
52 	pragma(inline, true) bool opEquals(in PacketPeerStream other) const
53 	{ return _godot_object.ptr is other._godot_object.ptr; }
54 	/// 
55 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
56 	{ _godot_object.ptr = n; return null; }
57 	/// 
58 	pragma(inline, true) bool opEquals(typeof(null) n) const
59 	{ return _godot_object.ptr is n; }
60 	/// 
61 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
62 	mixin baseCasts;
63 	/// Construct a new instance of PacketPeerStream.
64 	/// Note: use `memnew!PacketPeerStream` instead.
65 	static PacketPeerStream _new()
66 	{
67 		static godot_class_constructor constructor;
68 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("PacketPeerStream");
69 		if(constructor is null) return typeof(this).init;
70 		return cast(PacketPeerStream)(constructor());
71 	}
72 	@disable new(size_t s);
73 	/**
74 	
75 	*/
76 	long getInputBufferMaxSize() const
77 	{
78 		checkClassBinding!(typeof(this))();
79 		return ptrcall!(long)(GDNativeClassBinding.getInputBufferMaxSize, _godot_object);
80 	}
81 	/**
82 	
83 	*/
84 	long getOutputBufferMaxSize() const
85 	{
86 		checkClassBinding!(typeof(this))();
87 		return ptrcall!(long)(GDNativeClassBinding.getOutputBufferMaxSize, _godot_object);
88 	}
89 	/**
90 	
91 	*/
92 	Ref!StreamPeer getStreamPeer() const
93 	{
94 		checkClassBinding!(typeof(this))();
95 		return ptrcall!(StreamPeer)(GDNativeClassBinding.getStreamPeer, _godot_object);
96 	}
97 	/**
98 	
99 	*/
100 	void setInputBufferMaxSize(in long max_size_bytes)
101 	{
102 		checkClassBinding!(typeof(this))();
103 		ptrcall!(void)(GDNativeClassBinding.setInputBufferMaxSize, _godot_object, max_size_bytes);
104 	}
105 	/**
106 	
107 	*/
108 	void setOutputBufferMaxSize(in long max_size_bytes)
109 	{
110 		checkClassBinding!(typeof(this))();
111 		ptrcall!(void)(GDNativeClassBinding.setOutputBufferMaxSize, _godot_object, max_size_bytes);
112 	}
113 	/**
114 	
115 	*/
116 	void setStreamPeer(StreamPeer peer)
117 	{
118 		checkClassBinding!(typeof(this))();
119 		ptrcall!(void)(GDNativeClassBinding.setStreamPeer, _godot_object, peer);
120 	}
121 	/**
122 	
123 	*/
124 	@property long inputBufferMaxSize()
125 	{
126 		return getInputBufferMaxSize();
127 	}
128 	/// ditto
129 	@property void inputBufferMaxSize(long v)
130 	{
131 		setInputBufferMaxSize(v);
132 	}
133 	/**
134 	
135 	*/
136 	@property long outputBufferMaxSize()
137 	{
138 		return getOutputBufferMaxSize();
139 	}
140 	/// ditto
141 	@property void outputBufferMaxSize(long v)
142 	{
143 		setOutputBufferMaxSize(v);
144 	}
145 	/**
146 	The wrapped $(D StreamPeer) object.
147 	*/
148 	@property StreamPeer streamPeer()
149 	{
150 		return getStreamPeer();
151 	}
152 	/// ditto
153 	@property void streamPeer(StreamPeer v)
154 	{
155 		setStreamPeer(v);
156 	}
157 }