1 /**
2 Pre-parsed scene tree path.
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.core.nodepath;
14 
15 import godot.core.string;
16 import godot.c;
17 
18 /**
19 A pre-parsed relative or absolute path in a scene tree, for use with $(D Node.getNode) and similar functions. It can reference a node, a resource within a node, or a property of a node or resource. For instance, `"Path2D/PathFollow2D/Sprite:texture:size"` would refer to the size property of the texture resource on the node named “Sprite” which is a child of the other named nodes in the path. Note that if you want to get a resource, you must end the path with a colon, otherwise the last element will be used as a property name.
20 
21 Exporting a `NodePath` variable will give you a node selection widget in the properties panel of the editor, which can often be useful.
22 
23 A `NodePath` is made up of a list of node names, a list of “subnode” (resource) names, and the name of a property in the final node or resource.
24 */
25 struct NodePath
26 {
27 	@nogc nothrow:
28 	
29 	package(godot) godot_node_path _node_path;
30 	
31 	this(this)
32 	{
33 		godot_node_path other = _node_path;
34 		_godot_api.godot_node_path_new_copy(&_node_path, &other);
35 	}
36 	
37 	this(in String from)
38 	{
39 		_godot_api.godot_node_path_new(&_node_path, &from._godot_string);
40 	}
41 	
42 	this(in string name)
43 	{
44 		String from = String(name);
45 		_godot_api.godot_node_path_new(&_node_path, &from._godot_string);
46 	}
47 	
48 	String getName(in int idx) const
49 	{
50 		godot_string str = _godot_api.godot_node_path_get_name(&_node_path, idx);
51 		return String(str);
52 	}
53 	
54 	int getNameCount() const
55 	{
56 		return _godot_api.godot_node_path_get_name_count(&_node_path);
57 	}
58 	
59 	String getSubname(in int idx) const
60 	{
61 		godot_string str = _godot_api.godot_node_path_get_subname(&_node_path, idx);
62 		return String(str);
63 	}
64 	
65 	int getSubnameCount() const
66 	{
67 		return _godot_api.godot_node_path_get_subname_count(&_node_path);
68 	}
69 	
70 	bool isAbsolute() const
71 	{
72 		return cast(bool)_godot_api.godot_node_path_is_absolute(&_node_path);
73 	}
74 	
75 	bool isEmpty() const
76 	{
77 		return cast(bool)_godot_api.godot_node_path_is_empty(&_node_path);
78 	}
79 	
80 	String str() const
81 	{
82 		godot_string str = _godot_api.godot_node_path_as_string(&_node_path);
83 		return String(str);
84 	}
85 	
86 	/+void opAssign(in ref NodePath other)
87 	{
88 		godot_node_path_copy(&_node_path, &other._node_path);
89 	}+/
90 	
91 	~this()
92 	{
93 		_godot_api.godot_node_path_destroy(&_node_path);
94 	}
95 }