当前位置: 首页>>代码示例>>C++>>正文


C++ Entries类代码示例

本文整理汇总了C++中Entries的典型用法代码示例。如果您正苦于以下问题:C++ Entries类的具体用法?C++ Entries怎么用?C++ Entries使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Entries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

std::string
Dictionary::translate_plural(const Entries& dict, const std::string& msgid, const std::string& msgid_plural, int count)
{
  Entries::const_iterator i = dict.find(msgid);

  if (i != dict.end())
  {
    const std::vector<std::string>& msgstrs = i->second;
    unsigned int n = 0;
    n = plural_forms.get_plural(count);
    assert(/*n >= 0 &&*/ n < msgstrs.size());

    if (!msgstrs[n].empty())
      return msgstrs[n];
    else
      if (count == 1) // default to english rules
        return msgid;
      else
        return msgid_plural;
  }
  else
  {
    log_info << "Couldn't translate: " << msgid << std::endl;
    log_info << "Candidates: " << std::endl;
    for (i = dict.begin(); i != dict.end(); ++i)
      log_info << "'" << i->first << "'" << std::endl;

    if (count == 1) // default to english rules
      return msgid;
    else
      return msgid_plural;
  }
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:33,代码来源:dictionary.cpp

示例2: _write

bool PLS::_write(const Entries &list)
{
	Writer *writer = ioCtrl.rawPtr< Writer >();
	writer->write(QString("[playlist]\r\nNumberOfEntries=" + QString::number(list.size()) + "\r\n").toUtf8());
	for (int i = 0; i < list.size(); i++)
	{
		const Playlist::Entry &entry = list[i];
		QString idx = QString::number(i+1);
		QString url = entry.url;
		const bool isFile = url.startsWith("file://");
		if (isFile)
			url.remove(0, 7);
#ifdef Q_OS_WIN
		if (isFile)
			url.replace("/", "\\");
#endif
		if (!url.isEmpty())
			writer->write(QString("File" + idx + "=" + url + "\r\n").toUtf8());
		if (!entry.name.isEmpty())
			writer->write(QString("Title" + idx + "=" + QString(entry.name).replace('\n', '\001') + "\r\n").toUtf8());
		if (entry.length >= 0)
			writer->write(QString("Length" + idx + "=" + QString::number(entry.length) + "\r\n").toUtf8());
		if (entry.selected)
			writer->write(QString("QMPlay_sel" + idx + "=" + QString::number(entry.selected) + "\r\n").toUtf8());
		if (entry.queue)
			writer->write(QString("QMPlay_queue" + idx + "=" + QString::number(entry.queue) + "\r\n").toUtf8());
		if (entry.GID)
			writer->write(QString("QMPlay_GID" + idx + "=" + QString::number(entry.GID) + "\r\n").toUtf8());
		if (entry.parent)
			writer->write(QString("QMPlay_parent" + idx + "=" + QString::number(entry.parent) + "\r\n").toUtf8());
	}
	return true;
}
开发者ID:mitya57,项目名称:QMPlay2,代码行数:33,代码来源:PLS.cpp

示例3: foreach

 Func foreach(Func func)
 {
   for(Entries::iterator i = entries.begin(); i != entries.end(); ++i)
   {
     func(i->first, i->second);
   }
   return func;
 }
开发者ID:Flakebi,项目名称:stk-code,代码行数:8,代码来源:dictionary.hpp

示例4: op_delete

 void op_delete(void * const p, bool const array, std::size_t const s) {
   if (array) ::operator delete[](p);
   else ::operator delete(p);
   std::vector<boost::reference_wrapper<Entry const> > v;
   for (Entries::const_iterator j = entries.begin(); j != entries.end(); ++j)
     if (p <= j->p && boost::implicit_cast<void const *>(j->p) <= static_cast<char *>(p) + s)
       v.push_back(boost::cref(*j));
   if (array) { info i; i() << "delete["; more_ostreaming::delimit(i(), v); i() << ']'; }
   else { assert(v.size() == 1); info()() << "delete(" << v.front() << ")"; }
 }
开发者ID:SunnyKale,项目名称:geordi,代码行数:10,代码来源:tracked.cpp

示例5: SIGNAL

void ViennaMiniForm::setMaterialLibrary(MaterialManager::Library& lib)
{
    typedef MaterialManager::Library::Entries          Entries;
    typedef MaterialManager::Library::EntryIterator    EntryIterator;

    Entries metals = lib.getMaterialsOfCategory("metal");
    for(EntryIterator iter = metals.begin(); iter != metals.end(); iter++)
    {
        list_metals << QString::fromStdString(vmat::id(*iter));
    }
    ui->comboBoxContactMaterial->addItems(list_metals);
    QObject::connect(ui->comboBoxContactMaterial, SIGNAL(activated(QString)), this, SLOT(setSegmentMaterial(QString)));

    Entries oxides = lib.getMaterialsOfCategory("oxide");
    for(EntryIterator iter = oxides.begin(); iter != oxides.end(); iter++)
    {
        list_oxides << QString::fromStdString(vmat::id(*iter));
    }
    ui->comboBoxOxideMaterial->addItems(list_oxides);
    QObject::connect(ui->comboBoxOxideMaterial, SIGNAL(activated(QString)), this, SLOT(setSegmentMaterial(QString)));

    Entries semiconductors = lib.getMaterialsOfCategory("semiconductor");
    for(EntryIterator iter = semiconductors.begin(); iter != semiconductors.end(); iter++)
    {
        list_semiconductors << QString::fromStdString(vmat::id(*iter));
    }
    ui->comboBoxSemiconductorMaterial->addItems(list_semiconductors);
    QObject::connect(ui->comboBoxSemiconductorMaterial, SIGNAL(activated(QString)), this, SLOT(setSegmentMaterial(QString)));
}
开发者ID:rollingstone,项目名称:viennamos-dev,代码行数:29,代码来源:viennaminiform.cpp

示例6: main

int main(int argc, char* argv[])
{

  if(argc < 3) {
    printf("Usage whateveryoujusttyped.exe readFileName writeFileName\n");
    return -1;
  }

  const char* readFilename = argv[1];
  const char* writeFilename = argv[2];

  std::ifstream readFile(readFilename);
  if(!readFile.is_open()) {
    printf("Couldn't open %s for reading\n", readFilename);
    return -1;
  }

  std::ofstream writeFile(writeFilename);
  if(!writeFile.is_open()) {
    printf("Couldn't open %s for writing\n", writeFilename);
    return -1;
  }

  typedef std::list<std::string> Entries;
  Entries entries;

  std::string currentEntry;
  std::string line;
  while(std::getline(readFile, line)) {
    if(strstr(line.c_str(), "===") != NULL) {
      if(!currentEntry.empty()) {
        entries.push_back(currentEntry);
      }
      currentEntry.clear();
    }

    currentEntry += line;
    currentEntry += "\n";
  }
  if(!currentEntry.empty()) {
    entries.push_back(currentEntry);
  }
  readFile.close();

  for(auto entryIt = entries.rbegin();
    entryIt != entries.rend();
    ++entryIt) {
    writeFile << (*entryIt);
  }
  writeFile.close();

  return 0;
}
开发者ID:b3sigma,项目名称:logflipper,代码行数:53,代码来源:logflipper.cpp

示例7: abort

 ~LeakReporter() {
   std::vector<boost::reference_wrapper<Entry const> > v;
   for (Entries::const_iterator i = entries.begin(); i != entries.end(); ++i)
     if (i->status != destructed) v.push_back(boost::cref(*i));
   if (!v.empty() && !muted)
   {
     std::ostringstream oss;
       // We don't use cout here because apparently it can be unavailable by the time this code runs (judging by the segfaults I observed when this code used cout).
     more_ostreaming::delimit(oss, v);
     std::printf("%sleaked: %s.", parsep, oss.str().c_str());
     abort();
   }
 }
开发者ID:SunnyKale,项目名称:geordi,代码行数:13,代码来源:tracked.cpp

示例8:

std::string
Dictionary::translate(const Entries& dict, const std::string& msgid)
{
  Entries::const_iterator i = dict.find(msgid);
  if (i != dict.end() && !i->second.empty())
  {
    return i->second[0];
  }
  else
  {
    log_info << "Couldn't translate: " << msgid << std::endl;
    return msgid;
  } 
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:14,代码来源:dictionary.cpp

示例9: clear

void CalendarCell::update(const dbo::ptr<UserAccount>& user, const WDate& date)
{
  date_ = date;
  user_ = user;

  clear();

  dbo::Session& session = PlannerApplication::plannerApplication()->session;
  dbo::Transaction transaction(session);
  
  WString day;
  day += boost::lexical_cast<std::string>(date.day());
  if (date.day() == 1)
    day += " " + WDate::longMonthName(date.month());
  WText* header = new WText(day);
  header->setStyleClass("cell-header");
  addWidget(header);

  typedef dbo::collection< dbo::ptr<Entry> > Entries;
  Entries entries = user->entriesInRange(date, date.addDays(1));

  const unsigned maxEntries = 4;
  unsigned counter = 0;
  for (Entries::const_iterator i = entries.begin();
       i != entries.end(); ++i, ++counter) {
    if (counter == maxEntries) {
      WText* extra = 
	new WText(tr("calendar.cell.extra")
		  .arg((int)(entries.size() - maxEntries)));
      extra->setStyleClass("cell-extra");
      addWidget(extra);

      extra->clicked().preventPropagation();
      extra->clicked().connect(this, &CalendarCell::showAllEntriesDialog);
      
      break;
    }

    WString format = EntryDialog::timeFormat;
    addWidget(new WText((*i)->start.toString(format) +
			"-" + 
			(*i)->stop.toString(format) + 
			": " + (*i)->summary));
  }

  transaction.commit();
}
开发者ID:913862627,项目名称:wt,代码行数:47,代码来源:CalendarCell.C

示例10: available

std::string
Dictionary::translate_plural(const Entries& dict, const std::string& msgid, const std::string& msgid_plural, int count) const
{
	Entries::const_iterator it = dict.find(msgid);
	if (it != dict.end())
	{
		unsigned int                  n         = plural_forms.get_plural(count);
		const std::vector<std::string>& msgstrs = it->second;
		if (n >= msgstrs.size())
		{
			log_error << "Plural translation not available (and not set to empty): '" << msgid << "'" << std::endl;
			log_error << "Missing plural form: " << n << std::endl;
			return msgid;
		}

		if (!msgstrs[n].empty())
		{
			return msgstrs[n];
		}
		else
		if (count == 1) // default to english rules
		{
			return msgid;
		}
		else
		{
			return msgid_plural;
		}
	}
	else
	{
		log_info << "Couldn't translate: " << msgid << std::endl;
		log_info << "Candidates: " << std::endl;
		for (it = dict.begin(); it != dict.end(); ++it)
			log_info << "'" << it->first << "'" << std::endl;

		if (count == 1) // default to english rules
		{
			return msgid;
		}
		else
		{
			return msgid_plural;
		}
	}
}
开发者ID:dustinduse,项目名称:etlegacy,代码行数:46,代码来源:dictionary.cpp

示例11: entries

Path Directory::find(const Path& fileName, SensType sens) const
{
  if( fileName.toString().empty() )
  {
    Logger::warning( "!!! WARNING: Directory: cannot try find zero lenght name" );
    return "";
  }

  Entries files = entries();
  files.setSensType( sens );
  int index = files.findFile( fileName.baseName() );
  if( index >= 0 )
  {
    return files.item( index ).fullpath;
  }

  return "";
}
开发者ID:Ecordonnier,项目名称:caesaria-game,代码行数:18,代码来源:directory.cpp

示例12: qDebug

void DefineEntry::accept()
{
#ifdef DEBUG
    qDebug("DefineEntry::accpet()");
#endif
    if (!EntryProperties->count())
    {
        QMessageBox::warning(this, "No properties", "Please, define some entry's\nproperties", 0, 0, 0);
        return;
    }

    if (EntryName->text() == "")
    {
        QMessageBox::warning(this, "No entry name", "Please, define entry name", 0, 0, 0);
        return;
    }

    Entries *entries = IQApp->entries();

    Entry *entry;

    if (editEntry)
    {
        if (EntryName->text() != editEntry->getName() && entries->isIn(EntryName->text()))
        {
            QMessageBox::warning(this, "Entry exists", "Entry with such name\nexists. Please, choose another.", 0, 0, 0);
            return;
        }

        entry = editEntry;
        entry->clear();
        entry->setName(EntryName->text());
    }
    else if ((entry = entries->isIn(EntryName->text())))
    {
        QMessageBox::warning(this, "Entry exists", "Entry with such name\nexists. Please, choose another.", 0, 0, 0);
        return;
    }
    else
        entry = new Entry(EntryName->text());

    for (uint i = 0; true; i++)
    {
        PropertyBoxItem *pbi;

        if ((pbi = static_cast<PropertyBoxItem *>(EntryProperties->item(i))))
        {
            entry->addProperty(new PropertyStruct(pbi));
        }
        else
            break;
    }
    
    entry->setDefaultPic(defaultPic);

    if (!editEntry)
        entries->addEntry(entry);

    entry->checkPropertiesID();

    DefineEntryBase::accept();
}
开发者ID:BackupTheBerlios,项目名称:iqnotes-svn,代码行数:62,代码来源:defineEntry.cpp

示例13: info

  namespace detail
  {
    using geordi::error;
    using geordi::parsep;

    bool muted = false;

    struct info: boost::noncopyable
    {
      info() { if(!muted) std::cout << parsep; }
      ~info() { if(!muted) std::cout << parsep; }
      std::ostream & operator()() const
      {
        static std::ostream s(0); // used as null sink
        return muted ? s : std::cout;
      }
    };

    enum Status { fresh, pillaged, destructed };

    struct Entry {
      Tracked const * p;
      char const * name;
      Status status;
    };

    typedef std::vector<Entry> Entries;
    Entries entries;
      // Keeping track of Trackeds outside of the objects themselves allows us to give nice diagnostics for operations on objects that have already perished.
      // Invariant: If multiple entries have identical p, then all but the last have status==destructed.

    std::ostream & operator<<(std::ostream & o, Entry const & e)
    { return o << e.name << &e - &entries.front(); }

    Entry * entry(Tracked const * const r) {
      for (Entries::reverse_iterator i(entries.rbegin()); i != entries.rend(); ++i) if (i->p == r) return &*i;
      return 0;
    }

    void make_entry(Tracked const * const r) {
      if (Entry * const e = entry(r)) if (e->status != destructed) error()() << "leaked: " << *e << '.';
      Entry const e = { r, "?", fresh };
      entries.push_back(e);
    }

    void assert_status_below(Tracked const * const r, Status const st, std::string const & s) {
      Entry * const e = entry(r);
      if(!e) error()() << "tried to " << s << " non-existent object.";
      if (e->status < st) return;
      error()() << "tried to " << s << (e->status == pillaged ? " pillaged " : " destructed ") << *e << '.';
    }

    void * op_new(std::size_t const s, bool const array, void * const r, char const * const name) {
      if (!r) return 0;
      info()() << "new(" << name << (array ? "[]" : "") << ")";
      return r;
    }

    void op_delete(void * const p, bool const array, std::size_t const s) {
      if (array) ::operator delete[](p);
      else ::operator delete(p);
      std::vector<boost::reference_wrapper<Entry const> > v;
      for (Entries::const_iterator j = entries.begin(); j != entries.end(); ++j)
        if (p <= j->p && boost::implicit_cast<void const *>(j->p) <= static_cast<char *>(p) + s)
          v.push_back(boost::cref(*j));
      if (array) { info i; i() << "delete["; more_ostreaming::delimit(i(), v); i() << ']'; }
      else { assert(v.size() == 1); info()() << "delete(" << v.front() << ")"; }
    }

    void Tracked::set_name(char const * const s) const { entry(this)->name = s; }

    Tracked::Tracked() { make_entry(this); }

    Tracked::Tracked(Tag const & t): tag(t) { make_entry(this); }

    Tracked::Tracked(Tracked const & i): tag((assert_status_below(&i, pillaged, "copy"), i.tag)) { make_entry(this); }

    void Tracked::operator=(Tracked const & r) {
      assert_status_below(this, destructed, "assign to");
      assert_status_below(&r, pillaged, "assign from");
      entry(this)->status = fresh;
    }

    Tracked::Tracked(Tracked && r)
    { assert_status_below(&r, pillaged, "move"); make_entry(this); entry(&r)->status = pillaged; }

    void Tracked::operator=(Tracked && r) {
      assert_status_below(this, destructed, "move-assign to");
      assert_status_below(&r, pillaged, "move");
      entry(this)->status = fresh;
      entry(&r)->status = pillaged;
    }

    Tracked::~Tracked()
    { assert_status_below(this, destructed, "re-destruct"); entry(this)->status = destructed; }

    struct LeakReporter {
      ~LeakReporter() {
        std::vector<boost::reference_wrapper<Entry const> > v;
        for (Entries::const_iterator i = entries.begin(); i != entries.end(); ++i)
//.........这里部分代码省略.........
开发者ID:SunnyKale,项目名称:geordi,代码行数:101,代码来源:tracked.cpp

示例14: launch_pipeline

inline children launch_pipeline(const Entries &entries) 
{ 
    BOOST_ASSERT(entries.size() >= 2); 

    children cs; 
    detail::file_handle fhinvalid; 

    boost::scoped_array<detail::pipe> pipes(new detail::pipe[entries.size() - 1]); 

#if defined(BOOST_POSIX_API) 
    { 
        typename Entries::size_type i = 0; 
        const typename Entries::value_type::context_type &ctx = entries[i].context; 

        detail::info_map infoin, infoout; 

        if (ctx.stdin_behavior.get_type() != stream_behavior::close) 
        { 
            detail::stream_info si = detail::stream_info(ctx.stdin_behavior, false); 
            infoin.insert(detail::info_map::value_type(STDIN_FILENO, si)); 
        } 

        BOOST_ASSERT(ctx.stdout_behavior.get_type() == stream_behavior::close); 
        detail::stream_info si2(close_stream(), true); 
        si2.type_ = detail::stream_info::use_handle; 
        si2.handle_ = pipes[i].wend().release(); 
        infoout.insert(detail::info_map::value_type(STDOUT_FILENO, si2)); 

        if (ctx.stderr_behavior.get_type() != stream_behavior::close) 
        { 
            detail::stream_info si = detail::stream_info(ctx.stderr_behavior, true); 
            infoout.insert(detail::info_map::value_type(STDERR_FILENO, si)); 
        } 

        detail::posix_setup s; 
        s.work_directory = ctx.work_directory; 

        pid_t pid = detail::posix_start(entries[i].executable, entries[i].arguments, ctx.environment, infoin, infoout, s); 

        detail::file_handle fhstdin; 

        if (ctx.stdin_behavior.get_type() == stream_behavior::capture) 
        { 
            fhstdin = detail::posix_info_locate_pipe(infoin, STDIN_FILENO, false); 
            BOOST_ASSERT(fhstdin.valid()); 
        } 

        cs.push_back(child(pid, fhstdin, fhinvalid, fhinvalid)); 
    } 

    for (typename Entries::size_type i = 1; i < entries.size() - 1; ++i) 
    { 
        const typename Entries::value_type::context_type &ctx = entries[i].context; 
        detail::info_map infoin, infoout; 

        BOOST_ASSERT(ctx.stdin_behavior.get_type() == stream_behavior::close); 
        detail::stream_info si1(close_stream(), false); 
        si1.type_ = detail::stream_info::use_handle; 
        si1.handle_ = pipes[i - 1].rend().release(); 
        infoin.insert(detail::info_map::value_type(STDIN_FILENO, si1)); 

        BOOST_ASSERT(ctx.stdout_behavior.get_type() == stream_behavior::close); 
        detail::stream_info si2(close_stream(), true); 
        si2.type_ = detail::stream_info::use_handle; 
        si2.handle_ = pipes[i].wend().release(); 
        infoout.insert(detail::info_map::value_type(STDOUT_FILENO, si2)); 

        if (ctx.stderr_behavior.get_type() != stream_behavior::close) 
        { 
            detail::stream_info si = detail::stream_info(ctx.stderr_behavior, true); 
            infoout.insert(detail::info_map::value_type(STDERR_FILENO, si)); 
        } 

        detail::posix_setup s; 
        s.work_directory = ctx.work_directory; 

        pid_t pid = detail::posix_start(entries[i].executable, entries[i].arguments, ctx.environment, infoin, infoout, s); 

        cs.push_back(child(pid, fhinvalid, fhinvalid, fhinvalid)); 
    } 

    { 
        typename Entries::size_type i = entries.size() - 1; 
        const typename Entries::value_type::context_type &ctx = entries[i].context; 

        detail::info_map infoin, infoout; 

        BOOST_ASSERT(ctx.stdin_behavior.get_type() == stream_behavior::close); 
        detail::stream_info si1(close_stream(), false); 
        si1.type_ = detail::stream_info::use_handle; 
        si1.handle_ = pipes[i - 1].rend().release(); 
        infoin.insert(detail::info_map::value_type(STDIN_FILENO, si1)); 

        if (ctx.stdout_behavior.get_type() != stream_behavior::close) 
        { 
            detail::stream_info si = detail::stream_info(ctx.stdout_behavior, true); 
            infoout.insert(detail::info_map::value_type(STDOUT_FILENO, si)); 
        } 

        if (ctx.stderr_behavior.get_type() != stream_behavior::close) 
//.........这里部分代码省略.........
开发者ID:allannielsen,项目名称:termhub,代码行数:101,代码来源:operations.hpp

示例15: Set

 void Set(Entries& entries)
 {
     Set( entries.Ptr(), entries.Size() );
 }
开发者ID:BGCX261,项目名称:zlndx-emu-svn-to-git,代码行数:4,代码来源:NstSystemAccelerator.hpp


注:本文中的Entries类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。