1
0

nde_c.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #pragma once
  2. /* C style API.
  3. We'll eventually deprecate the C++ API as it presents a lot of linking challenges
  4. */
  5. #include "../nde_defines.h"
  6. #include "../NDEString.h"
  7. #include <bfc/platform/types.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct nde_database_struct_t { } *nde_database_t;
  12. typedef struct nde_table_struct_t { } *nde_table_t;
  13. typedef struct nde_scanner_t_struct_t { } *nde_scanner_t;
  14. typedef struct nde_field_t_struct_t { } *nde_field_t;
  15. typedef struct nde_filter_struct_t { } *nde_filter_t;
  16. /* Database functions */
  17. // Windows API
  18. #ifdef __cplusplus
  19. #define NDE_DEFAULT_PARAMETER(x) =x
  20. #else
  21. #define NDE_DEFAULT_PARAMETER(x)
  22. #endif
  23. NDE_API void NDE_Init();
  24. NDE_API void NDE_Quit();
  25. NDE_API nde_database_t NDE_CreateDatabase(HINSTANCE hInstance NDE_DEFAULT_PARAMETER(0));
  26. NDE_API void NDE_DestroyDatabase(nde_database_t db);
  27. NDE_API nde_table_t NDE_Database_OpenTable(nde_database_t db, const wchar_t *filename, const wchar_t *filename_index, int create, int cache);
  28. NDE_API void NDE_Database_CloseTable(nde_database_t db, nde_table_t table);
  29. /* Table functions */
  30. NDE_API nde_field_t NDE_Table_NewColumn(nde_table_t table, unsigned char id, const char *name, unsigned char type);
  31. NDE_API nde_field_t NDE_Table_NewColumnW(nde_table_t table, unsigned char id, const wchar_t *name, unsigned char type);
  32. NDE_API void NDE_Table_PostColumns(nde_table_t table);
  33. NDE_API void NDE_Table_AddIndexByID(nde_table_t table, unsigned char id, const char *name);
  34. NDE_API void NDE_Table_AddIndexByIDW(nde_table_t table, unsigned char id, const wchar_t *name);
  35. NDE_API nde_scanner_t NDE_Table_CreateScanner(nde_table_t table);
  36. NDE_API void NDE_Table_DestroyScanner(nde_table_t table, nde_scanner_t scanner);
  37. NDE_API void NDE_Table_Sync(nde_table_t table);
  38. NDE_API void NDE_Table_Compact(nde_table_t table, int *progress NDE_DEFAULT_PARAMETER(0));
  39. NDE_API int NDE_Table_GetRecordsCount(nde_table_t table);
  40. NDE_API nde_field_t NDE_Table_GetColumnByID(nde_table_t table, unsigned char id);
  41. NDE_API nde_field_t NDE_Table_GetColumnByName(nde_table_t table, const char *name);
  42. NDE_API void NDE_Table_SetColumnSearchableByID(nde_table_t table, unsigned char id, int searchable);
  43. /* Scanner functions */
  44. NDE_API int NDE_Scanner_Query(nde_scanner_t scanner, const wchar_t *query);
  45. NDE_API void NDE_Scanner_Search(nde_scanner_t scanner, const wchar_t *search_term);
  46. NDE_API const wchar_t *NDE_Scanner_GetLastQuery(nde_scanner_t scanner);
  47. NDE_API int NDE_Scanner_GetRecordsCount(nde_scanner_t scanner);
  48. NDE_API void NDE_Scanner_New(nde_scanner_t scanner);
  49. NDE_API void NDE_Scanner_Post(nde_scanner_t scanner);
  50. NDE_API void NDE_Scanner_First(nde_scanner_t scanner, int *killswitch NDE_DEFAULT_PARAMETER(0));
  51. NDE_API int NDE_Scanner_Next(nde_scanner_t scanner, int *killswitch NDE_DEFAULT_PARAMETER(0));
  52. NDE_API void NDE_Scanner_Delete(nde_scanner_t scanner);
  53. NDE_API void NDE_Scanner_Edit(nde_scanner_t scanner);
  54. NDE_API int NDE_Scanner_EOF(nde_scanner_t scanner);
  55. NDE_API int NDE_Scanner_BOF(nde_scanner_t scanner);
  56. NDE_API nde_field_t NDE_Scanner_NewFieldByID(nde_scanner_t scanner, unsigned char id);
  57. NDE_API nde_field_t NDE_Scanner_NewFieldByType(nde_scanner_t s, unsigned char type, unsigned char id);
  58. NDE_API nde_field_t NDE_Scanner_NewFieldByName(nde_scanner_t scanner, const char *name);
  59. NDE_API nde_field_t NDE_Scanner_GetFieldByID(nde_scanner_t scanner, unsigned char id);
  60. NDE_API nde_field_t NDE_Scanner_GetFieldByName(nde_scanner_t scanner, const char *name);
  61. NDE_API void NDE_Scanner_AddFilterByID(nde_scanner_t scanner, unsigned char id, nde_field_t field, unsigned char filter_operation);
  62. NDE_API int NDE_Scanner_LocateInteger(nde_scanner_t scanner, unsigned char id, int from, int value,
  63. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  64. NDE_API int NDE_Scanner_LocateString(nde_scanner_t scanner, unsigned char id, int from, const wchar_t *value,
  65. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  66. NDE_API int NDE_Scanner_LocateNDEString(nde_scanner_t scanner, unsigned char id, int from, wchar_t *value,
  67. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  68. NDE_API int NDE_Scanner_LocateFilename(nde_scanner_t scanner, unsigned char id, int from, const wchar_t *value,
  69. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  70. NDE_API int NDE_Scanner_LocateNDEFilename(nde_scanner_t scanner, unsigned char id, int from, wchar_t *value,
  71. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  72. NDE_API int NDE_Scanner_LocateField(nde_scanner_t scanner, unsigned char id, int from, nde_field_t field,
  73. int *nskip NDE_DEFAULT_PARAMETER(0), int compare_mode NDE_DEFAULT_PARAMETER(COMPARE_MODE_EXACT));
  74. NDE_API void NDE_Scanner_DeleteField(nde_scanner_t scanner, nde_field_t field);
  75. NDE_API void NDE_Scanner_RemoveFilters(nde_scanner_t scanner);
  76. typedef int (__cdecl *FieldEnumerator)(void *record, nde_field_t field, void *context);
  77. NDE_API void NDE_Scanner_WalkFields(nde_scanner_t scanner, FieldEnumerator enumerator, void *context);
  78. /* Filter functions */
  79. NDE_API unsigned char NDE_Filter_GetID(nde_filter_t filter);
  80. NDE_API unsigned char NDE_Filter_GetOp(nde_filter_t filter);
  81. NDE_API nde_field_t NDE_Filter_GetData(nde_filter_t filter);
  82. /* Field functions */
  83. NDE_API unsigned char NDE_Field_GetType(nde_field_t field);
  84. NDE_API unsigned char NDE_Field_GetID(nde_field_t field);
  85. /* String Field functions */
  86. NDE_API wchar_t *NDE_StringField_GetString(nde_field_t field); /* returns non-const because it's an NDE string (reference counted, see ndestring.h) */
  87. NDE_API void NDE_StringField_SetNDEString(nde_field_t field, wchar_t *nde_string);
  88. NDE_API void NDE_StringField_SetString(nde_field_t field, const wchar_t *str);
  89. /* IntegerField functions */
  90. NDE_API void NDE_IntegerField_SetValue(nde_field_t field, int value);
  91. NDE_API int NDE_IntegerField_GetValue(nde_field_t field);
  92. NDE_API nde_field_t NDE_IntegerField_Create(int value); /* mainly used for NDE_Scanner_AddFilterByID */
  93. /* Int64Field functions */
  94. NDE_API void NDE_Int64Field_SetValue(nde_field_t field, __int64 value);
  95. NDE_API __int64 NDE_Int64Field_GetValue(nde_field_t field);
  96. NDE_API nde_field_t NDE_Int64Field_Create(__int64 value);
  97. /* BinaryField functions */
  98. // on windows, the data pointer is optionally reference counted via ndestring (ndestring_retain if you plan on keeping it)
  99. NDE_API void *NDE_BinaryField_GetData(nde_field_t field, size_t *length);
  100. NDE_API void NDE_BinaryField_SetData(nde_field_t field, const void *data, size_t length);
  101. /* Int128Field functions */
  102. NDE_API void NDE_Int128Field_SetValue(nde_field_t field, const void *value);
  103. /* ColumnField functions */
  104. NDE_API const wchar_t *NDE_ColumnField_GetFieldName(nde_field_t field);
  105. NDE_API unsigned char NDE_ColumnField_GetDataType(nde_field_t field);
  106. NDE_API unsigned char NDE_ColumnField_GetFieldID(nde_field_t);
  107. NDE_API __time64_t NDE_Time_ApplyConversion(__time64_t value, const wchar_t *str, class TimeParse *tp);
  108. #ifdef __cplusplus
  109. }
  110. #endif