NodePath.cpp 2.2 KB

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