本文整理汇总了C++中Name::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::append方法的具体用法?C++ Name::append怎么用?C++ Name::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareCertificate
void
Pib::initializeMgmtCert()
{
shared_ptr<IdentityCertificate> mgmtCert = m_db.getMgmtCertificate();
if (mgmtCert == nullptr ||
!m_tpm->doesKeyExistInTpm(mgmtCert->getPublicKeyName(), KEY_CLASS_PRIVATE)) {
// If mgmt cert is set, or corresponding private key of the current mgmt cert is missing,
// generate new mgmt cert
// key name: /localhost/pib/[UserName]/mgmt/dsk-...
Name mgmtKeyName = PIB_PREFIX;
mgmtKeyName.append(m_owner).append(MGMT_LABEL);
std::ostringstream oss;
oss << "dsk-" << time::toUnixTimestamp(time::system_clock::now()).count();
mgmtKeyName.append(oss.str());
// self-sign pib root key
m_mgmtCert = prepareCertificate(mgmtKeyName, RsaKeyParams(),
time::system_clock::now(),
time::system_clock::now() + time::days(7300));
// update management certificate in database
m_db.updateMgmtCertificate(*m_mgmtCert);
}
else
m_mgmtCert = mgmtCert;
}
示例2: runtime_error
virtual uint64_t
expressInterest
(const Interest& interest, const OnData& onData,
const OnTimeout& onTimeout, const OnNetworkNack& onNetworkNack,
WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
{
if (expectedInterest_ != interest.getName())
throw runtime_error("TestFace::expressInterest: Not the expectedInterest_");
bool gotInterestName = false;
Name interestName;
for (size_t i = 0; i < 3; ++i) {
interestName = Name(interest.getName());
if (i == 0)
interestName.append(timeMarkerFirstHop_);
else if (i == 1)
interestName.append(timeMarkerSecondHop_);
else if (i == 2)
interestName.append(timeMarkerThirdHop_);
// matchesName will check the Exclude.
if (interest.matchesName(interestName)) {
gotInterestName = true;
++(*requestCount_);
break;
}
}
if (gotInterestName)
onData(ptr_lib::make_shared<Interest>(interest),
parent_->encryptionKeys[interestName]);
return 0;
}
示例3:
shared_ptr<Data>
Response::toData()
{
Name name;
name.append(m_zone)
.append(m_queryType)
.append(m_rrLabel)
.append(m_rrType);
if (m_version.empty()) {
name.appendVersion();
m_version = name.get(-1);
}
else {
name.append(m_version);
}
shared_ptr<Data> data = make_shared<Data>(name);
if (m_contentType != NDNS_BLOB && m_contentType != NDNS_KEY) {
data->setContent(this->wireEncode());
}
else {
data->setContent(m_appContent);
}
data->setFreshnessPeriod(m_freshnessPeriod);
data->setContentType(m_contentType);
return data;
}
示例4: prefix
TEST_F(TestProducer, ProducerWithLink)
{
Name prefix("/prefix");
Name suffix("/suffix");
Name expectedInterest = prefix;
expectedInterest.append(Encryptor::getNAME_COMPONENT_READ());
expectedInterest.append(suffix);
expectedInterest.append(Encryptor::getNAME_COMPONENT_E_KEY());
MillisecondsSince1970 testTime = fromIsoString("20150101T100001");
int timeoutCount = 0;
// Prepare a TestFace to instantly answer calls to expressInterest.
class TestFace : public Face {
public:
TestFace(const Name& expectedInterest, int* timeoutCount)
: Face("localhost"),
expectedInterest_(expectedInterest),
timeoutCount_(timeoutCount)
{}
virtual uint64_t
expressInterest
(const Interest& interest, const OnData& onData,
const OnTimeout& onTimeout, const OnNetworkNack& onNetworkNack,
WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
{
if (expectedInterest_ != interest.getName())
throw runtime_error("TestFace::expressInterest: Not the expectedInterest_");
if (interest.getLink()->getDelegations().size() != 3)
throw runtime_error
("TestFace::expressInterest: The Interest link does not the expected number of delegates");
++(*timeoutCount_);
onTimeout(ptr_lib::make_shared<Interest>(interest));
return 0;
}
private:
Name expectedInterest_;
int* timeoutCount_;
};
TestFace face(expectedInterest, &timeoutCount);
// Verify that if no response is received, the producer appropriately times
// out. The result vector should not contain elements that have timed out.
Link link;
link.addDelegation(10, Name("/test1"));
link.addDelegation(20, Name("/test2"));
link.addDelegation(100, Name("/test3"));
keyChain->sign(link);
ptr_lib::shared_ptr<ProducerDb> testDb(new Sqlite3ProducerDb(databaseFilePath));
Producer producer(prefix, suffix, &face, keyChain.get(), testDb, 3, link);
producer.createContentKey
(testTime,
bind(&TestProducer::keyTimeoutOnEncryptedKeys, this, _1, &timeoutCount));
}
示例5: Name
Name
NameComponents::streamPrefix(MediaStreamParams::MediaStreamType type, std::string basePrefix)
{
Name n = Name(basePrefix);
n.append(ndnrtcSuffix());
return ((type == MediaStreamParams::MediaStreamType::MediaStreamTypeAudio) ?
n.append(NameComponentAudio) : n.append(NameComponentVideo));
}
示例6: if
Name
RegexTopMatcher::expand(const std::string& expandStr)
{
Name result;
shared_ptr<RegexBackrefManager> backrefManager =
(m_isSecondaryUsed ? m_secondaryBackrefManager : m_primaryBackrefManager);
size_t backrefNo = backrefManager->size();
std::string expand;
if (!expandStr.empty())
expand = expandStr;
else
expand = m_expand;
size_t offset = 0;
while (offset < expand.size())
{
std::string item = getItemFromExpand(expand, offset);
if (item[0] == '<')
{
result.append(item.substr(1, item.size() - 2));
}
if (item[0] == '\\')
{
size_t index = boost::lexical_cast<size_t>(item.substr(1, item.size() - 1));
if (0 == index) {
std::vector<name::Component>::iterator it = m_matchResult.begin();
std::vector<name::Component>::iterator end = m_matchResult.end();
for (; it != end; it++)
result.append(*it);
}
else if (index <= backrefNo)
{
std::vector<name::Component>::const_iterator it =
backrefManager->getBackref(index - 1)->getMatchResult().begin();
std::vector<name::Component>::const_iterator end =
backrefManager->getBackref(index - 1)->getMatchResult().end();
for (; it != end; it++)
result.append(*it);
}
else
BOOST_THROW_EXCEPTION(RegexMatcher::Error("Exceed the range of back reference"));
}
}
return result;
}
示例7: iname
std::vector<boost::shared_ptr<const Interest>>
Pipeliner::getBatch(Name n, SampleClass cls, bool noParity) const
{
std::vector<boost::shared_ptr<const Interest>> interests;
unsigned int nData = sampleEstimator_->getSegmentNumberEstimation(cls, SegmentClass::Data);
for (int segNo = 0; segNo < nData; ++segNo)
{
Name iname(n);
iname.appendSegment(segNo);
boost::shared_ptr<Interest> i = boost::make_shared<Interest>(iname, interestLifetime_);
i->setMustBeFresh(false);
interests.push_back(i);
}
if (!noParity)
{
n.append(NameComponents::NameComponentParity);
unsigned int nParity = sampleEstimator_->getSegmentNumberEstimation(cls, SegmentClass::Parity);
for (int segNo = 0; segNo < nParity; ++segNo)
{
Name iname(n);
iname.appendSegment(segNo);
boost::shared_ptr<Interest> i = boost::make_shared<Interest>(iname, interestLifetime_);
i->setMustBeFresh(false);
interests.push_back(i);
}
}
return interests;
}
示例8: prefix
void
generatePacketsAndPopulateFib(size_t nPackets,
size_t nFibEntries,
size_t fibPrefixLength,
size_t interestNameLength,
size_t dataNameLength)
{
BOOST_ASSERT(1 <= fibPrefixLength);
BOOST_ASSERT(fibPrefixLength <= interestNameLength);
BOOST_ASSERT(interestNameLength <= dataNameLength);
for (size_t i = 0; i < nPackets; i++) {
Name prefix(to_string(i / nFibEntries));
extendName(prefix, fibPrefixLength);
m_fib.insert(prefix);
Name interestName = prefix;
if (nPackets > nFibEntries) {
interestName.append(to_string(i));
}
extendName(interestName, interestNameLength);
interests.push_back(make_shared<Interest>(interestName));
Name dataName = interestName;
extendName(dataName, dataNameLength);
data.push_back(make_shared<Data>(dataName));
}
}
示例9:
Name
InMemoryPibImpl::getKeyName(const Name& identity, const name::Component& keyId) const
{
Name keyName = identity;
keyName.append(keyId);
return keyName;
}
示例10: extendName
static void
extendName(Name& name, size_t length)
{
BOOST_ASSERT(length >= name.size());
for (size_t i = name.size(); i < length; i++) {
name.append("dup");
}
}
示例11: convertStringToName
Name
ApolloStoryProducer :: convertStringToName(string str)
{
Name name = Name();
for (unsigned int i=0; i<str.size(); i++)
name.append(string(1,str[i]));
return name;
}
示例12:
Name
Name::getSubName(size_t iStartComponent) const
{
Name result;
for (size_t i = iStartComponent; i < size(); ++i)
result.append(at(i));
return result;
}
示例13: rFile
ApolloStoryProducer :: ApolloStoryProducer (string dir)
{
ifstream rFile(dir+string("/task_info.json"));
if (!rFile)
{
cout << "task_info.json does not exist." << endl;
candidate = false;
return;
}
string line;
getline (rFile, line);
Reader reader;
Value metaData;
reader.parse(line, metaData);
Value query = metaData["query"];
Value analysisType = query["analysis_types"];
for (unsigned int i=0; i<analysisType.size(); i++)
{
if (analysisType[i].asString() == string("Diversity"))
{
candidate = true;
break;
}
}
Name nRoot = Name("Apollo");
nRoot.append(Name(query["dataset"].asString()));
this->storyName = query["dataset"].asString();
this->producer = new InfoMaxProducer(nRoot);
vector<Name> nameList;
vector<Data> dataList;
string subdir = string(dir+string("/analysis/Diversity"));
if (readDirintoNameAndData(subdir, &nameList, &dataList))
{
for(unsigned int i=0; i<nameList.size(); i++) {
producer->add(nameList[i], dataList[i]);
}
}
if (!candidate)
{
cout << "This folder doesn't have Diversity folder." << endl;
candidate = false;
return;
}
}
示例14:
Name
ControlCommand::getRequestName(const Name& commandPrefix,
const ControlParameters& parameters) const
{
this->validateRequest(parameters);
Name name = commandPrefix;
name.append(m_module).append(m_verb);
name.append(parameters.wireEncode());
return name;
}
示例15: keyString
Name
IdentityManager::getKeyNameFromCertificatePrefix(const Name & certificatePrefix)
{
Name result;
string keyString("KEY");
int i = 0;
for(; i < certificatePrefix.size(); i++) {
if (certificatePrefix.get(i).toEscapedString() == keyString)
break;
}
if (i >= certificatePrefix.size())
throw SecurityException("Identity Certificate Prefix does not have a KEY component");
result.append(certificatePrefix.getSubName(0, i));
result.append(certificatePrefix.getSubName(i + 1, certificatePrefix.size()-i-1));
return result;
}