本文整理汇总了C++中StrList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ StrList::push_back方法的具体用法?C++ StrList::push_back怎么用?C++ StrList::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrList
的用法示例。
在下文中一共展示了StrList::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: desiresCB
void EventsGenerator::desiresCB(const hbba_msgs::DesiresSet::ConstPtr& msg)
{
typedef std::vector<std::string> StrVec;
typedef std::list<std::string> StrList;
typedef std::vector<hbba_msgs::Desire> DesVec;
typedef std::map<std::string,std::string> TypeMap;
const DesVec& desires = msg->desires;
TypeMap typeMap;
StrVec ids;
ids.reserve(desires.size());
for (DesVec::const_iterator d = desires.begin(); d != desires.end(); ++d)
{
ids.push_back(d->id);
typeMap[d->id] = d->type;
}
// First, remove desires not in it the current desires set.
StrList del;
for (Model::const_iterator i = model_.begin(); i != model_.end(); ++i)
{
const std::string& id = i->first;
if (std::find(ids.begin(), ids.end(), id) == ids.end())
del.push_back(id);
}
for (StrList::const_iterator i = del.begin(); i != del.end(); ++i)
{
const std::string& id = *i;
event(id, model_[id].type, hbba_msgs::Event::DES_OFF);
if (model_[id].flags & FLAG_INT)
event(id, model_[id].type, hbba_msgs::Event::INT_OFF);
if (model_[id].flags & FLAG_EXP)
event(id, model_[id].type, hbba_msgs::Event::EXP_OFF);
model_.erase(id);
}
// Then, generate events for new desires.
for (StrVec::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
const std::string& id = *i;
if (model_.find(id) == model_.end())
{
model_[id].flags = FLAG_NONE;
model_[id].type = typeMap[id]; //set type in the model
event(id, model_[id].type, hbba_msgs::Event::DES_ON);
}
}
}
示例2: get_history
void get_history(StrList& history, const char* cmdFifo, const char* listFifo)
{
char current[256];
if (!getcwd(current, sizeof(current)-1))
current[0] = '\0';
String buf(":list:");
buf += current;
buf += '\n';
ofstream daemon(cmdFifo);
daemon << buf;
daemon.close();
ifstream in(listFifo);
while (getline(in, buf).good()) {
history.push_back(buf);
}
} // end get_history