NodePath.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. }
  16. NodePath::NodePath(const String &from)
  17. {
  18. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  19. }
  20. NodePath::NodePath(const char *contents)
  21. {
  22. String from = contents;
  23. godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
  24. }
  25. String NodePath::get_name(const int idx) const
  26. {
  27. godot_string str = godot::api->godot_node_path_get_name(&_node_path, idx);
  28. return *(String *) &str;
  29. }
  30. int NodePath::get_name_count() const
  31. {
  32. return godot::api->godot_node_path_get_name_count(&_node_path);
  33. }
  34. String NodePath::get_subname(const int idx) const
  35. {
  36. godot_string str = godot::api->godot_node_path_get_subname(&_node_path, idx);
  37. return *(String *) &str;
  38. }
  39. int NodePath::get_subname_count() const
  40. {
  41. return godot::api->godot_node_path_get_subname_count(&_node_path);
  42. }
  43. bool NodePath::is_absolute() const
  44. {
  45. return godot::api->godot_node_path_is_absolute(&_node_path);
  46. }
  47. bool NodePath::is_empty() const
  48. {
  49. return godot::api->godot_node_path_is_empty(&_node_path);
  50. }
  51. NodePath::operator String() const
  52. {
  53. godot_string str = godot::api->godot_node_path_as_string(&_node_path);
  54. return *(String *) &str;
  55. }
  56. bool NodePath::operator ==(const NodePath& other)
  57. {
  58. return godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path);
  59. }
  60. void NodePath::operator =(const NodePath& other)
  61. {
  62. godot::api->godot_node_path_destroy(&_node_path);
  63. String other_string = (String) other;
  64. godot::api->godot_node_path_new(&_node_path, (godot_string *) &other_string);
  65. }
  66. NodePath::~NodePath()
  67. {
  68. godot::api->godot_node_path_destroy(&_node_path);
  69. }
  70. }