📄 xcuria.h
字号:
* @return the pointer to the region of the value of the corresponding record. * @throw Curia_error if an error occures, no record corresponds, or the size of the value * of the corresponding record is less than `start'. * @note 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 `std::malloc' call, it should be released with the * `std::free' call if it is no longer in use. */ virtual char* get(const char* kbuf, int ksiz, int start = 0, int max = -1, int* sp = 0) throw(Curia_error); /** * Get the size of the value of a record. * @param kbuf the pointer to the region of a key. * @param ksiz the size of the region of the key. If it is negative, the size is assigned * with `std::strlen(kbuf)'. * @return the size of the value of the corresponding record. * @throw Curia_error if an error occures or no record corresponds. * @note Because this function does not read the entity of a record, it is faster than `get'. */ virtual int vsiz(const char* kbuf, int ksiz) throw(Curia_error); /** * Initialize the iterator of the database handle. * @throw Curia_error if an error occures. * @note The iterator is used in order to access the key of every record stored in a database. */ virtual void iterinit() throw(Curia_error); /** * Get the next key of the iterator. * @param sp the pointer to a variable to which the size of the region of the return value is * assigned. If it is 0, it is not used. * @return the pointer to the region of the next key. * @throw Curia_error if an error occures or no record is to be get out of the iterator. * @note 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 `std::malloc' call, it should be released with the * `std::free' call if it is no longer in use. * @note 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. */ virtual char* iternext(int* sp = 0) throw(Curia_error); /** * Set alignment of the database handle. * @param align the basic size of alignment. * @throw Curia_error if an error occures. * @note If alignment is set to a database, the efficiency of overwriting values are improved. * The size of alignment is suggested to be average size of the values of the records to be * stored. If alignment is positive, padding whose size is multiple number of the alignment * is placed. If alignment is negative, as `vsiz' is the size of a value, the size of padding * is calculated with `(vsiz / pow(2, abs(align) - 1))'. Because alignment setting is not * saved in a database, you should specify alignment every opening a database. */ virtual void setalign(int align) throw(Curia_error); /** * Synchronize updating contents with the files and the devices. * @note Curia_error if an error occures. * This function is useful when another process uses the connected database directory. */ virtual void sync() throw(Curia_error); /** * Optimize the database. * @param bnum the number of the elements of each bucket array. If it is not more than 0, * the default value is specified. * @throw Curia_error if an error occures. * @note In an alternating succession of deleting and storing with overwrite or concatenate, * dispensable regions accumulate. This function is useful to do away with them. */ virtual void optimize(int bnum = -1) throw(Curia_error); /** * Get the name of the database. * @return the pointer to the region of the name of the database. * @throw Curia_error if an error occures. * @note Because the region of the return value is allocated with the `std::malloc' call, * it should be released with the `std::free' call if it is no longer in use. */ virtual char* name() throw(Curia_error); /** * Get the total size of database files. * @return the total size of the database files. * @throw Curia_error if an error occures. */ virtual int fsiz() throw(Curia_error); /** * Get the total number of the elements of each bucket array. * @return the total number of the elements of each bucket array. * @throw Curia_error if an error occures. */ virtual int bnum() throw(Curia_error); /** * Get the total number of the used elements of each bucket array. * @return the total number of the used elements of each bucket array. * @throw Curia_error if an error occures. * @note This function is inefficient because it accesses all elements of each bucket array. */ virtual int busenum() throw(Curia_error); /** * Get the number of the records stored in the database. * @return the number of the records stored in the database. * @throw Curia_error if an error occures. */ virtual int rnum() throw(Curia_error); /** * Check whether the database handle is a writer or not. * @return true if the handle is a writer, false if not. * @throw Curia_error if an error occures. */ virtual bool writable() throw(Curia_error); /** * Check whether the database has a fatal error or not. * @return true if the database has a fatal error, false if not. * @throw Curia_error if an error occures. */ virtual bool fatalerror() throw(Curia_error); /** * Get the inode number of the database directory. * @return the inode number of the database directory. * @throw Curia_error if an error occures. */ virtual int inode() throw(Curia_error); /** * Store a large object. * @param kbuf the pointer to the region of a key. * @param ksiz the size of the region of the key. If it is negative, the size is assigned * with `std::strlen(kbuf)'. * @param vbuf the pointer to the region of a value. * @param vsiz the size of the region of the value. If it is negative, the size is assigned * with `std::strlen(vbuf)'. * @param dmode behavior when the key overlaps, by the following values: `Curia::DOVER', * which means the specified value overwrites the existing one, `Curia::DKEEP', which means the * existing value is kept, `Curia::DCAT', which means the specified value is concatenated at * the end of the existing value. * @throw Curia_error if an error occures or replace is cancelled. */ virtual void putlob(const char* kbuf, int ksiz, const char* vbuf, int vsiz, int dmode = Curia::DOVER) throw(Curia_error); /** * Delete a large object. * @param kbuf the pointer to the region of a key. * @param ksiz the size of the region of the key. If it is negative, the size is assigned * with `std::strlen(kbuf)'. * @throw Curia_error if an error occures or no large object corresponds. */ virtual void outlob(const char* kbuf, int ksiz) throw(Curia_error); /** * Retrieve a large object. * @param kbuf the pointer to the region of a key. * @param ksiz the size of the region of the key. If it is negative, the size is assigned * with `std::strlen(kbuf)'. * @param start the offset address of the beginning of the region of the value to be read. * @param max the max size to be read. If it is negative, the size to read is unlimited. * @param sp the pointer to a variable to which the size of the region of the return value * is assigned. If it is 0, it is not used. * @return the pointer to the region of the value of the corresponding large object. * @throw Curia_error if an error occures, no record corresponds, or the size of the value * of the corresponding record is less than `start'. * @note 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 `std::malloc' call, it should be released with the * `std::free' call if it is no longer in use. */ virtual char* getlob(const char* kbuf, int ksiz, int start = 0, int max = -1, int* sp = 0) throw(Curia_error); /** * Get the size of the value of a large object. * @param kbuf the pointer to the region of a key. * @param ksiz the size of the region of the key. If it is negative, the size is assigned * with `std::strlen(kbuf)'. * @return the size of the value of the corresponding large object. * @throw Curia_error if an error occures or no large object corresponds. * @note Because this function does not read the entity of a large object, it is faster than * `getlob'. */ virtual int vsizlob(const char* kbuf, int ksiz) throw(Curia_error); /** * Get the number of the large objects stored in the database. * @return the number of the large objects stored in the database. * @throw Curia_error if an error occures. */ virtual int rnumlob() throw(Curia_error); /** * Store a record. * @param key reference to a key object. * @param val reference to a value object. * @param replace whether the existing value is to be overwritten or not. * @throw Curia_error if an error occures or replace is cancelled. */ virtual void storerec(const Datum& key, const Datum& val, bool replace = true) throw(Curia_error); /** * Delete a record. * @param key reference to a key object. * @throw Curia_error if an error occures or no record corresponds. */ virtual void deleterec(const Datum& key) throw(Curia_error); /** * Fetch a record. * @param key reference to a key object. * @return a temporary instance of the value of the corresponding record. * @throw Curia_error if an error occures or no record corresponds. */ virtual Datum fetchrec(const Datum& key) throw(Curia_error); /** * Get the first key. * @return a temporary instance of the key of the first record. * @throw Curia_error if an error occures or no record corresponds. */ virtual Datum firstkey() throw(Curia_error); /** * Get the next key. * @return a temporary instance of the key of the next record. * @throw Curia_error if an error occures or no record corresponds. */ virtual Datum nextkey() throw(Curia_error); /** * Check whether a fatal error occured or not. * @return true if the database has a fatal error, false if not. * @throw Curia_error if an error occures. */ virtual bool error() throw(Curia_error); //---------------------------------------------------------------- // private member variables //----------------------------------------------------------------private: CURIA *curia; ///< internal database handle //---------------------------------------------------------------- // private member functions //----------------------------------------------------------------private: /** copy constructor: This should not be used. */ Curia(const Curia& curia) throw(Curia_error); /** assignment operator: This should not be used. */ Curia& operator =(const Curia& curia) throw(Curia_error);};#endif /* duplication check *//* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -