📄 tcfdb.h
字号:
ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified. `vstr' specifies the string of the value. If successful, the return value is true, else, it is false. If a record with the same key exists in the database, this function has no effect. */bool tcfdbputkeep3(TCFDB *fdb, const char *kstr, const void *vstr);/* Concatenate a value at the end of the existing 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. `vbuf' specifies the pointer to the region of the value. `vsiz' specifies the size of the region of the value. If the size of the value is greater than the width tuning parameter of the database, the size is cut down to the width. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created. */bool tcfdbputcat(TCFDB *fdb, int64_t id, const void *vbuf, int vsiz);/* Concatenate a value with a decimal key in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `kbuf' specifies the pointer to the region 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 "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified. `ksiz' specifies the size of the region of the key. `vbuf' specifies the pointer to the region of the value. `vsiz' specifies the size of the region of the value. If the size of the value is greater than the width tuning parameter of the database, the size is cut down to the width. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created. */bool tcfdbputcat2(TCFDB *fdb, const void *kbuf, int ksiz, const void *vbuf, int vsiz);/* Concatenate a string value with a decimal key in a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `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 "prev", the number less by one than the minimum ID number of existing records is specified. If it is "max", the maximum ID number of existing records is specified. If it is "next", the number greater by one than the maximum ID number of existing records is specified. `vstr' specifies the string of the value. If successful, the return value is true, else, it is false. If there is no corresponding record, a new record is created. */bool tcfdbputcat3(TCFDB *fdb, const char *kstr, const void *vstr);/* Remove a record of 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 `FDBIDMAX', the maximum ID number of existing records is specified. If successful, the return value is true, else, it is false. */bool tcfdbout(TCFDB *fdb, int64_t id);/* Remove a record with a decimal key of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `kbuf' specifies the pointer to the region 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. `ksiz' specifies the size of the region of the key. If successful, the return value is true, else, it is false. */bool tcfdbout2(TCFDB *fdb, const void *kbuf, int ksiz);/* Remove a string record with a decimal key of a fixed-length database object. `fdb' specifies the fixed-length database object connected as a writer. `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 true, else, it is false. */bool tcfdbout3(TCFDB *fdb, const char *kstr);/* Retrieve a record in a fixed-length database object. `fdb' specifies the fixed-length database object. `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 `FDBIDMAX', the maximum ID number of existing records is specified. `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 *tcfdbget(TCFDB *fdb, int64_t id, int *sp);/* Retrieve a record with a decimal key in a fixed-length database object. `fdb' specifies the fixed-length database object. `kbuf' specifies the pointer to the region 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. `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 *tcfdbget2(TCFDB *fdb, const void *kbuf, int ksiz, int *sp);/* Retrieve a string record 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 string 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. */char *tcfdbget3(TCFDB *fdb, const char *kstr);/* Retrieve a record in a fixed-length database object and write the value into a buffer. `fdb' specifies the fixed-length database object. `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 `FDBIDMAX', the maximum ID number of existing records is specified. `vbuf' specifies the pointer to the buffer into which the value of the corresponding record is written. `max' specifies the size of the buffer. If successful, the return value is the size of the written data, else, it is -1. -1 is returned if no record corresponds to the specified key. Note that an additional zero code is not appended at the end of the region of the writing buffer. */int tcfdbget4(TCFDB *fdb, int64_t id, void *vbuf, int max);/* Get the size of the value of a record in a fixed-length database object. `fdb' specifies the fixed-length database object. `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 `FDBIDMAX', 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 tcfdbvsiz(TCFDB *fdb, int64_t id);/* Get the size of the value with a decimal key in a fixed-length database object. `fdb' specifies the fixed-length database object. `kbuf' specifies the pointer to the region 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. `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 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -