yamlwrapper.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * This file is a part of rAthena++.
  3. * Copyright(C) 2017 rAthena Development Team
  4. * https://rathena.org - https://github.com/rathena
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. * Author(s)
  20. * Jittapan Pluemsumran <secret@rathena.org>
  21. */
  22. #pragma once
  23. #ifdef WIN32
  24. #pragma warning(disable:4099) // Damn it, Microsoft! [Secret]
  25. #endif
  26. #ifndef YAMLWRAPPER_H
  27. #define YAMLWRAPPER_H
  28. #ifdef __cplusplus
  29. #include "yaml-cpp/yaml.h"
  30. #include <string>
  31. extern "C" {
  32. #endif
  33. #include "cbasetypes.h"
  34. #ifdef __cplusplus
  35. class yamliterator {
  36. public:
  37. YAML::Node sequence;
  38. unsigned int index;
  39. yamliterator(YAML::Node sequence_);
  40. };
  41. class yamlwrapper {
  42. public:
  43. YAML::Node root;
  44. yamlwrapper(std::string file);
  45. yamlwrapper(YAML::Node node);
  46. yamliterator* iterator();
  47. };
  48. #else
  49. typedef struct yamlwrapper yamlwrapper;
  50. typedef struct yamliterator yamliterator;
  51. #endif
  52. yamlwrapper* yaml_load_file(const char* file_name);
  53. void yaml_destroy_wrapper(yamlwrapper* wrapper);
  54. char* yaml_get_c_string(yamlwrapper* wrapper, const char* key);
  55. int yaml_get_int(yamlwrapper* wrapper, const char* key);
  56. int16 yaml_get_int16(yamlwrapper* wrapper, const char* key);
  57. int32 yaml_get_int32(yamlwrapper* wrapper, const char* key);
  58. int64 yaml_get_int64(yamlwrapper* wrapper, const char* key);
  59. int yaml_get_uint(yamlwrapper* wrapper, const char* key);
  60. int16 yaml_get_uint16(yamlwrapper* wrapper, const char* key);
  61. int32 yaml_get_uint32(yamlwrapper* wrapper, const char* key);
  62. int64 yaml_get_uint64(yamlwrapper* wrapper, const char* key);
  63. bool yaml_get_boolean(yamlwrapper* wrapper, const char* key);
  64. char* yaml_as_c_string(yamlwrapper* wrapper);
  65. int yaml_as_int(yamlwrapper* wrapper);
  66. int16 yaml_as_int16(yamlwrapper* wrapper);
  67. int32 yaml_as_int32(yamlwrapper* wrapper);
  68. int64 yaml_as_int64(yamlwrapper* wrapper);
  69. int yaml_as_uint(yamlwrapper* wrapper);
  70. int16 yaml_as_uint16(yamlwrapper* wrapper);
  71. int32 yaml_as_uint32(yamlwrapper* wrapper);
  72. int64 yaml_as_uint64(yamlwrapper* wrapper);
  73. bool yaml_as_boolean(yamlwrapper* wrapper);
  74. bool yaml_node_is_defined(yamlwrapper* wrapper, const char* key);
  75. yamlwrapper* yaml_get_subnode(yamlwrapper* wrapper, const char* key);
  76. char* yaml_verify_nodes(yamlwrapper* wrapper, int amount, char** nodes);
  77. yamliterator* yaml_get_iterator(yamlwrapper* wrapper);
  78. bool yaml_iterator_is_valid(yamliterator* it);
  79. yamlwrapper* yaml_iterator_first(yamliterator* it);
  80. yamlwrapper* yaml_iterator_next(yamliterator* it);
  81. bool yaml_iterator_has_next(yamliterator* it);
  82. void yaml_iterator_destroy(yamliterator* it);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif /* extern "C" */