• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: readTemplate

void Task::processTemplate() {
    Template* temp = readTemplate(*_templateName);
    std::vector<string> subtasks = temp->subTaskList();
    int subId = 1;
    for (std::vector<string>::iterator iterSub = subtasks.begin(); iterSub != subtasks.end(); iterSub++) {
        string subtask = *iterSub;
        int posPar = subtask.find('(');
        int posFin = subtask.find(')');

        string tempSub = subtask.substr(posPar + 1, posFin - posPar - 1);
        string subTaskName = subtask.substr(0, posPar);

        Task* sub = new Task(_project);
        std::stringstream ssId;
        ssId << *id() << "." << subId++;
        sub->setId(new string(ssId.str()));
        sub->setDuration(Duration(1, 0, 0));
        sub->setEndDate(endDate());
        sub->setShortDescription(new string(subTaskName));
        sub->setStartDate(startDate());
        sub->setStatus(status());
        sub->setTemplateName(new string(tempSub));

        _project->addTask(sub);
        if (errorOcurred()) {
            return;
        }
        sub->processTemplate();
    }
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:30,代码来源:task.cpp


示例2: compare

    float compare(const Template &a, const Template &b) const
    {
        if (a.size() != distances.size() ||
            b.size() != distances.size())
            return -std::numeric_limits<float>::max();

        QList<float> scores;
        for (int i=0; i<distances.size(); i++) {
            float weight;
            weights.isEmpty() ? weight = 1. : weight = weights[i];
            if (weight != 0)
                scores.append(weight*distances[i]->compare(Template(a.file, a[i]),Template(b.file, b[i])));
        }

        switch (operation) {
          case Mean:
            return std::accumulate(scores.begin(),scores.end(),0.0)/(float)scores.size();
            break;
          case Sum:
            return std::accumulate(scores.begin(),scores.end(),0.0);
            break;
          case Min:
            return *std::min_element(scores.begin(),scores.end());
            break;
          case Max:
            return *std::max_element(scores.begin(),scores.end());
            break;
          default:
            qFatal("Invalid operation.");
        }
        return 0;
    }
开发者ID:13221325403,项目名称:openbr,代码行数:32,代码来源:fuse.cpp


示例3: write

    void write(const Template &t) const
    {
        QFile f(file);
        QtUtils::touchDir(f);
        if (!f.open(QFile::WriteOnly))
            qFatal("Failed to open %s for writing.", qPrintable(file));

        Mat m;
        if (!raw) {
            if (t.m().type() != CV_32FC1)
                t.m().convertTo(m, CV_32F);
            else m = t.m();

            if (m.channels() != 1) qFatal("Only supports single channel matrices.");

            f.write((const char *) &m.rows, 4);
            f.write((const char *) &m.cols, 4);
        }
        else m =  t.m();

        qint64 rowSize = m.cols * sizeof(float);
        for (int i=0; i < m.rows; i++)
        {
            f.write((const char *) m.row(i).data, rowSize);
        }
        f.close();
    }
开发者ID:Alive-AttemptTheLifeGangHouse,项目名称:openbr,代码行数:27,代码来源:format.cpp


示例4: compare

    float compare(const Template &a, const Template &b) const
    {
        QList<int> indices;
        for (int i=0; i<a.size(); i++)
            indices << i;

        QList<float> scores;
        do {
            QList<float> permScores;
            for (int i=0; i<a.size(); i++)
                permScores.append(distance->compare(Template(a.file, a[indices[i]]),Template(b.file, b[i])));
            scores.append(std::accumulate(permScores.begin(),permScores.end(),0.0));
        } while ( next_permutation(indices.begin(),indices.end()) );

        switch (operation) {
          case Mean:
            return std::accumulate(scores.begin(),scores.end(),0.0)/(float)scores.size();
            break;
          case Sum:
            return std::accumulate(scores.begin(),scores.end(),0.0);
            break;
          case Min:
            return *std::min_element(scores.begin(),scores.end());
            break;
          case Max:
            return *std::max_element(scores.begin(),scores.end());
            break;
          default:
            qFatal("Invalid operation.");
        }
        return 0;
    }
开发者ID:13221325403,项目名称:openbr,代码行数:32,代码来源:permute.cpp


示例5: TEST

TEST(template_unittest, test_template_efficiency) {
  std::vector<Template *> repos;
  repos.push_back(new Template("1={w0}"));
  repos.push_back(new Template("2={p0}"));
  repos.push_back(new Template("3={w0}-{p0}"));
  repos.push_back(new Template("4={w1}"));
  repos.push_back(new Template("5={p1}"));
  repos.push_back(new Template("6={w1}-{p1}"));

  string payload;
  payload.reserve(128);
  long start_time = clock();
  int kNumRepeats = 1024 * 1024;
  int kNumTemplates = repos.size();

  for (int t = 0; t < 1024 * 1024; ++ t) {
    Template::Data data;
    data.set("w0", "am");
    data.set("p0", "v");
    data.set("w1", "I");
    data.set("p1", "r");
    for (int i = 0; i < repos.size(); ++ i) {
      Template* T = repos[i];
      T->render(data, payload);
    }
  }

  long throughput_per_millisecond = ((kNumRepeats * kNumTemplates)
      / ((clock() -start_time) / 1000));
  std::cout << throughput_per_millisecond << std::endl;
}
开发者ID:XiaoboYuan,项目名称:ltp,代码行数:31,代码来源:utils_template_unittest.cpp


示例6: QStringLiteral

void TestCachingLoader::testRenderAfterError()
{
  Engine engine;
  engine.setPluginPaths(QStringList() << QStringLiteral(GRANTLEE_PLUGIN_PATH));

  QSharedPointer<InMemoryTemplateLoader> loader(new InMemoryTemplateLoader);
  loader->setTemplate(QStringLiteral("template1"),
                      QStringLiteral("This template has an error {{ va>r }}"));
  loader->setTemplate(QStringLiteral("template2"), QStringLiteral("Ok"));
  loader->setTemplate(QStringLiteral("main"),
                      QStringLiteral("{% include template_var %}"));

  QSharedPointer<Grantlee::CachingLoaderDecorator> cache(
      new Grantlee::CachingLoaderDecorator(loader));

  engine.addTemplateLoader(cache);

  Context c;
  Template t;
  t = engine.loadByName(QStringLiteral("main"));

  c.insert(QStringLiteral("template_var"), QLatin1String("template1"));
  QCOMPARE(t->render(&c), QString());
  QCOMPARE(t->error(), TagSyntaxError);

  c.insert(QStringLiteral("template_var"), QLatin1String("template2"));
  QCOMPARE(t->render(&c), QLatin1String("Ok"));
  QCOMPARE(t->error(), NoError);
}
开发者ID:aodkrisda,项目名称:grantlee,代码行数:29,代码来源:testcachingloader.cpp


示例7: load

void DisjointMetadata::load(const ImageInfo &info)
{
    CaptionsMap commentMap;
    CaptionsMap titleMap;

    {
        CoreDbAccess access;
        ImageComments comments = info.imageComments(access);
        commentMap             = comments.toCaptionsMap();
        titleMap               = comments.toCaptionsMap(DatabaseComment::Title);
    }

    Template tref = info.metadataTemplate();
    Template t    = TemplateManager::defaultManager()->findByContents(tref);
    //qCDebug(DIGIKAM_GENERAL_LOG) << "Found Metadata Template: " << t.templateTitle();

    load(info.dateTime(),
         titleMap,
         commentMap,
         info.colorLabel(),
         info.pickLabel(),
         info.rating(),
         t.isNull() ? tref : t);

    QList<int> tagIds = info.tagIds();
    loadTags(tagIds);
}
开发者ID:KDE,项目名称:digikam,代码行数:27,代码来源:disjointmetadata.cpp


示例8: asString

string SAMSUser::asString () const
{
  string res = "";
  Template *tpl = TemplateList::getTemplate (this->getCurrentTemplateId());
  if (!tpl)
    {
      WARNING ("User with id " << _id << " lost template");
      return res;
    }

  if (tpl->getAuth() == Proxy::AUTH_IP)
    {
      res = _ip.asString ();
    }
  else
    {
      if (!_domain.empty () && Proxy::useDomain ())
        {
          res = _domain + Proxy::getSeparator ();
        }
      res += _nick;
    }

  return res;
}
开发者ID:Chugajstyr,项目名称:sams2,代码行数:25,代码来源:samsuser.cpp


示例9: Template

void RequestError::stdException(Request* request, const std::exception& e)
{
#ifndef DEBUG
	if (!request->headersSent())
		request->setStatus(500);
	Template* tpl = new Template("Errors/500.html", nullptr, request);
	tpl->render();
	delete tpl;
	return;
#endif

	/*try
	{
		View tpl = new Template("Sys::Exception.html", nullptr, request);
		tpl["exceptionName"] = (typeid e).name();
		tpl["exceptionMessage"] = e.what();
		tpl["webcppVersion"] = System::get()->version();
		tpl["serverName"] = request->env("SERVER_NAME", "");

		if (!request->headersSent())
			request->setStatus(500);
		tpl->render();
	}
	catch (const Exception& e2)
	{*/ fallbackErrorPage(request, e, ""); /* e, e2.type() */ /*}
	catch (const std::exception& e2)
	{ fallbackErrorPage(request, e, typeid(e2).name()); }*/
}
开发者ID:dreamsxin,项目名称:WebCpp,代码行数:28,代码来源:RequestError.cpp


示例10: janus_detect

janus_error janus_detect(const janus_image image, janus_attributes *attributes_array, const size_t num_requested, size_t *num_actual)
{
    TemplateList src, dst;

    Template t;
    cv::Mat input(image.height,
                  image.width,
                  image.color_space == JANUS_GRAY8 ? CV_8UC1 : CV_8UC3,
                  image.data);

    t.append(input);
    src.append(t);
    detect->project(src, dst);
    *num_actual = dst.size();
    if (dst.size() == 0)
        return JANUS_FAILURE_TO_DETECT;

    // Sort by confidence, descending
    std::sort(dst.begin(), dst.end(), compareConfidence);

    size_t count = 0;
    foreach (const Template &temp, dst) {
        QRectF rect = temp.file.rects().first();
        attributes_array->face_x = rect.x();
        attributes_array->face_y = rect.y();
        attributes_array->face_width = rect.width();
        attributes_array->face_height = rect.height();
        attributes_array->detection_confidence = temp.file.get<float>("Confidence");
        attributes_array++;
        if (++count >= num_requested)
            break;
    }
开发者ID:13221325403,项目名称:openbr,代码行数:32,代码来源:janus.cpp


示例11: main

int main()
{
	Template * pTemplate = new Boy();
	pTemplate->DoFood();
	delete pTemplate;

	return 0;
}
开发者ID:FanChael,项目名称:cplusplus-version-to-achieve-24-design-patterns-and-six-design-principles-,代码行数:8,代码来源:tmplate.cpp


示例12: getTemplate

Template* TemplateMap::getTemplate(const char *text)
{
	for (Template *ptr = entries; ptr != NULL; ptr = ptr->getNext())
		if (ptr->equals(text))
			return ptr;

	return 0;
}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:8,代码来源:Template.cpp


示例13: field

void NewDocumentWizard::accept()
// ----------------------------------------------------------------------------
//   Copy template into user's document folder
// ----------------------------------------------------------------------------
{
    QString docName = field("docName").toString();
    QString docLocation = field("docLocation").toString();
    QString dstPath = docLocation + "/" + docName;

    QDir dst(dstPath);
    if (dst.exists())
    {
        QString dstPathNative = QDir::toNativeSeparators(dstPath);
        int r = QMessageBox::warning(this, tr("Folder exists"),
                    tr("Document folder:\n%1\nalready exists. "
                       "Do you want to use it anyway (current content "
                       "will be deleted)?\n"
                       "Click No to choose another location.")
                       .arg(dstPathNative),
                       QMessageBox::Yes | QMessageBox::No);
        if (r != QMessageBox::Yes)
            return;
    }

    Template t = templates.at(field("templateIdx").toInt());

    bool ok = t.copyTo(dst);
    if (!ok)
    {
        QMessageBox::warning(this, tr("Error"),
                             tr("Failed to copy document template."));
        return;
    }

    docPath = dstPath;
    if (t.mainFile != "")
    {
        QString oldName = t.mainFile.replace(QRegExp("\\.ddd$"), "");
        QString newName = docName;
        if (oldName != newName)
        {
            // Rename template main file to doc name.
            // We need to remove the destination file if it is there
            QDir dstDir = QDir(dstPath);
            Rename(dstDir, oldName, newName, ".ddd");
            Rename(dstDir, oldName, newName, ".ddd.sig");
            Rename(dstDir, oldName, newName, ".json");
            docPath = dstDir.filePath(newName + ".ddd");
        }
    }

#if !defined(CFG_NOGIT)
    // Create project to avoid prompt when document is first opened
    RepositoryFactory::repository(dstPath, RepositoryFactory::Create);
#endif
    QDialog::accept();
}
开发者ID:c3d,项目名称:tao-3D,代码行数:57,代码来源:new_document_wizard.cpp


示例14: Template

bool Task::AddTemplate(const QString &template_path)
{
	Template *t = new Template();
	if (t && t->Initialize(template_path)) {
		return AddTemplate(t);
	} else {
		return false;
	}
}
开发者ID:ssidko,项目名称:WorkProjects,代码行数:9,代码来源:Task.cpp


示例15: Template

//=============================================================================
// 生成
//=============================================================================
bool Template::Create(Template** outPointer)
{
	Template* pointer = new Template();
	if(!pointer->Initialize())
		return false;

	*outPointer = pointer;
	return true;
}
开发者ID:tnbmi,项目名称:ms_project,代码行数:12,代码来源:template.cpp


示例16: main

int main()
{
    Template* t;
    t=new ConcreteClassA(8,2);
    t->templateMethod();
    t=new ConcreteClassB(10,5);
    t->templateMethod();
    return 0;
}
开发者ID:wongxingjun,项目名称:designPatterns,代码行数:9,代码来源:TemplateMethodPattern.cpp


示例17: createPageMenus

  void createPageMenus( void )
  {
    // find the menus associated with this page
    siteObject thisSite;
    thisSite.id - site_id;
    thisSite.key(site_id);
    if( thisSite.get_data() )
    {
      Template tmplt;
      tmplt.id = template_id;
      tmplt.key(template_id);
      if( tmplt.get_data() )
      {
        // build a path to the Template
        string fullPath = thisSite.path;
        fullPath += "/Templates/";
        fullPath += tmplt.path;

        cgiTemplates cTemp;
        if( cTemp.load(fullPath.c_str()) )
        {
          // get the control section
          xmlParser parser( cTemp.getParagraph("control") );
          parser.parse();
          node_vector::iterator & it = parser.findFirstNodeByName( "menu" );
          int order=0;
          while( it !=  parser.states.nodes.end() )
          {
            xmlNode & node = *it;
            string open_tag = node.attr["open"];
            string close_tag = node.attr["close"];

            class menu mnu;
            string clause = "reference_template = '";
            clause += tmplt.path;
            clause += "' and template_open_tag = '";
            clause += open_tag;
            clause += "' and  template_close_tag = '";
            clause +=  close_tag;
            clause += "'";

            if( mnu.get_data(clause) )
            {
              page_menus_Obj pg_mnu;
              pg_mnu.site_id = site_id;
              pg_mnu.menu_id = mnu.id;
              pg_mnu.page_id = id;
              pg_mnu.place_order = order++;
              pg_mnu.collapsible = false;
              pg_mnu.db_insert();
            }
            it = parser.findNextNodeByName( "menu" );
          }
        }
      }
    }
  }
开发者ID:davidmc,项目名称:w3metasite,代码行数:57,代码来源:page.hpp


示例18: main

int main() {

	static Template<String> t;


	t.methodThatUsesAnotherMethod();

	return 0;
}
开发者ID:AndreaMarangoni,项目名称:ForcedDerivation,代码行数:9,代码来源:main.cpp


示例19: getTemplate

Template* TemplateMap::getTemplate(const char *text) {
	Template *ptr;
	for (ptr=entries; ptr!=NULL; ptr=ptr->getNext()) {
		if (ptr->equals(text)) {
			break;
		}
	}
	return ptr;
}
开发者ID:BackupTheBerlios,项目名称:mgoodies-svn,代码行数:9,代码来源:Template.cpp


示例20: readTemplates

void DialogSettings::loadTemplates() {
    vector<Template*>* templates = readTemplates();
    QStringList list;
    for (vector<Template*>::iterator iter = templates->begin(); iter != templates->end(); iter++) {
        Template* tpl = *iter;
        QString description(tpl->description()->c_str());
        list.append(description);
    }
    ui->templatesList->addItems(list);
}
开发者ID:crossleyjuan,项目名称:djon,代码行数:10,代码来源:dialogsettings.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TemplateArgument类代码示例发布时间:2022-05-31
下一篇:
C++ Temperature类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap