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)));
}
Esempio n. 2
0
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;
  }
}
Esempio n. 3
0
 Func foreach(Func func)
 {
   for(Entries::iterator i = entries.begin(); i != entries.end(); ++i)
   {
     func(i->first, i->second);
   }
   return func;
 }
Esempio n. 4
0
 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() << ")"; }
 }
Esempio n. 5
0
 ~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();
   }
 }
Esempio n. 6
0
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();
}
Esempio n. 7
0
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;
		}
	}
}
void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in)
{
    typedef Ptr<EntryT> EntryPtr;
    typedef std::list<EntryPtr> Entries;
    typedef typename Entries::iterator EntryIter;

    auto_ptr<InputStreamT> arc(m_factory->NewStream(in));
    int expectedTotal = m_testEntries.size();
    EntryPtr entry;
    Entries entries;

    if ((m_options & PipeIn) == 0)
        OnArchiveExtracted(*arc, expectedTotal);

    while (entry = EntryPtr(arc->GetNextEntry()), entry.get() != NULL) {
        wxString name = entry->GetName(wxPATH_UNIX);

        // provide some context for the error message so that we know which
        // iteration of the loop we were on
        string error_entry((_T(" '") + name + _T("'")).mb_str());
        string error_context(" failed for entry" + error_entry);

        TestEntries::iterator it = m_testEntries.find(name);
        CPPUNIT_ASSERT_MESSAGE(
            "archive contains an entry that shouldn't be there" + error_entry,
            it != m_testEntries.end());

        const TestEntry& testEntry = *it->second;

        wxDateTime dt = testEntry.GetDateTime();
        if (dt.IsValid())
            CPPUNIT_ASSERT_MESSAGE("timestamp check" + error_context,
                                   dt == entry->GetDateTime());

        // non-seekable entries are allowed to have GetSize == wxInvalidOffset
        // until the end of the entry's data has been read past
        CPPUNIT_ASSERT_MESSAGE("entry size check" + error_context,
            testEntry.GetLength() == entry->GetSize() ||
            ((m_options & PipeIn) != 0 && entry->GetSize() == wxInvalidOffset));
        CPPUNIT_ASSERT_MESSAGE(
            "arc->GetLength() == entry->GetSize()" + error_context,
            arc->GetLength() == entry->GetSize());

        if (name.Last() != _T('/'))
        {
            CPPUNIT_ASSERT_MESSAGE("!IsDir" + error_context,
                !entry->IsDir());
            wxCharBuffer buf(testEntry.GetSize() + 1);
            CPPUNIT_ASSERT_MESSAGE("Read until Eof" + error_context,
                arc->Read(buf.data(), testEntry.GetSize() + 1).Eof());
            CPPUNIT_ASSERT_MESSAGE("LastRead check" + error_context,
                arc->LastRead() == testEntry.GetSize());
            CPPUNIT_ASSERT_MESSAGE("data compare" + error_context,
                !memcmp(buf.data(), testEntry.GetData(), testEntry.GetSize()));
        } else {
            CPPUNIT_ASSERT_MESSAGE("IsDir" + error_context, entry->IsDir());
        }

        // GetSize() must return the right result in all cases after all the
        // data has been read
        CPPUNIT_ASSERT_MESSAGE("entry size check" + error_context,
            testEntry.GetLength() == entry->GetSize());
        CPPUNIT_ASSERT_MESSAGE(
            "arc->GetLength() == entry->GetSize()" + error_context,
            arc->GetLength() == entry->GetSize());

        if ((m_options & PipeIn) == 0) {
            OnEntryExtracted(*entry, testEntry, arc.get());
            delete it->second;
            m_testEntries.erase(it);
        } else {
            entries.push_back(entry);
        }
    }

    // check that the end of the input archive was reached without error
    CPPUNIT_ASSERT(arc->Eof());

    // for non-seekable streams these data are only guaranteed to be
    // available once the end of the archive has been reached
    if (m_options & PipeIn) {
        for (EntryIter i = entries.begin(); i != entries.end(); ++i) {
            wxString name = (*i)->GetName(wxPATH_UNIX);
            TestEntries::iterator j = m_testEntries.find(name);
            OnEntryExtracted(**i, *j->second);
            delete j->second;
            m_testEntries.erase(j);
        }
        OnArchiveExtracted(*arc, expectedTotal);
    }
}