kcdb.h   kcdb.h 
skipping to change at line 339 skipping to change at line 339
* Set the value of a record. * Set the value of a record.
* @note Equal to the original DB::append method except that the paramete rs are std::string. * @note Equal to the original DB::append method except that the paramete rs are std::string.
*/ */
virtual bool append(const std::string& key, const std::string& value) = 0 ; virtual bool append(const std::string& key, const std::string& value) = 0 ;
/** /**
* Add a number to the numeric integer value of a record. * Add a number to the numeric integer 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 num the additional number. * @param num the additional number.
* @return the result value, or INT64_MIN on failure. * @return the result value, or INT64_MIN on failure.
* @note If no record corresponds to the key, a new record is created wit
h the initial value
* set by the additional value. The value is serialized as an 8-byte bin
ary integer in
* big-endian order, not a decimal string. If existing value is not 8-by
te, this function
* fails.
*/ */
virtual int64_t increment(const char* kbuf, size_t ksiz, int64_t num) = 0 ; virtual int64_t increment(const char* kbuf, size_t ksiz, int64_t num) = 0 ;
/** /**
* Add a number to the numeric integer value of a record. * Add a number to the numeric integer value of a record.
* @note Equal to the original DB::increment method except that the param eter is std::string. * @note Equal to the original DB::increment method except that the param eter is std::string.
*/ */
virtual int64_t increment(const std::string& key, int64_t num) = 0; virtual int64_t increment(const std::string& key, int64_t num) = 0;
/** /**
* Add a number to the numeric double value of a record. * Add a number to the numeric double 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 num the additional number. * @param num the additional number.
* @return the result value, or Not-a-number on failure. * @return the result value, or Not-a-number on failure.
* @note If no record corresponds to the key, a new record is created wit
h the initial value
* set by the additional value. The value is serialized as an 16-byte bi
nary fixed-point
* number in big-endian order, not a decimal string. If existing value i
s not 16-byte, this
* function fails.
*/ */
virtual double increment_double(const char* kbuf, size_t ksiz, double num ) = 0; virtual double increment_double(const char* kbuf, size_t ksiz, double num ) = 0;
/** /**
* Add a number to the numeric double value of a record. * Add a number to the numeric double value of a record.
* @note Equal to the original DB::increment_double method except that th e parameter is * @note Equal to the original DB::increment_double method except that th e parameter is
* std::string. * std::string.
*/ */
virtual double increment_double(const std::string& key, double num) = 0; virtual double increment_double(const std::string& key, double num) = 0;
/** /**
* Perform compare-and-swap. * Perform compare-and-swap.
skipping to change at line 1446 skipping to change at line 1454
bool append(const std::string& key, const std::string& value) { bool append(const std::string& key, const std::string& value) {
_assert_(true); _assert_(true);
return append(key.c_str(), key.size(), value.c_str(), value.size()); return append(key.c_str(), key.size(), value.c_str(), value.size());
} }
/** /**
* Add a number to the numeric value of a record. * Add a number to the numeric 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 num the additional number. * @param num the additional number.
* @return the result value, or INT64_MIN on failure. * @return the result value, or INT64_MIN on failure.
* @note If no record corresponds to the key, a new record is created wit
h the initial value
* set by the additional value. The value is serialized as an 8-byte bin
ary integer in
* big-endian order, not a decimal string. If existing value is not 8-by
te, this function
* fails.
*/ */
int64_t increment(const char* kbuf, size_t ksiz, int64_t num) { int64_t increment(const char* kbuf, size_t ksiz, int64_t num) {
_assert_(kbuf && ksiz <= MEMMAXSIZ); _assert_(kbuf && ksiz <= MEMMAXSIZ);
class VisitorImpl : public Visitor { class VisitorImpl : public Visitor {
public: public:
explicit VisitorImpl(int64_t num) : num_(num), big_(0) {} explicit VisitorImpl(int64_t num) : num_(num), big_(0) {}
int64_t num() { int64_t num() {
return num_; return num_;
} }
private: private:
skipping to change at line 1505 skipping to change at line 1517
int64_t increment(const std::string& key, int64_t num) { int64_t increment(const std::string& key, int64_t num) {
_assert_(true); _assert_(true);
return increment(key.c_str(), key.size(), num); return increment(key.c_str(), key.size(), num);
} }
/** /**
* Add a number to the numeric double value of a record. * Add a number to the numeric double 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 num the additional number. * @param num the additional number.
* @return the result value, or Not-a-number on failure. * @return the result value, or Not-a-number on failure.
* @note If no record corresponds to the key, a new record is created wit
h the initial value
* set by the additional value. The value is serialized as an 16-byte bi
nary fixed-point
* number in big-endian order, not a decimal string. If existing value i
s not 16-byte, this
* function fails.
*/ */
double increment_double(const char* kbuf, size_t ksiz, double num) { double increment_double(const char* kbuf, size_t ksiz, double num) {
_assert_(kbuf && ksiz <= MEMMAXSIZ); _assert_(kbuf && ksiz <= MEMMAXSIZ);
class VisitorImpl : public Visitor { class VisitorImpl : public Visitor {
public: public:
explicit VisitorImpl(double num) : DECUNIT(1000000000000000LL), num_( num), buf_() {} explicit VisitorImpl(double num) : DECUNIT(1000000000000000LL), num_( num), buf_() {}
double num() { double num() {
return num_; return num_;
} }
private: private:
 End of changes. 4 change blocks. 
0 lines changed or deleted 28 lines changed or added


 kcutil.h   kcutil.h 
skipping to change at line 293 skipping to change at line 293
* Split a string with delimiters. * Split a string with delimiters.
* @param str the string. * @param str the string.
* @param delims the delimiters. * @param delims the delimiters.
* @param elems a vector object into which the result elements are pushed. * @param elems a vector object into which the result elements are pushed.
* @return the number of result elements. * @return the number of result elements.
*/ */
size_t strsplit(const std::string& str, const std::string& delims, size_t strsplit(const std::string& str, const std::string& delims,
std::vector<std::string>* elems); std::vector<std::string>* elems);
/** /**
* Serialize a string vector object into a string object.
* @param src the source object.
* @param dest the destination object.
*/
void strvecdump(const std::vector<std::string>& src, std::string* dest);
/**
* Deserialize a string object into a string vector object.
* @param src the destination object.
* @param dest the source object.
*/
void strvecload(const std::string& src, std::vector<std::string>* dest);
/**
* Serialize a string vector object into a string object.
* @param src the source object.
* @param dest the destination object.
*/
void strmapdump(const std::map<std::string, std::string>& src, std::string*
dest);
/**
* Deserialize a string object into a string map object.
* @param src the destination object.
* @param dest the source object.
*/
void strmapload(const std::string& src, std::map<std::string, std::string>*
dest);
/**
* Encode a serial object by hexadecimal encoding. * Encode a serial object by hexadecimal encoding.
* @param buf the pointer to the region. * @param buf the pointer to the region.
* @param size the size of the region. * @param size the size of the region.
* @return the result string. * @return the result string.
* @note Because the region of the return value is allocated with the the n ew[] operator, it * @note Because the region of the return value is allocated with the the n ew[] operator, it
* should be released with the delete[] operator when it is no longer in us e. * should be released with the delete[] operator when it is no longer in us e.
*/ */
char* hexencode(const void* buf, size_t size); char* hexencode(const void* buf, size_t size);
/** /**
skipping to change at line 1348 skipping to change at line 1376
break; break;
} }
it++; it++;
} }
std::string col(pv, it); std::string col(pv, it);
elems->push_back(col); elems->push_back(col);
return elems->size(); return elems->size();
} }
/** /**
* Serialize a string vector object into a string object.
*/
inline void strvecdump(const std::vector<std::string>& src, std::string* de
st) {
_assert_(dest);
std::vector<std::string>::const_iterator it = src.begin();
std::vector<std::string>::const_iterator itend = src.end();
size_t dsiz = 1;
while (it != itend) {
dsiz += 2 + it->size();
it++;
}
dest->reserve(dest->size() + dsiz);
it = src.begin();
while (it != itend) {
char nbuf[NUMBUFSIZ];
size_t nsiz = writevarnum(nbuf, it->size());
dest->append(nbuf, nsiz);
dest->append(it->data(), it->size());
it++;
}
}
/**
* Deserialize a string object into a string vector object.
*/
inline void strvecload(const std::string& src, std::vector<std::string>* de
st) {
_assert_(dest);
const char* rp = src.data();
size_t size = src.size();
while (size > 0) {
uint64_t vsiz;
size_t step = readvarnum(rp, size, &vsiz);
rp += step;
size -= step;
if (vsiz > size) break;
dest->push_back(std::string(rp, vsiz));
rp += vsiz;
size -= vsiz;
}
}
/**
* Serialize a string vector object into a string object.
*/
inline void strmapdump(const std::map<std::string, std::string>& src, std::
string* dest) {
_assert_(dest);
std::map<std::string, std::string>::const_iterator it = src.begin();
std::map<std::string, std::string>::const_iterator itend = src.end();
size_t dsiz = 1;
while (it != itend) {
dsiz += 4 + it->first.size() + it->second.size();
it++;
}
dest->reserve(dest->size() + dsiz);
it = src.begin();
while (it != itend) {
char nbuf[NUMBUFSIZ*2];
size_t nsiz = writevarnum(nbuf, it->first.size());
nsiz += writevarnum(nbuf + nsiz, it->second.size());
dest->append(nbuf, nsiz);
dest->append(it->first.data(), it->first.size());
dest->append(it->second.data(), it->second.size());
it++;
}
}
/**
* Deserialize a string object into a string map object.
*/
inline void strmapload(const std::string& src, std::map<std::string, std::s
tring>* dest) {
_assert_(dest);
const char* rp = src.data();
int64_t size = src.size();
while (size > 1) {
uint64_t ksiz;
size_t step = readvarnum(rp, size, &ksiz);
rp += step;
size -= step;
if (size < 1) break;
uint64_t vsiz;
step = readvarnum(rp, size, &vsiz);
rp += step;
size -= step;
int64_t rsiz = ksiz + vsiz;
if (rsiz > size) break;
(*dest)[std::string(rp, ksiz)] = std::string(rp + ksiz, vsiz);
rp += rsiz;
size -= rsiz;
}
}
/**
* Encode a serial object by hexadecimal encoding. * Encode a serial object by hexadecimal encoding.
*/ */
inline char* hexencode(const void* buf, size_t size) { inline char* hexencode(const void* buf, size_t size) {
_assert_(buf && size <= MEMMAXSIZ); _assert_(buf && size <= MEMMAXSIZ);
const unsigned char* rp = (const unsigned char*)buf; const unsigned char* rp = (const unsigned char*)buf;
char* zbuf = new char[size*2+1]; char* zbuf = new char[size*2+1];
char* wp = zbuf; char* wp = zbuf;
for (const unsigned char* ep = rp + size; rp < ep; rp++) { for (const unsigned char* ep = rp + size; rp < ep; rp++) {
int32_t num = *rp >> 4; int32_t num = *rp >> 4;
if (num < 10) { if (num < 10) {
 End of changes. 2 change blocks. 
0 lines changed or deleted 126 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/