本文整理汇总了C++中Name::appendSegmentOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::appendSegmentOffset方法的具体用法?C++ Name::appendSegmentOffset怎么用?C++ Name::appendSegmentOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::appendSegmentOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fin
NdnServer(std::string fileName, size_t segSize, size_t contentsize, int signORnot){
using namespace std;
isSign = signORnot;
ifstream fin(fileName.c_str(), fstream::binary);
fin.seekg(0, fin.end);
m_FileSize = fin.tellg();
fin.seekg(0, fin.beg);
fin.read(fileBuffer, m_FileSize);
fin.close();
m_SegmentSize = segSize * 1024;
m_ContentSize = contentsize * 1024;
m_TotalPacketNum = m_FileSize / m_ContentSize + 1;
cout << "Finish reading file\n";
std::cout << "Total file size:\t" << m_FileSize << std::endl ;
std::cout << "m_SegmentSize is:\t" << m_SegmentSize << std::endl ;
std::cout << "m_TotalSegNum is:\t" << m_FileSize / m_SegmentSize + 1 << std::endl ;
std::cout << "m_ContentSize is:\t" << m_ContentSize << std::endl ;
std::cout << "Total packet num is:\t" << m_FileSize / m_ContentSize + 1 << std::endl ;
timeval start, end;
gettimeofday(&start, 0);
for(int id = 0;id < m_TotalPacketNum; id++){
Name fileName = Name("askfile");
fileName.appendNumber(xxx);
fileName.appendSegment(1024);
fileName.appendSegmentOffset(id);
shared_ptr<Data> data = make_shared<Data>(fileName);
if(isSign == 1)
m_keyChain.sign(*data);
else
m_keyChain.signWithSha256(*data);
m_store.push_back(data);
if(id == m_TotalPacketNum - 1)
std::cout <<"Finish signing last datapacket\n";
}
gettimeofday(&end, 0);
double totalTime =(1000000.0 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec ) / 1000000;
std::cout << "Signing cost is:\t" << totalTime <<" s" << std::endl;
};