📄 tcfdb.h
字号:
If successful, the return value is the size of the value of the corresponding record, else, it is -1. */int tcfdbvsiz2(TCFDB *fdb, const void *kbuf, int ksiz);/* Get the size of the string value with a decimal key in a fixed-length database object. `fdb' specifies the fixed-length database object. `kstr' specifies the string of the decimal key. It should be more than 0. If it is "min", the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If successful, the return value is the size of the value of the corresponding record, else, it is -1. */int tcfdbvsiz3(TCFDB *fdb, const char *kstr);/* Initialize the iterator of a fixed-length database object. `fdb' specifies the fixed-length 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 tcfdbiterinit(TCFDB *fdb);/* Get the next ID number of the iterator of a fixed-length database object. `fdb' specifies the fixed-length database object. If successful, the return value is the next ID number of the iterator, else, it is 0. 0 is returned when no record is to be get out of the iterator. 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. The order of this traversal access method is ascending of the ID number. */uint64_t tcfdbiternext(TCFDB *fdb);/* Get the next decimay key of the iterator of a fixed-length database object. `fdb' specifies the fixed-length 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 decimal 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. The order of this traversal access method is ascending of the ID number. */void *tcfdbiternext2(TCFDB *fdb, int *sp);/* Get the next decimay key string of the iterator of a fixed-length database object. `fdb' specifies the fixed-length database object. If successful, the return value is the string of the next decimal 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. It is allowed to update or remove records whose keys are fetched while the iteration. The order of this traversal access method is ascending of the ID number. */char *tcfdbiternext3(TCFDB *fdb);/* Get range matching ID numbers in a fixed-length database object. `fdb' specifies the fixed-length database object. `lower' specifies the lower limit of the range. If it is `FDBIDMIN', the minimum ID is specified. `upper' specifies the upper limit of the range. If it is `FDBIDMAX', the maximum ID is specified. `max' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified. `np' specifies the pointer to the variable into which the number of elements of the return value is assigned. If successful, the return value is the pointer to an array of ID numbers of the corresponding records. `NULL' is returned on failure. This function does never fail and return an empty array even if no key 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. */uint64_t *tcfdbrange(TCFDB *fdb, int64_t lower, int64_t upper, int max, int *np);/* Get range matching decimal keys in a fixed-length database object. `fdb' specifies the fixed-length database object. `lbuf' specifies the pointer to the region of the lower key. If it is "min", the minimum ID number of existing records is specified. `lsiz' specifies the size of the region of the lower key. `ubuf' specifies the pointer to the region of the upper key. If it is "max", the maximum ID number of existing records is specified. `usiz' specifies the size of the region of the upper key. `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 decimal 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 *tcfdbrange2(TCFDB *fdb, const void *lbuf, int lsiz, const void *ubuf, int usiz, int max);/* Get range matching decimal keys with strings in a fixed-length database object. `fdb' specifies the fixed-length database object. `lstr' specifies the string of the lower key. If it is "min", the minimum ID number of existing records is specified. `ustr' specifies the string of the upper key. If it is "max", the maximum ID number of existing records is specified. `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 decimal 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 *tcfdbrange3(TCFDB *fdb, const char *lstr, const char *ustr, int max);/* Get keys with an interval notation in a fixed-length database object. `fdb' specifies the fixed-length database object. `ibuf' specifies the pointer to the region of the interval notation. `isiz' specifies the size of the region of the interval notation. `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 decimal 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 *tcfdbrange4(TCFDB *fdb, const void *ibuf, int isiz, int max);/* Get keys with an interval notation string in a fixed-length database object. `fdb' specifies the fixed-length database object. `istr' specifies the pointer to the region of the interval notation string. `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 decimal 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 *tcfdbrange5(TCFDB *fdb, const void *istr, int max);/* Add an integer to a record in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records is specified. If it is `FDBIDPREV', the number less by one than the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than the maximum ID number of existing records is specified. `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 tcfdbaddint(TCFDB *fdb, int64_t id, int num);/* Add a real number to a record in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `id' specifies the ID number. It should be more than 0. If it is `FDBIDMIN', the minimum ID number of existing records is specified. If it is `FDBIDPREV', the number less by one than the minimum ID number of existing records is specified. If it is `FDBIDMAX', the maximum ID number of existing records is specified. If it is `FDBIDNEXT', the number greater by one than the maximum ID number of existing records is specified. `num' specifies the additional value. If successful, the return value is the summation value, else, it is Not-a-Number. 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 tcfdbadddouble(TCFDB *fdb, int64_t id, double num);/* Synchronize updated contents of a fixed-length database object with the file and the device. `fdb' specifies the fixed-length database object connected as a writer. If successful, the return value is true, else, it is false. This function is useful when another process connects to the same database file. */bool tcfdbsync(TCFDB *fdb);/* Optimize the file of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `width' specifies the width of the value of each record. If it is not more than 0, the current setting is not changed. `limsiz' specifies the limit size of the database file. If it is not more than 0, the current setting is not changed. If successful, the return value is true, else, it is false. */bool tcfdboptimize(TCFDB *fdb, int32_t width, int64_t limsiz);/* Remove all records of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. If successful, the return value is true, else, it is false. */bool tcfdbvanish(TCFDB *fdb);/* Copy the database file of a fixed-length database object. `fdb' specifies the fixed-length 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 tcfdbcopy(TCFDB *fdb, const char *path);/* Begin the transaction of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. If successful, the return value is true, else, it is false. The database is locked by the thread while the transaction so that only one transaction can be activated with a database object at the same time. Thus, the serializable isolation level is assumed if every database operation is performed in the transaction. All updated regions are kept track of by write ahead logging while the transaction. If the database is closed during
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -