kcdb.h   kcdb.h 
skipping to change at line 436 skipping to change at line 436
* Retrieve the value of a record. * Retrieve the value of a record.
* @param kbuf the pointer to the key region. * @param kbuf the pointer to the key region.
* @param ksiz the size of the key region. * @param ksiz the size of the key region.
* @param vbuf the pointer to the buffer into which the value of the corr esponding record is * @param vbuf the pointer to the buffer into which the value of the corr esponding record is
* written. * written.
* @param max the size of the buffer. * @param max the size of the buffer.
* @return the size of the value, or -1 on failure. * @return the size of the value, or -1 on failure.
*/ */
virtual int32_t get(const char* kbuf, size_t ksiz, char* vbuf, size_t max ) = 0; virtual int32_t get(const char* kbuf, size_t ksiz, char* vbuf, size_t max ) = 0;
/** /**
* Check the existence of a record.
* @param kbuf the pointer to the key region.
* @param ksiz the size of the key region.
* @return the size of the value, or -1 on failure.
*/
virtual int32_t check(const char* kbuf, size_t ksiz) = 0;
/**
* Check the existence of a record.
* @note Equal to the original DB::check method except that the parameter
is std::string.
*/
virtual int32_t check(const std::string& key) = 0;
/**
* Remove all records. * Remove all records.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
virtual bool clear() = 0; virtual bool clear() = 0;
/** /**
* Get the number of records. * Get the number of records.
* @return the number of records, or -1 on failure. * @return the number of records, or -1 on failure.
*/ */
virtual int64_t count() = 0; virtual int64_t count() = 0;
/** /**
skipping to change at line 2000 skipping to change at line 2012
VisitorImpl visitor(vbuf, max); VisitorImpl visitor(vbuf, max);
if (!accept(kbuf, ksiz, &visitor, false)) return -1; if (!accept(kbuf, ksiz, &visitor, false)) return -1;
int32_t vsiz = visitor.vsiz(); int32_t vsiz = visitor.vsiz();
if (vsiz < 0) { if (vsiz < 0) {
set_error(_KCCODELINE_, Error::NOREC, "no record"); set_error(_KCCODELINE_, Error::NOREC, "no record");
return -1; return -1;
} }
return vsiz; return vsiz;
} }
/** /**
* Check the existence of a record.
* @param kbuf the pointer to the key region.
* @param ksiz the size of the key region.
* @return the size of the value, or -1 on failure.
*/
int32_t check(const char* kbuf, size_t ksiz) {
class VisitorImpl : public Visitor {
public:
explicit VisitorImpl() : vsiz_(-1) {}
int32_t vsiz() {
return vsiz_;
}
private:
const char* visit_full(const char* kbuf, size_t ksiz,
const char* vbuf, size_t vsiz, size_t* sp) {
vsiz_ = vsiz;
return NOP;
}
size_t vsiz_;
};
VisitorImpl visitor;
if (!accept(kbuf, ksiz, &visitor, false)) return -1;
int32_t vsiz = visitor.vsiz();
if (vsiz < 0) {
set_error(_KCCODELINE_, Error::NOREC, "no record");
return -1;
}
return vsiz;
}
/**
* Check the existence of a record.
* @note Equal to the original DB::check method except that the parameter
is std::string.
*/
int32_t check(const std::string& key) {
return check(key.data(), key.size());
}
/**
* Retrieve the value of a record and remove it atomically. * Retrieve the value of a record and remove it atomically.
* @param kbuf the pointer to the key region. * @param kbuf the pointer to the key region.
* @param ksiz the size of the key region. * @param ksiz the size of the key region.
* @param sp the pointer to the variable into which the size of the regio n of the return * @param sp the pointer to the variable into which the size of the regio n of the return
* value is assigned. * value is assigned.
* @return the pointer to the value region of the corresponding record, o r NULL on failure. * @return the pointer to the value region of the corresponding record, o r NULL on failure.
* @note If no record corresponds to the key, NULL is returned. Because an additional zero * @note If no record corresponds to the key, NULL is returned. Because an additional zero
* code is appended at the end of the region of the return value, the ret urn value can be * code is appended at the end of the region of the return value, the ret urn value can be
* treated as a C-style string. Because the region of the return value i s allocated with the * treated as a C-style string. Because the region of the return value i s allocated with the
* the new[] operator, it should be released with the delete[] operator w hen it is no longer * the new[] operator, it should be released with the delete[] operator w hen it is no longer
 End of changes. 2 change blocks. 
0 lines changed or deleted 51 lines changed or added


 kcdbext.h   kcdbext.h 
skipping to change at line 1101 skipping to change at line 1101
if (omode_ == 0) { if (omode_ == 0) {
set_error(_KCCODELINE_, BasicDB::Error::INVALID, "not opened"); set_error(_KCCODELINE_, BasicDB::Error::INVALID, "not opened");
return false; return false;
} }
if (!cache_) { if (!cache_) {
set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ; set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ;
return false; return false;
} }
bool err = false; bool err = false;
if (!clean_dbs(kbuf, ksiz)) err = true; if (!clean_dbs(kbuf, ksiz)) err = true;
cache_->append(kbuf, ksiz, vbuf, vsiz); cache_->set(kbuf, ksiz, vbuf, vsiz);
csiz_ += ksiz + vsiz; csiz_ += ksiz + vsiz;
if (csiz_ > clim_ && !flush_cache()) err = false; if (csiz_ > clim_ && !flush_cache()) err = false;
return !err; return !err;
} }
/** /**
* Set the value of a record. * Set the value of a record.
* @note Equal to the original DB::set method except that the parameters are std::string. * @note Equal to the original DB::set method except that the parameters are std::string.
*/ */
bool set(const std::string& key, const std::string& value) { bool set(const std::string& key, const std::string& value) {
_assert_(true); _assert_(true);
skipping to change at line 1140 skipping to change at line 1140
} }
if (!cache_) { if (!cache_) {
set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ; set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ;
return false; return false;
} }
if (check_impl(kbuf, ksiz)) { if (check_impl(kbuf, ksiz)) {
set_error(_KCCODELINE_, BasicDB::Error::DUPREC, "record duplication") ; set_error(_KCCODELINE_, BasicDB::Error::DUPREC, "record duplication") ;
return false; return false;
} }
bool err = false; bool err = false;
cache_->append(kbuf, ksiz, vbuf, vsiz); cache_->set(kbuf, ksiz, vbuf, vsiz);
csiz_ += ksiz + vsiz; csiz_ += ksiz + vsiz;
if (csiz_ > clim_ && !flush_cache()) err = false; if (csiz_ > clim_ && !flush_cache()) err = false;
return !err; return !err;
} }
/** /**
* Set the value of a record. * Set the value of a record.
* @note Equal to the original DB::add method except that the parameters are std::string. * @note Equal to the original DB::add method except that the parameters are std::string.
*/ */
bool add(const std::string& key, const std::string& value) { bool add(const std::string& key, const std::string& value) {
_assert_(true); _assert_(true);
skipping to change at line 1180 skipping to change at line 1180
if (!cache_) { if (!cache_) {
set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ; set_error(_KCCODELINE_, BasicDB::Error::INVALID, "permission denied") ;
return false; return false;
} }
if (!check_impl(kbuf, ksiz)) { if (!check_impl(kbuf, ksiz)) {
set_error(_KCCODELINE_, BasicDB::Error::NOREC, "no record"); set_error(_KCCODELINE_, BasicDB::Error::NOREC, "no record");
return false; return false;
} }
bool err = false; bool err = false;
if (!clean_dbs(kbuf, ksiz)) err = true; if (!clean_dbs(kbuf, ksiz)) err = true;
cache_->append(kbuf, ksiz, vbuf, vsiz); cache_->set(kbuf, ksiz, vbuf, vsiz);
csiz_ += ksiz + vsiz; csiz_ += ksiz + vsiz;
if (csiz_ > clim_ && !flush_cache()) err = false; if (csiz_ > clim_ && !flush_cache()) err = false;
return !err; return !err;
} }
/** /**
* Replace the value of a record. * Replace the value of a record.
* @note Equal to the original DB::replace method except that the paramet ers are std::string. * @note Equal to the original DB::replace method except that the paramet ers are std::string.
*/ */
bool replace(const std::string& key, const std::string& value) { bool replace(const std::string& key, const std::string& value) {
_assert_(true); _assert_(true);
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 kclangc.h   kclangc.h 
skipping to change at line 537 skipping to change at line 537
* value is assigned. * value is assigned.
* @return the pointer to the value region of the corresponding record, or NULL on failure. * @return the pointer to the value region of the corresponding record, or NULL on failure.
* @note If no record corresponds to the key, NULL is returned. Because an additional zero * @note If no record corresponds to the key, NULL is returned. Because an additional zero
* code is appended at the end of the region of the return value, the retur n value can be * code is appended at the end of the region of the return value, the retur n value can be
* treated as a C-style string. The region of the return value should be r eleased with the * treated as a C-style string. The region of the return value should be r eleased with the
* kcfree function when it is no longer in use. * kcfree function when it is no longer in use.
*/ */
char* kcdbget(KCDB* db, const char* kbuf, size_t ksiz, size_t* sp); char* kcdbget(KCDB* db, const char* kbuf, size_t ksiz, size_t* sp);
/** /**
* Check the existence of a record.
* @param db a database object.
* @param kbuf the pointer to the key region.
* @param ksiz the size of the key region.
* @return the size of the value, or -1 on failure.
*/
int32_t kcdbcheck(KCDB* db, const char* kbuf, size_t ksiz);
/**
* Retrieve the value of a record. * Retrieve the value of a record.
* @param db a database object. * @param db a database object.
* @param kbuf the pointer to the key region. * @param kbuf the pointer to the key region.
* @param ksiz the size of the key region. * @param ksiz the size of the key region.
* @param vbuf the pointer to the buffer into which the value of the corres ponding record is * @param vbuf the pointer to the buffer into which the value of the corres ponding record is
* written. * written.
* @param max the size of the buffer. * @param max the size of the buffer.
* @return the size of the value, or -1 on failure. * @return the size of the value, or -1 on failure.
*/ */
int32_t kcdbgetbuf(KCDB* db, const char* kbuf, size_t ksiz, char* vbuf, siz e_t max); int32_t kcdbgetbuf(KCDB* db, const char* kbuf, size_t ksiz, char* vbuf, siz e_t max);
 End of changes. 1 change blocks. 
0 lines changed or deleted 9 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/