dataArgs.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * This file is part of the PikaPython project.
  3. * http://github.com/pikastech/pikapython
  4. *
  5. * MIT License
  6. *
  7. * Copyright (c) 2021 lyon liang6516@outlook.com
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a
  10. * copy of this software and associated documentation files (the "Software"),
  11. * to deal in the Software without restriction, including without limitation
  12. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. * and/or sell copies of the Software, and to permit persons to whom the
  14. * Software is furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  22. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. * DEALINGS IN THE SOFTWARE.
  26. */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. #ifndef _dataArgs__H
  31. #define _dataArgs__H
  32. #include "dataArg.h"
  33. #include "dataLink.h"
  34. #include "dataMemory.h"
  35. #include "dataString.h"
  36. typedef Link Args;
  37. /* operation */
  38. void args_deinit(Args* self);
  39. void args_deinit_stack(Args* self);
  40. void args_deinit_ex(Args* self, pika_bool is_object);
  41. void args_init(Args* self, Args* args);
  42. int32_t args_getSize(Args* self);
  43. LinkNode* args_getNode(Args* self, char* name);
  44. Arg* args_getArgByIndex(Args* self, int index);
  45. Arg* args_getArg(Args* self, char* name);
  46. PIKA_RES args_removeArg(Args* self, Arg* argNow);
  47. PIKA_RES args_moveArg(Args* self, Args* dict, Arg* arg);
  48. Arg* args_getArg_hash(Args* self, Hash nameHash);
  49. PIKA_RES args_setArg(Args* self, Arg* arg);
  50. PIKA_RES args_copyArgByName(Args* self, char* name, Args* directList);
  51. PIKA_RES args_copyArg(Args* self, Arg* argToBeCopy);
  52. ArgType args_getType(Args* self, char* name);
  53. int32_t args_isArgExist_hash(Args* self, Hash nameHash);
  54. int32_t args_isArgExist(Args* self, char* name);
  55. PIKA_RES args_setStr(Args* self, char* name, char* strIn);
  56. PIKA_RES args_setNone(Args* self, char* name);
  57. PIKA_RES args_setStrWithDefaultName(Args* self, char* strIn);
  58. char* args_getStr(Args* self, char* name);
  59. PIKA_RES args_setFloatWithDefaultName(Args* self, pika_float argFloat);
  60. PIKA_RES args_setFloat(Args* self, char* name, pika_float argFloat);
  61. pika_float args_getFloat(Args* self, char* name);
  62. PIKA_RES args_setRef(Args* self, char* name, void* argPointer);
  63. PIKA_RES args_setPtr(Args* self, char* name, void* argPointer);
  64. void* args_getPtr(Args* self, char* name);
  65. PIKA_RES args_setInt(Args* self, char* name, int64_t int64In);
  66. int64_t args_getInt(Args* self, char* name);
  67. pika_bool args_getBool(Args* self, char* name);
  68. char* args_print(Args* self, char* name);
  69. PIKA_RES args_setStructWithSize(Args* self,
  70. char* name,
  71. void* struct_ptr,
  72. uint32_t struct_size);
  73. PIKA_RES args_setHeapStructWithSize(Args* self,
  74. char* name,
  75. void* struct_ptr,
  76. uint32_t struct_size,
  77. void* struct_deinit_fun);
  78. #define args_setStruct(Args_p_self, char_p_name, struct_) \
  79. args_setStructWithSize((Args_p_self), (char_p_name), &(struct_), \
  80. sizeof(struct_))
  81. #define args_setHeapStruct(Args_p_self, char_p_name, struct_, \
  82. struct_deinit_fun) \
  83. args_setHeapStructWithSize((Args_p_self), (char_p_name), &(struct_), \
  84. sizeof(struct_), (void*)struct_deinit_fun)
  85. void* args_getStruct(Args* self, char* name);
  86. PIKA_RES args_set(Args* self, char* name, char* valueStr);
  87. PIKA_RES args_setObjectWithClass(Args* self,
  88. char* objectName,
  89. char* className,
  90. void* objectPtr);
  91. PIKA_RES args_setPtrWithType(Args* self,
  92. char* name,
  93. ArgType type,
  94. void* objPtr);
  95. typedef int32_t (*fn_args_foreach)(Arg* argEach, void* context);
  96. PIKA_RES args_foreach(Args* self, fn_args_foreach eachHandle, void* context);
  97. PIKA_RES args_reverse(Args* self);
  98. char* args_getBuff(Args* self, int32_t size);
  99. PIKA_RES args_pushArg(Args* self, Arg* arg);
  100. PIKA_RES args_pushArg_name(Args* self, char* name, Arg* arg);
  101. void* args_getHeapStruct(Args* self, char* name);
  102. PIKA_RES args_removeArg_notDeinitArg(Args* self, Arg* argNow);
  103. uint8_t* args_getBytes(Args* self, char* name);
  104. PIKA_RES args_setBytes(Args* self, char* name, uint8_t* src, size_t size);
  105. size_t args_getBytesSize(Args* self, char* name);
  106. Args* New_args(Args* args);
  107. char* args_cacheStr(Args* self, char* str);
  108. char* strsFormatArg(Args* out_buffs, char* fmt, Arg* arg);
  109. #endif
  110. #ifdef __cplusplus
  111. }
  112. #endif