本文整理汇总了C++中Package::encodinglib方法的典型用法代码示例。如果您正苦于以下问题:C++ Package::encodinglib方法的具体用法?C++ Package::encodinglib怎么用?C++ Package::encodinglib使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::encodinglib方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: zht_parse_meta
//DEPRECATED
const char* zht_parse_meta(struct metadata* meta) {
Package package;
package.set_virtualpath(meta->key); //as key
package.set_isdir(false);
package.set_replicano(1);
package.set_operation(3); //1 for look up, 2 for remove, 3 for insert
package.set_realfullpath(meta->physicalPath);
// IDA metadata
package.set_k(meta->k);
package.set_m(meta->m);
package.set_encodinglib(meta->encodingLib);
package.set_filesize(meta->fileSize);
package.set_bufsize(meta->bufsize);
std::string serialized = package.SerializeAsString();
cout << serialized << endl;
dbgprintf("Serialized:%s \n",serialized.c_str());
dbgprintf("k:%i,m:%i,encodinglib:%i,filesize:%i \n",package.k(),package.m(),package.encodinglib(),package.filesize());
const char * resString = serialized.c_str();
Package package2;
package2.ParseFromString(string(resString));
dbgprintf("k:%i,m:%i,encodinglib:%i,filesize:%i \n",package2.k(),package2.m(),package2.encodinglib(),package2.filesize());
std::string reborn = string(resString);
Package package3;
package3.ParseFromString(reborn);
dbgprintf("k:%i,m:%i,encodinglib:%i,filesize:%i \n",package3.k(),package3.m(),package3.encodinglib(),package3.filesize());
return resString;
}
示例3: 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;
}