本文整理汇总了C++中Package::bufsize方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::bufsize方法的具体用法?C++ Package::bufsize怎么用?C++ Package::bufsize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::bufsize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zht_unparse_meta
//DEPRECATED
struct metadata* zht_unparse_meta(const char* text) {
Package package;
package.ParseFromString(text);
struct metadata* meta = (struct metadata*)malloc(sizeof(struct metadata));
meta->loc = (struct comLocations *) malloc(sizeof(struct comLocations));
meta->key = package.virtualpath().c_str();
meta->k = package.k();
meta->m = package.m();
meta->bufsize = package.bufsize();
meta->fileSize = package.filesize();
meta->encodingLib = package.encodinglib();
return meta;
}
示例2: keyStr
struct metadata * zht_lookup_meta(ZHTClient_c zhtClient, const char * key){
//1. Lookup in ZHT
ZHTClient * zhtcppClient = (ZHTClient *) zhtClient;
string keyStr(key);
string resSerializedPackage;
Package keyPackage;
keyPackage.set_virtualpath(keyStr); //as key
keyPackage.set_isdir(false);
keyPackage.set_replicano(1);
keyPackage.set_operation(1); //1 for look up, 2 for remove, 3 for insert
int res = zhtcppClient->lookup(keyPackage.SerializeAsString(),resSerializedPackage);
dbgprintf("Package Length:%i\n",resSerializedPackage.size());
//2. Parse Package and fill meta
Package package;
package.ParseFromString(resSerializedPackage);
struct metadata* meta = (struct metadata*)malloc(sizeof(struct metadata));
//2.1 General file infos
meta->key = package.virtualpath().c_str();
meta->k = package.k();
meta->m = package.m();
meta->bufsize = package.bufsize();
meta->fileSize = package.filesize();
meta->encodingLib = package.encodinglib();
//2.2 Locations
meta->loc = (struct comLocations *) malloc(sizeof(struct comLocations));
struct comTransfer * current;
struct comTransfer * prev = NULL;
for (int j = package.location_size() -1 ; j >= 0; j--) {
current = (struct comTransfer *) malloc(sizeof(struct comTransfer));
const Package_Location& location = package.location(j);
//const std::string host = location.hostname();
current->hostName = (char *) malloc((location.hostname()).size()+1);
strcpy(current->hostName,location.hostname().c_str());
current->port = location.port();
current->distantChunkName = (char *) malloc((location.distantchunkname()).size()+1);
strcpy(current->distantChunkName,location.distantchunkname().c_str());
dbgprintf("Host (%i):%s - port: %i - chunkname: %s\n",j,location.hostname().c_str(),location.port(), location.distantchunkname().c_str());
current->next = prev;
prev = current;
}
meta->loc->transfers = current;
return meta;
}