kcdb.h   kcdb.h 
skipping to change at line 145 skipping to change at line 145
* @return the pointer to the key region of the current record, or NULL on failure. * @return the pointer to the key region of the current record, or NULL on failure.
* @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero * @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero
* code is appended at the end of the region of the return value, the r eturn value can be * code is appended at the end of the region of the return value, the r eturn value can be
* treated as a C-style string. Because the region of the return value is allocated with the * treated as a C-style string. Because the region of the return value is allocated with the
* the new[] operator, it should be released with the delete[] operator when it is no longer * the new[] operator, it should be released with the delete[] operator when it is no longer
* in use. * in use.
*/ */
virtual char* get_key(size_t* sp, bool step = false) = 0; virtual char* get_key(size_t* sp, bool step = false) = 0;
/** /**
* Get the key of the current record. * Get the key of the current record.
* @note Equal to the original Cursor::get_key method except that the p * @note Equal to the original Cursor::get_key method except that a par
arameter and the ameter is a string to
* return value are std::string. The return value should be deleted ex * contain the result and the return value is bool for success.
plicitly by the
* caller.
*/ */
virtual std::string* get_key(bool step = false) = 0; virtual bool get_key(std::string* key, bool step = false) = 0;
/** /**
* Get the value of the current record. * Get the value of the current record.
* @param sp the pointer to the variable into which the size of the reg ion of the return * @param sp the pointer to the variable into which the size of the reg ion of the return
* value is assigned. * value is assigned.
* @param step true to move the cursor to the next record, or false for no move. * @param step true to move the cursor to the next record, or false for no move.
* @return the pointer to the value region of the current record, or NU LL on failure. * @return the pointer to the value region of the current record, or NU LL on failure.
* @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero * @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero
* code is appended at the end of the region of the return value, the r eturn value can be * code is appended at the end of the region of the return value, the r eturn value can be
* treated as a C-style string. Because the region of the return value is allocated with the * treated as a C-style string. Because the region of the return value is allocated with the
* the new[] operator, it should be released with the delete[] operator when it is no longer * the new[] operator, it should be released with the delete[] operator when it is no longer
* in use. * in use.
*/ */
virtual char* get_value(size_t* sp, bool step = false) = 0; virtual char* get_value(size_t* sp, bool step = false) = 0;
/** /**
* Get the value of the current record. * Get the value of the current record.
* @note Equal to the original Cursor::get_value method except that the * @note Equal to the original Cursor::get_value method except that a p
parameter and the arameter is a string
* return value are std::string. The return value should be deleted ex * to contain the result and the return value is bool for success.
plicitly by the
* caller.
*/ */
virtual std::string* get_value(bool step = false) = 0; virtual bool get_value(std::string* value, bool step = false) = 0;
/** /**
* Get a pair of the key and the value of the current record. * Get a pair of the key and the value of the current record.
* @param ksp the pointer to the variable into which the size of the re gion of the return * @param ksp the pointer to the variable into which the size of the re gion of the return
* value is assigned. * value is assigned.
* @param vbp the pointer to the variable into which the pointer to the value region is * @param vbp the pointer to the variable into which the pointer to the value region is
* assigned. * assigned.
* @param vsp the pointer to the variable into which the size of the va lue region is * @param vsp the pointer to the variable into which the size of the va lue region is
* assigned. * assigned.
* @param step true to move the cursor to the next record, or false for no move. * @param step true to move the cursor to the next record, or false for no move.
* @return the pointer to the key region, or NULL on failure. * @return the pointer to the key region, or NULL on failure.
* @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero code is * @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero code is
* appended at the end of each region of the key and the value, each re gion can be treated * appended at the end of each region of the key and the value, each re gion can be treated
* as a C-style string. The return value should be deleted explicitly by the caller with * as a C-style string. The return value should be deleted explicitly by the caller with
* the detele[] operator. * the detele[] operator.
*/ */
virtual char* get(size_t* ksp, const char** vbp, size_t* vsp, bool step = false) = 0; virtual char* get(size_t* ksp, const char** vbp, size_t* vsp, bool step = false) = 0;
/** /**
* Get a pair of the key and the value of the current record. * Get a pair of the key and the value of the current record.
* @param step true to move the cursor to the next record, or false for * @note Equal to the original Cursor::get method except that parameter
no move. s are strings
* @return the pointer to the pair of the key and the value, or NULL on * to contain the result and the return value is bool for success.
failure.
* @note If the cursor is invalidated, NULL is returned. The return va
lue should be deleted
* explicitly by the caller.
*/ */
virtual std::pair<std::string, std::string>* get_pair(bool step = false ) = 0; virtual bool get(std::string* key, std::string* value, bool step = fals e) = 0;
/** /**
* Jump the cursor to the first record for forward scan. * Jump the cursor to the first record for forward scan.
* @return true on success, or false on failure. * @return true on success, or false on failure.
*/ */
virtual bool jump() = 0; virtual bool jump() = 0;
/** /**
* Jump the cursor to a record for forward scan. * Jump the cursor to a record for forward scan.
* @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.
* @return true on success, or false on failure. * @return true on success, or false on failure.
skipping to change at line 415 skipping to change at line 411
* @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
* in use. * in use.
*/ */
virtual char* get(const char* kbuf, size_t ksiz, size_t* sp) = 0; virtual char* get(const char* kbuf, size_t ksiz, size_t* sp) = 0;
/** /**
* Retrieve the value of a record. * Retrieve the value of a record.
* @note Equal to the original DB::get method except that the parameter a * @note Equal to the original DB::get method except that the first param
nd the return value eters is the key
* are std::string. The return value should be deleted explicitly by the * string and the second parameter is a string to contain the result and
caller. the return value is
* bool for success.
*/ */
virtual std::string* get(const std::string& key) = 0; virtual bool get(const std::string& key, std::string* value) = 0;
/** /**
* 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;
skipping to change at line 616 skipping to change at line 613
char* kbuf = visitor.pop(&ksiz); char* kbuf = visitor.pop(&ksiz);
if (!kbuf) { if (!kbuf) {
*sp = 0; *sp = 0;
return NULL; return NULL;
} }
*sp = ksiz; *sp = ksiz;
return kbuf; return kbuf;
} }
/** /**
* Get the key of the current record. * Get the key of the current record.
* @note Equal to the original Cursor::key method except that the param * @note Equal to the original Cursor::get_key method except that a par
eter and the return ameter is a string to
* value are std::string. * contain the result and the return value is bool for success.
*/ */
std::string* get_key(bool step = false) { bool get_key(std::string* key, bool step = false) {
_assert_(true); _assert_(key);
size_t ksiz; size_t ksiz;
char* kbuf = get_key(&ksiz, step); char* kbuf = get_key(&ksiz, step);
if (!kbuf) return NULL; if (!kbuf) return false;
std::string* key = new std::string(kbuf, ksiz); key->clear();
key->append(kbuf, ksiz);
delete[] kbuf; delete[] kbuf;
return key; return true;
} }
/** /**
* Get the value of the current record. * Get the value of the current record.
* @param sp the pointer to the variable into which the size of the reg ion of the return * @param sp the pointer to the variable into which the size of the reg ion of the return
* value is assigned. * value is assigned.
* @param step true to move the cursor to the next record, or false for no move. * @param step true to move the cursor to the next record, or false for no move.
* @return the pointer to the value region of the current record, or NU LL on failure. * @return the pointer to the value region of the current record, or NU LL on failure.
* @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero * @note If the cursor is invalidated, NULL is returned. Because an ad ditional zero
* code is appended at the end of the region of the return value, the r eturn value can be * code is appended at the end of the region of the return value, the r eturn value can be
* treated as a C-style string. Because the region of the return value is allocated with the * treated as a C-style string. Because the region of the return value is allocated with the
skipping to change at line 681 skipping to change at line 679
char* vbuf = visitor.pop(&vsiz); char* vbuf = visitor.pop(&vsiz);
if (!vbuf) { if (!vbuf) {
*sp = 0; *sp = 0;
return NULL; return NULL;
} }
*sp = vsiz; *sp = vsiz;
return vbuf; return vbuf;
} }
/** /**
* Get the value of the current record. * Get the value of the current record.
* @note Equal to the original Cursor::value method except that the par * @note Equal to the original Cursor::get_value method except that a p
ameter and the return arameter is a string
* value are std::string. * to contain the result and the return value is bool for success.
*/ */
std::string* get_value(bool step = false) { bool get_value(std::string* value, bool step = false) {
_assert_(true); _assert_(value);
size_t vsiz; size_t vsiz;
char* vbuf = get_value(&vsiz, step); char* vbuf = get_value(&vsiz, step);
if (!vbuf) return NULL; if (!vbuf) return false;
std::string* value = new std::string(vbuf, vsiz); value->clear();
value->append(vbuf, vsiz);
delete[] vbuf; delete[] vbuf;
return value; return true;
} }
/** /**
* Get a pair of the key and the value of the current record. * Get a pair of the key and the value of the current record.
* @param ksp the pointer to the variable into which the size of the re gion of the return * @param ksp the pointer to the variable into which the size of the re gion of the return
* value is assigned. * value is assigned.
* @param vbp the pointer to the variable into which the pointer to the value region is * @param vbp the pointer to the variable into which the pointer to the value region is
* assigned. * assigned.
* @param vsp the pointer to the variable into which the size of the va lue region is * @param vsp the pointer to the variable into which the size of the va lue region is
* assigned. * assigned.
* @param step true to move the cursor to the next record, or false for no move. * @param step true to move the cursor to the next record, or false for no move.
skipping to change at line 753 skipping to change at line 752
visitor.clear(); visitor.clear();
*ksp = 0; *ksp = 0;
*vbp = NULL; *vbp = NULL;
*vsp = 0; *vsp = 0;
return NULL; return NULL;
} }
return visitor.pop(ksp, vbp, vsp); return visitor.pop(ksp, vbp, vsp);
} }
/** /**
* Get a pair of the key and the value of the current record. * Get a pair of the key and the value of the current record.
* @return the pointer to the pair of the key and the value, or NULL on * @note Equal to the original Cursor::get method except that parameter
failure. s are strings
* @note If the cursor is invalidated, NULL is returned. The return va * to contain the result and the return value is bool for success.
lue should be deleted
* explicitly by the caller.
*/ */
std::pair<std::string, std::string>* get_pair(bool step = false) { bool get(std::string* key, std::string* value, bool step = false) {
_assert_(true); _assert_(key && value);
typedef std::pair<std::string, std::string> Record;
class VisitorImpl : public Visitor { class VisitorImpl : public Visitor {
public: public:
explicit VisitorImpl() : rec_(NULL) {} explicit VisitorImpl(std::string* key, std::string* value) :
Record* pop() { key_(key), value_(value), ok_(false) {}
return rec_; bool ok() {
return ok_;
} }
private: private:
const char* visit_full(const char* kbuf, size_t ksiz, const char* visit_full(const char* kbuf, size_t ksiz,
const char* vbuf, size_t vsiz, size_t* sp) { const char* vbuf, size_t vsiz, size_t* sp) {
std::string key(kbuf, ksiz); key_->clear();
std::string value(vbuf, vsiz); key_->append(kbuf, ksiz);
rec_ = new Record(key, value); value_->clear();
value_->append(vbuf, vsiz);
ok_ = true;
return NOP; return NOP;
} }
Record* rec_; std::string* key_;
std::string* value_;
bool ok_;
}; };
VisitorImpl visitor; VisitorImpl visitor(key, value);
if (!accept(&visitor, false, step)) return NULL; if (!accept(&visitor, false, step)) return false;
return visitor.pop(); return visitor.ok();
} }
/** /**
* Get the database object. * Get the database object.
* @return the database object. * @return the database object.
*/ */
virtual BasicDB* db() = 0; virtual BasicDB* db() = 0;
/** /**
* Get the last happened error. * Get the last happened error.
* @return the last happened error. * @return the last happened error.
*/ */
skipping to change at line 1775 skipping to change at line 1777
if (!vbuf) { if (!vbuf) {
set_error(_KCCODELINE_, Error::NOREC, "no record"); set_error(_KCCODELINE_, Error::NOREC, "no record");
*sp = 0; *sp = 0;
return NULL; return NULL;
} }
*sp = vsiz; *sp = vsiz;
return vbuf; return vbuf;
} }
/** /**
* Retrieve the value of a record. * Retrieve the value of a record.
* @note Equal to the original DB::get method except that the parameter a * @note Equal to the original DB::get method except that the first param
nd the return value eters is the key
* are std::string. The return value should be deleted explicitly by the * string and the second parameter is a string to contain the result and
caller. the return value is
* bool for success.
*/ */
std::string* get(const std::string& key) { bool get(const std::string& key, std::string* value) {
_assert_(true); _assert_(value);
size_t vsiz; size_t vsiz;
char* vbuf = get(key.c_str(), key.size(), &vsiz); char* vbuf = get(key.c_str(), key.size(), &vsiz);
if (!vbuf) return NULL; if (!vbuf) return false;
std::string* value = new std::string(vbuf, vsiz); value->clear();
value->append(vbuf, vsiz);
delete[] vbuf; delete[] vbuf;
return value; return true;
} }
/** /**
* 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.
*/ */
 End of changes. 26 change blocks. 
68 lines changed or deleted 67 lines changed or added


 kcutil.h   kcutil.h 
skipping to change at line 589 skipping to change at line 589
* @param strmap a string map to contain the result. * @param strmap a string map to contain the result.
*/ */
void getsysinfo(std::map<std::string, std::string>* strmap); void getsysinfo(std::map<std::string, std::string>* strmap);
/** /**
* Set the standard streams into the binary mode. * Set the standard streams into the binary mode.
*/ */
void setstdiobin(); void setstdiobin();
/** /**
* Dummy test driver.
* @return always true.
*/
bool _dummytest();
/**
* Convert a decimal string to an integer. * Convert a decimal string to an integer.
*/ */
inline int64_t atoi(const char* str) { inline int64_t atoi(const char* str) {
_assert_(str); _assert_(str);
while (*str > '\0' && *str <= ' ') { while (*str > '\0' && *str <= ' ') {
str++; str++;
} }
int32_t sign = 1; int32_t sign = 1;
int64_t num = 0; int64_t num = 0;
if (*str == '-') { if (*str == '-') {
skipping to change at line 2079 skipping to change at line 2085
} }
/** /**
* Free a region on memory. * Free a region on memory.
*/ */
inline void xfree(void* ptr) { inline void xfree(void* ptr) {
_assert_(true); _assert_(true);
std::free(ptr); std::free(ptr);
} }
/**
* Dummy test driver.
*/
inline bool _dummytest() {
_assert_(true);
std::ostringstream oss;
oss << INT8MAX << INT16MAX << INT32MAX << INT64MAX;
oss << INT8MIN << INT16MIN << INT32MIN << INT64MIN;
oss << UINT8MAX << UINT16MAX << UINT32MAX << UINT64MAX;
oss << VERSION << LIBVER << LIBREV << FMTVER << SYSNAME;
oss << BIGEND << CLOCKTICK << PAGESIZE << FEATURES;
oss << NUMBUFSIZ << MEMMAXSIZ;
return oss.tellp() > 0;
}
} // common namespace } // common namespace
#endif // duplication check #endif // duplication check
// END OF FILE // END OF FILE
 End of changes. 2 change blocks. 
0 lines changed or deleted 21 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/