⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcadb.h

📁 高性能嵌入式数据库在高并发的环境下使用最好是64位系统比较好
💻 H
📖 第 1 页 / 共 2 页
字号:
/* Retrieve a record in an abstract database object.   `adb' specifies the abstract database object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   If successful, the return value is the pointer to the region of the value of the corresponding   record.  `NULL' is returned if no record corresponds.   Because an additional zero code is appended at the end of the region of the return value,   the return value can be treated as a character string.  Because the region of the return   value is allocated with the `malloc' call, it should be released with the `free' call when   it is no longer in use. */void *tcadbget(TCADB *adb, const void *kbuf, int ksiz, int *sp);/* Retrieve a string record in an abstract database object.   `adb' specifies the abstract database object.   `kstr' specifies the string of the key.   If successful, the return value is the string of the value of the corresponding record.   `NULL' is returned if no record corresponds.   Because the region of the return value is allocated with the `malloc' call, it should be   released with the `free' call when it is no longer in use. */char *tcadbget2(TCADB *adb, const char *kstr);/* Get the size of the value of a record in an abstract database object.   `adb' specifies the abstract database object.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   If successful, the return value is the size of the value of the corresponding record, else,   it is -1. */int tcadbvsiz(TCADB *adb, const void *kbuf, int ksiz);/* Get the size of the value of a string record in an abstract database object.   `adb' specifies the abstract database object.   `kstr' specifies the string of the key.   If successful, the return value is the size of the value of the corresponding record, else,   it is -1. */int tcadbvsiz2(TCADB *adb, const char *kstr);/* Initialize the iterator of an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false.   The iterator is used in order to access the key of every record stored in a database. */bool tcadbiterinit(TCADB *adb);/* Get the next key of the iterator of an abstract database object.   `adb' specifies the abstract database object.   `sp' specifies the pointer to the variable into which the size of the region of the return   value is assigned.   If successful, the return value is the pointer to the region of the next key, else, it is   `NULL'.  `NULL' is returned when no record is to be get out of the iterator.   Because an additional zero code is appended at the end of the region of the return value, the   return value can be treated as a character string.  Because the region of the return value is   allocated with the `malloc' call, it should be released with the `free' call when it is no   longer in use.  It is possible to access every record by iteration of calling this function.   It is allowed to update or remove records whose keys are fetched while the iteration.   However, it is not assured if updating the database is occurred while the iteration.  Besides,   the order of this traversal access method is arbitrary, so it is not assured that the order of   storing matches the one of the traversal access. */void *tcadbiternext(TCADB *adb, int *sp);/* Get the next key string of the iterator of an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is the string of the next key, else, it is `NULL'.  `NULL' is   returned when no record is to be get out of the iterator.   Because the region of the return value is allocated with the `malloc' call, it should be   released with the `free' call when it is no longer in use.  It is possible to access every   record by iteration of calling this function.  However, it is not assured if updating the   database is occurred while the iteration.  Besides, the order of this traversal access method   is arbitrary, so it is not assured that the order of storing matches the one of the traversal   access. */char *tcadbiternext2(TCADB *adb);/* Get forward matching keys in an abstract database object.   `adb' specifies the abstract database object.   `pbuf' specifies the pointer to the region of the prefix.   `psiz' specifies the size of the region of the prefix.   `max' specifies the maximum number of keys to be fetched.  If it is negative, no limit is   specified.   The return value is a list object of the corresponding keys.  This function does never fail   and return an empty list even if no key corresponds.   Because the object of the return value is created with the function `tclistnew', it should be   deleted with the function `tclistdel' when it is no longer in use.  Note that this function   may be very slow because every key in the database is scanned. */TCLIST *tcadbfwmkeys(TCADB *adb, const void *pbuf, int psiz, int max);/* Get forward matching string keys in an abstract database object.   `adb' specifies the abstract database object.   `pstr' specifies the string of the prefix.   `max' specifies the maximum number of keys to be fetched.  If it is negative, no limit is   specified.   The return value is a list object of the corresponding keys.  This function does never fail   and return an empty list even if no key corresponds.   Because the object of the return value is created with the function `tclistnew', it should be   deleted with the function `tclistdel' when it is no longer in use.  Note that this function   may be very slow because every key in the database is scanned. */TCLIST *tcadbfwmkeys2(TCADB *adb, const char *pstr, int max);/* Add an integer to a record in an abstract database object.   `adb' specifies the abstract database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `num' specifies the additional value.   If successful, the return value is the summation value, else, it is `INT_MIN'.   If the corresponding record exists, the value is treated as an integer and is added to.  If no   record corresponds, a new record of the additional value is stored. */int tcadbaddint(TCADB *adb, const void *kbuf, int ksiz, int num);/* Add a real number to a record in an abstract database object.   `adb' specifies the abstract database object connected as a writer.   `kbuf' specifies the pointer to the region of the key.   `ksiz' specifies the size of the region of the key.   `num' specifies the additional value.   If successful, the return value is the summation value, else, it is `NAN'.   If the corresponding record exists, the value is treated as a real number and is added to.  If   no record corresponds, a new record of the additional value is stored. */double tcadbadddouble(TCADB *adb, const void *kbuf, int ksiz, double num);/* Synchronize updated contents of an abstract database object with the file and the device.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false. */bool tcadbsync(TCADB *adb);/* Remove all records of an abstract database object.   `adb' specifies the abstract database object.   If successful, the return value is true, else, it is false. */bool tcadbvanish(TCADB *adb);/* Copy the database file of an abstract database object.   `adb' specifies the abstract database object.   `path' specifies the path of the destination file.  If it begins with `@', the trailing   substring is executed as a command line.   If successful, the return value is true, else, it is false.  False is returned if the executed   command returns non-zero code.   The database file is assured to be kept synchronized and not modified while the copying or   executing operation is in progress.  So, this function is useful to create a backup file of   the database file. */bool tcadbcopy(TCADB *adb, const char *path);/* Get the number of records of an abstract database object.   `adb' specifies the abstract database object.   The return value is the number of records or 0 if the object does not connect to any database   instance. */uint64_t tcadbrnum(TCADB *adb);/* Get the size of the database of an abstract database object.   `adb' specifies the abstract database object.   The return value is the size of the database or 0 if the object does not connect to any   database instance. */uint64_t tcadbsize(TCADB *adb);__TCADB_CLINKAGEEND#endif                                   /* duplication check *//* END OF FILE */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -