1 /**
2 Data transformation (marshalling) and encoding helpers.
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.marshalls;
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 /**
24 Data transformation (marshalling) and encoding helpers.
25 
26 Provides data transformation and encoding utility functions.
27 */
28 @GodotBaseClass struct MarshallsSingleton
29 {
30 	package(godot) enum string _GODOT_internal_name = "_Marshalls";
31 public:
32 @nogc nothrow:
33 	union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; }
34 	alias _GODOT_base this;
35 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
36 	package(godot) __gshared bool _classBindingInitialized = false;
37 	package(godot) static struct GDNativeClassBinding
38 	{
39 		__gshared:
40 		godot_object _singleton;
41 		immutable char* _singletonName = "Marshalls";
42 		@GodotName("base64_to_raw") GodotMethod!(PoolByteArray, String) base64ToRaw;
43 		@GodotName("base64_to_utf8") GodotMethod!(String, String) base64ToUtf8;
44 		@GodotName("base64_to_variant") GodotMethod!(Variant, String, bool) base64ToVariant;
45 		@GodotName("raw_to_base64") GodotMethod!(String, PoolByteArray) rawToBase64;
46 		@GodotName("utf8_to_base64") GodotMethod!(String, String) utf8ToBase64;
47 		@GodotName("variant_to_base64") GodotMethod!(String, Variant, bool) variantToBase64;
48 	}
49 	/// 
50 	pragma(inline, true) bool opEquals(in MarshallsSingleton other) const
51 	{ return _godot_object.ptr is other._godot_object.ptr; }
52 	/// 
53 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
54 	{ _godot_object.ptr = n; return null; }
55 	/// 
56 	pragma(inline, true) bool opEquals(typeof(null) n) const
57 	{ return _godot_object.ptr is n; }
58 	/// 
59 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
60 	mixin baseCasts;
61 	/// Construct a new instance of MarshallsSingleton.
62 	/// Note: use `memnew!MarshallsSingleton` instead.
63 	static MarshallsSingleton _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_Marshalls");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(MarshallsSingleton)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/**
72 	Returns a decoded $(D PoolByteArray) corresponding to the Base64-encoded string `base64_str`.
73 	*/
74 	PoolByteArray base64ToRaw(in String base64_str)
75 	{
76 		checkClassBinding!(typeof(this))();
77 		return ptrcall!(PoolByteArray)(GDNativeClassBinding.base64ToRaw, _godot_object, base64_str);
78 	}
79 	/**
80 	Returns a decoded string corresponding to the Base64-encoded string `base64_str`.
81 	*/
82 	String base64ToUtf8(in String base64_str)
83 	{
84 		checkClassBinding!(typeof(this))();
85 		return ptrcall!(String)(GDNativeClassBinding.base64ToUtf8, _godot_object, base64_str);
86 	}
87 	/**
88 	Returns a decoded $(D Variant) corresponding to the Base64-encoded string `base64_str`. If `allow_objects` is `true`, decoding objects is allowed.
89 	$(B Warning:) Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
90 	*/
91 	Variant base64ToVariant(in String base64_str, in bool allow_objects = false)
92 	{
93 		checkClassBinding!(typeof(this))();
94 		return ptrcall!(Variant)(GDNativeClassBinding.base64ToVariant, _godot_object, base64_str, allow_objects);
95 	}
96 	/**
97 	Returns a Base64-encoded string of a given $(D PoolByteArray).
98 	*/
99 	String rawToBase64(in PoolByteArray array)
100 	{
101 		checkClassBinding!(typeof(this))();
102 		return ptrcall!(String)(GDNativeClassBinding.rawToBase64, _godot_object, array);
103 	}
104 	/**
105 	Returns a Base64-encoded string of the UTF-8 string `utf8_str`.
106 	*/
107 	String utf8ToBase64(in String utf8_str)
108 	{
109 		checkClassBinding!(typeof(this))();
110 		return ptrcall!(String)(GDNativeClassBinding.utf8ToBase64, _godot_object, utf8_str);
111 	}
112 	/**
113 	Returns a Base64-encoded string of the $(D Variant) `variant`. If `full_objects` is `true`, encoding objects is allowed (and can potentially include code).
114 	*/
115 	String variantToBase64(VariantArg0)(in VariantArg0 variant, in bool full_objects = false)
116 	{
117 		checkClassBinding!(typeof(this))();
118 		return ptrcall!(String)(GDNativeClassBinding.variantToBase64, _godot_object, variant, full_objects);
119 	}
120 }
121 /// Returns: the MarshallsSingleton
122 @property @nogc nothrow pragma(inline, true)
123 MarshallsSingleton Marshalls()
124 {
125 	checkClassBinding!MarshallsSingleton();
126 	return MarshallsSingleton(MarshallsSingleton.GDNativeClassBinding._singleton);
127 }