NodePath.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "NodePath.hpp"
  2. #include "String.hpp"
  3. #include "GodotGlobal.hpp"
  4. #include <gdnative/node_path.h>
  5. namespace godot {
  6. NodePath::NodePath()
  7. {
  8. String from = "";
  9. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  10. }
  11. NodePath::NodePath(const NodePath &other)
  12. {
  13. String from = other;
  14. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  15. godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path);
  16. }
  17. NodePath::NodePath(const String &from)
  18. {
  19. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  20. }
  21. NodePath::NodePath(const char *contents)
  22. {
  23. String from = contents;
  24. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  25. }
  26. String NodePath::get_name(const int idx) const
  27. {
  28. godot_string str = godot::api->godot_node_path_get_name(&_node_path, idx);
  29. return *(String *) &str;
  30. }
  31. int NodePath::get_name_count() const
  32. {
  33. return godot::api->godot_node_path_get_name_count(&_node_path);
  34. }
  35. String NodePath::get_subname(const int idx) const
  36. {
  37. godot_string str = godot::api->godot_node_path_get_subname(&_node_path, idx);
  38. return *(String *) &str;
  39. }
  40. int NodePath::get_subname_count() const
  41. {
  42. return godot::api->godot_node_path_get_subname_count(&_node_path);
  43. }
  44. bool NodePath::is_absolute() const
  45. {
  46. return godot::api->godot_node_path_is_absolute(&_node_path);
  47. }
  48. bool NodePath::is_empty() const
  49. {
  50. return godot::api->godot_node_path_is_empty(&_node_path);
  51. }
  52. NodePath::operator String() const
  53. {
  54. godot_string str = godot::api->godot_node_path_as_string(&_node_path);
  55. return *(String *) &str;
  56. }
  57. void NodePath::operator =(const NodePath& other)
  58. {
  59. godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path);
  60. }
  61. NodePath::~NodePath()
  62. {
  63. godot::api->godot_node_path_destroy(&_node_path);
  64. }
  65. }