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

C++ openstudio::path类代码示例

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

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



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

示例1: initializeModelTempDir

  bool initializeModelTempDir(const openstudio::path& osmPath, const openstudio::path& modelTempDir)
  {
    bool result = true;
    
    if( osmPath.empty() || !boost::filesystem::exists(osmPath)){
     
      LOG_FREE(Debug, "initializeModelTempDir", "OSM path '" << toString(osmPath) << "' is empty or does not exist");
      result = false;

    }else{
      LOG_FREE(Debug, "initializeModelTempDir", "Copying '" << toString(osmPath) << "' to '" << toString(modelTempDir / toPath("in.osm")) << "'");
   
      // copy osm file
      bool test = QFile::copy(toQString(osmPath), toQString(modelTempDir / toPath("in.osm")));
      if (!test){
        LOG_FREE(Error, "initializeModelTempDir", "Could not copy '" << toString(osmPath) << "' to '" << toString(modelTempDir / toPath("in.osm")) << "'");
      }

      // Copy all files from existing resources dir into temp dir when opening
      openstudio::path sourceDir = osmPath.parent_path() / osmPath.stem();
      openstudio::path destDir = modelTempDir / toPath("resources");
      if (boost::filesystem::exists(sourceDir)){
        LOG_FREE(Debug, "initializeModelTempDir", "Copying '" << toString(sourceDir) << "' to '" << toString(destDir) << "'");

        test = copyDir(toQString(sourceDir), toQString(destDir));
        if (!test){
          LOG_FREE(Error, "initializeModelTempDir", "Could not copy '" << toString(sourceDir) << "' to '" << toString(destDir) << "'");
          result = false;
        }
      }
    }

    return result;
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:34,代码来源:FileOperations.cpp


示例2: toPath

  openstudio::path MainWindow::getOutDir(const openstudio::path &t_file, const openstudio::runmanager::Workflow &t_wf, const std::string &t_jobstring, bool t_simpleName)
  {
    openstudio::path outpath = m_runmanager.getConfigOptions().getOutputLocation();
    openstudio::path parentdir = t_file.parent_path();
    openstudio::path jobname;
    openstudio::path tailpathname = toPath("workflow-" + (t_simpleName?t_jobstring:t_wf.key()));

    QString jobstring = toQString(t_jobstring);
    jobstring.remove(">");

    if (openstudio::toString(t_file.stem()) == "in")
    {
      // The file is called "in", let's use the parent path's name as our job name
      jobname = openstudio::toPath(parentdir.filename());
    } else {
      // Let's use the stem of the file name to create a working dir, since it's a meaningful name
      jobname = openstudio::toPath(t_file.stem());     
    }

    std::string workflowkey = "workflow-" + t_wf.key();

    if (outpath.empty())
    {
      if (openstudio::toString(t_file.stem()) == "in")
      {
        return parentdir / tailpathname; // if we are running in the parent dir, and our name is "in" no reason to make a subdir
      } else {
        return parentdir / jobname / tailpathname; // we are either reconstructing the path it was already in, or making a new one based on the file name
      }

    } else {
      return outpath / jobname / tailpathname; // use the outpath
    }

  }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:35,代码来源:MainWindow.cpp


示例3: readLfr

SimFile::SimFile(openstudio::path path)
{
  m_hasLfr = false;
  m_hasNfr = false;
  m_hasNcr = false;
  // For now, we need to cheat and assume that the .lfr etc. actually exist
  // This means that simread has to have been run for this to work
  openstudio::path lfrPath = path.replace_extension(openstudio::toPath("lfr").string());
  m_hasLfr = readLfr(openstudio::toQString(lfrPath));
  openstudio::path nfrPath = path.replace_extension(openstudio::toPath("nfr").string());
  m_hasNfr = readNfr(openstudio::toQString(nfrPath));
}
开发者ID:MatthewSteen,项目名称:OpenStudio,代码行数:12,代码来源:SimFile.cpp


示例4: doit

openstudio::path ScriptFolderListView::iterateFileName(const openstudio::path &t_path)
{
  struct BuildFileName
  {
    static openstudio::path doit(const openstudio::path &t_root,
        const std::string &t_stem,
        const std::string &t_extension,
        int iteration)
    {
      std::stringstream numportion;
      if (iteration > 0)
      {
        numportion << "-";
        if (iteration < 10)
        {
          numportion << "0";
        } 
        numportion << iteration;
      }
      return t_root / openstudio::toPath(t_stem + numportion.str() + t_extension);
    }
  };

  std::string stem = openstudio::toString(t_path.stem());

  if (boost::regex_match(openstudio::toString(stem), boost::regex(".*-[0-9][0-9]")))
  {
    stem = stem.substr(0, stem.size() - 3);
  }

  int num = 99;
  openstudio::path p;
  openstudio::path last;
  do
  {
    last = p;
    p = BuildFileName::doit(t_path.parent_path(), openstudio::toString(stem), openstudio::toString(t_path.extension()), num);
    --num;
  } while (!boost::filesystem::exists(p) && num > -1);

  if (!boost::filesystem::exists(p))
  {
    return p;
  } else {
    return last;
  }


}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:49,代码来源:ScriptFolderListView.cpp


示例5: rootPathChanged

 void MainWindow::rootPathChanged(const openstudio::path &p)
 {
   if (toPath(ui.txtRootPath->text()) != p)
   {
     ui.txtRootPath->setText(toQString(p.external_file_string()));
   }
 }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:7,代码来源:MainWindow.cpp


示例6: OSItem

ScriptItem::ScriptItem(const openstudio::path& path,
                       OSItemType type,
                       QWidget * parent)
  : OSItem(scriptToItemId(path), type, parent),
    m_removed(false),
    m_scriptInfo(path, true, false)
{
  setText(openstudio::toQString(path.filename()));
  setLeftPixmap(QPixmap(":/images/icon_scripts.png"));
  if (boost::regex_search(toString(itemId().sourceId()),boost::regex("resource"))) {
    m_scriptInfo.isUserScript = false;
  }
  else {
    try {
      m_scriptInfo = runmanager::RubyJobBuilder::updateArgumentsFromDb(m_scriptInfo);
    } catch (const runmanager::ScriptDetectionError &e) {
      // Nothing to display here in the constructor
      m_scriptInfo = e.scriptInfo;
    }
  }


  std::shared_ptr<OSDocument> osDoc = OSAppBase::instance()->currentDocument();
  connect(this, &ScriptItem::argChanged, osDoc.get(), &OSDocument::markAsModified);
}
开发者ID:pepsi7959,项目名称:OpenStudio,代码行数:25,代码来源:ScriptItem.cpp


示例7: EpwFile

  boost::optional<EpwFile> WeatherFile_Impl::file(const openstudio::path& dir) const {
    boost::optional<EpwFile> result;

    // get current path
    boost::optional<openstudio::path> currentPath = this->path();
    if (currentPath){

      // try to load absolute path
      if (currentPath->is_complete() && boost::filesystem::exists(*currentPath)) {
        try {
          result = EpwFile(*currentPath);
          return result;
        }catch (...) {}

        // loading absolute path failed, try as relative path
        currentPath = toPath(currentPath->filename());
      }

      // try relative path
      if (!dir.empty()){
        openstudio::path newPath = boost::filesystem::complete(*currentPath, dir);
        if (boost::filesystem::exists(newPath)) {
          try {
            result = EpwFile(newPath);
            return result;
          }catch (...) {}
        }
      }
    }

    return boost::none;
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:32,代码来源:WeatherFile.cpp


示例8: createEnergyPlusJob

  Job JobFactory::createEnergyPlusJob(
      ToolInfo t_energyPlusTool,
      const openstudio::path &t_idd,
      const openstudio::path &t_idf,
      const openstudio::path &t_epw,
      const openstudio::path &t_outdir,
      const boost::optional<openstudio::UUID> &t_uuid)
  {
    JobParams params;
    params.append("outdir", toString(t_outdir));

    Tools tools;
    t_energyPlusTool.name = "energyplus";
    tools.append(t_energyPlusTool);

    Files files;
    FileInfo idf(t_idf, "idf");

    if (!t_idd.empty())
    {
      idf.addRequiredFile(t_idd,toPath("Energy+.idd"));
    }

    idf.addRequiredFile(t_epw, toPath("in.epw"));
    files.append(idf);

    return createEnergyPlusJob(tools, params, files, std::vector<openstudio::URLSearchPath>(), t_uuid);
  }
开发者ID:airguider,项目名称:OpenStudio,代码行数:28,代码来源:JobFactory.cpp


示例9: toPath

  boost::optional<TimeDependentValuationFile> TimeDependentValuation_Impl::file(const openstudio::path& dir) const {
    if (!m_file) {

      // get current path
      boost::optional<openstudio::path> currentPath = this->path();
      if (currentPath){
  
        // try to load absolute path
        if (currentPath->is_complete() && boost::filesystem::exists(*currentPath)) {
          m_file = TimeDependentValuationFile::load(*currentPath);

          // loading absolute path failed, try as relative path
          if (!m_file){
            currentPath = toPath(currentPath->filename());
          }
        }

        // try relative path
        if (!m_file){
          if (!dir.empty()){
            openstudio::path newPath = boost::filesystem::complete(*currentPath, dir);
            if (boost::filesystem::exists(newPath)) { 
              m_file = TimeDependentValuationFile::load(*currentPath);
            }
          }
        }
      }
    }
    return m_file;
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:30,代码来源:TimeDependentValuation.cpp


示例10: getFilename

  openstudio::path NormalizeURLs::getFilename(const QUrl &t_url, const openstudio::path &t_filename)
  {
    const std::map<QUrl, openstudio::path>::const_iterator itr = m_url_map.find(t_url);

    if (itr != m_url_map.end())
    {
      // we've already mapped this url, let's return the same one
      return itr->second;
    }

    const size_t existingcount = m_filenames.count(t_filename);

    if (existingcount == 0)
    {
      m_filenames.insert(t_filename);
      m_url_map[t_url] = t_filename;
      return t_filename;
    } else {
      openstudio::path newfilename 
        = toPath(t_filename.stem().string() + toPath("-" + boost::lexical_cast<std::string>(existingcount)).string() + t_filename.extension().string());

      // Make sure both the newly generated file name and the passed in file name are tracked for counting purposes
      m_filenames.insert(newfilename);
      m_filenames.insert(t_filename);

      m_url_map[t_url] = newfilename;
      return newfilename;
    }

  }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:30,代码来源:NormalizeURLs.cpp


示例11: saveModelTempDir

  void saveModelTempDir(const openstudio::path& modelTempDir, const openstudio::path& osmPath)
  {
    bool test = true;

    // must remove file, QFile::copy does not overwrite
    QFileInfo osmInfo(toQString(osmPath));
    if (osmInfo.exists() && osmInfo.isFile()){
      test = QFile::remove(toQString(osmPath));
      if (!test){
        LOG_FREE(Error, "saveModelTempDir", "Could not remove previous osm at '" << toString(osmPath) << "'");
      }
    }

    // copy osm file
    openstudio::path srcPath = modelTempDir / toPath("in.osm");
    test = QFile::copy(toQString(srcPath), toQString(osmPath));
    if (!test){
      LOG_FREE(Error, "saveModelTempDir", "Could not copy osm from '" << toString(srcPath) << "' to '" << toString(osmPath) << "'");
    }

    if( QFileInfo(toQString(osmPath)).exists() ) {

      // copy resources
      openstudio::path srcDir = modelTempDir / toPath("resources");
      openstudio::path dstDir =  osmPath.parent_path() / osmPath.stem();

      openstudio::path srcproject = srcDir / toPath("project.osp");
      openstudio::path destproject = dstDir / toPath("project.osp");

//      LOG_FREE(Debug, "saveModelTempDir", "copying project file: " << toString(srcproject) << " to " << toString(destproject));
//      QFile::copy(toQString(srcproject), toQString(destproject));

      LOG_FREE(Debug, "saveModelTempDir", "Copying " << toString(srcDir) << " to " << toString(dstDir));

      test = copyDir(toQString(srcDir), toQString(dstDir));
      if (!test){
        LOG_FREE(Error, "saveModelTempDir", "Could not copy '" << toString(srcDir) << "' to '" << toString(dstDir) << "'");
      }

      // TODO: Open all osps just copied over to make the stored paths look reasonable.

    }
  }
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:43,代码来源:FileOperations.cpp


示例12: connect

  ScriptsVectorController::ScriptsVectorController(const openstudio::path &t_path,
      const std::shared_ptr<QFileSystemWatcher> &t_fswatcher)
    : m_path(t_path), m_fswatcher(t_fswatcher)
  {
    connect(m_fswatcher.get(), &QFileSystemWatcher::directoryChanged, this, &ScriptsVectorController::directoryChanged);
    if (boost::filesystem::exists(t_path))
    {
      m_fswatcher->addPath(openstudio::toQString(t_path));
    }

    if (boost::filesystem::exists(t_path.parent_path()))
    {
      m_fswatcher->addPath(openstudio::toQString(t_path.parent_path()));
    }

    directoryChanged(openstudio::toQString(m_path));

    LOG(Debug, "Created ScriptVectorController " << m_path);
  }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:19,代码来源:ScriptsListView.cpp


示例13: complete

FileInfo FileInfo::complete(const openstudio::path &t_basePath) const
{
  if (t_basePath.empty() || fullPath.empty())
  {
    return *this;
  } else {
    FileInfo fi = *this;
    fi.fullPath = boost::filesystem::complete(fullPath, t_basePath);
    return fi;
  }
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:11,代码来源:FileInfo.cpp


示例14: toString

  void MainWindow::queueSimulation(const openstudio::path &t_input, const openstudio::path &t_epw)
  {
    try {
      // Build list of jobs to create
      std::string jobsstring = toString(ui.cbWorkflow->currentText());

      if (jobsstring == "<Custom>")
      {
        openstudio::path expecteddb = t_input.parent_path() / t_input.stem() / openstudio::toPath("run.db");

        if (!boost::filesystem::exists(expecteddb))
        {
          QMessageBox::critical(this, "Unable to launch job", "Db containing custom workflow for OpenStudio UI created OSM not found at the expected location: " + openstudio::toQString(expecteddb));
        } else {
          try {
            m_runmanager.loadJobs(expecteddb);
            statusBar()->showMessage("Job Queued - " + openstudio::toQString(t_input));
          } catch (const std::exception &e) {
            QMessageBox::critical(this, "Unable to launch job", e.what());
          }
        }
      } else {
        // parse the string list with the workflow constructor
        openstudio::runmanager::Workflow workflow(jobsstring);

        // Build list of tools
        openstudio::runmanager::Tools tools;
        ConfigOptions co = m_runmanager.getConfigOptions();
        tools.append(co.getTools());
        workflow.add(tools);

        workflow.setInputFiles(t_input, t_epw);
        openstudio::runmanager::Job job = workflow.create(getOutDir(t_input, workflow, jobsstring, co.getSimpleName()));

        m_runmanager.enqueue(job, false);
        statusBar()->showMessage("Job Queued - " + openstudio::toQString(job.description()));
      }
    } catch (const std::exception &e) {
      QMessageBox::critical(this, "Unable to launch job", e.what());
    }
  }
开发者ID:Rahjou,项目名称:OpenStudio,代码行数:41,代码来源:MainWindow.cpp


示例15: modelToSDD

  bool ForwardTranslator::modelToSDD(const openstudio::model::Model& model, const openstudio::path& path, ProgressBar* progressBar)
  {
    m_progressBar = progressBar;
    m_translatedObjects.clear();
    m_ignoreTypes.clear();
    m_ignoreObjects.clear();

    m_logSink.setThreadId(QThread::currentThread());

    m_logSink.resetStringStream();

    model::Model modelCopy = model.clone().cast<model::Model>();

    // remove unused resource objects
    modelCopy.purgeUnusedResourceObjects();

    boost::optional<QDomDocument> doc = this->translateModel(modelCopy);
    logUntranslatedObjects(modelCopy);
    if (!doc){
      return false;
    }

    if (exists(path)){
      remove(path);
    }

    if (!exists(path.parent_path())){
      create_directory(path.parent_path());
    }

    QFile file(toQString(path));
    if (file.open(QFile::WriteOnly)){
      QTextStream textStream(&file);
      textStream.setCodec("UTF-8");
      textStream << doc->toString(2);
      file.close();
      return true;
    }

    return false;
  }
开发者ID:urbanengr,项目名称:OpenStudio,代码行数:41,代码来源:ForwardTranslator.cpp


示例16: addScriptToFolder

void ScriptFolderListView::addScriptToFolder(const openstudio::path &t_path, const openstudio::path& folder_name)
{
  openstudio::path folder = m_rootPath / folder_name;
  boost::filesystem::create_directories(folder);
  openstudio::path filename = folder / t_path.filename();
  filename = iterateFileName(filename);
  boost::filesystem::copy_file(t_path, filename, boost::filesystem::copy_option::overwrite_if_exists);
  

  ScriptsListView *lv = m_scriptsListViews[folder];
  if (lv)
  {
    lv->updateData();
  }
}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:15,代码来源:ScriptFolderListView.cpp


示例17: makePathRelative

bool FileReference::makePathRelative(const openstudio::path& basePath) {
  openstudio::path newPath;
  if (basePath.empty()) {
    newPath = path().filename();
  }
  else {
    newPath = relativePath(path(),basePath);
  }
  if (newPath.empty()) {
    return false;
  }
  m_path = newPath;
  m_versionUUID = createUUID();
  return true;
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:15,代码来源:FileReference.cpp


示例18: makeUrlRelative

 bool WeatherFile_Impl::makeUrlRelative(const openstudio::path& basePath) {
   boost::optional<openstudio::path> currentPath = this->path();
   if (currentPath){
     openstudio::path newPath;
     if (basePath.empty()) {
       newPath = toPath(currentPath->filename());
     } else {
       newPath = relativePath(*currentPath,basePath);
     }
     if (!newPath.empty()) {
       std::string weatherFileUrl = toString(toURL(newPath));
       LOG(Debug,"Setting weather file url to " << weatherFileUrl);
       return setString(OS_WeatherFileFields::Url,weatherFileUrl);
     }
   }
   return false;
 }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:17,代码来源:WeatherFile.cpp


示例19: toPath

std::vector<openstudio::path> ProjectVersioningFixture::projectDatabasePaths(
    openstudio::path basePath)
{
  std::vector<openstudio::path> result;

  if (basePath.empty()) {
    basePath = toPath("ProjectVersioningFixtureData") / toPath(toString(uuid));
  }

  for (boost::filesystem::directory_iterator it(basePath), itend; it != itend; ++it)
  {
    if (getFileExtension(it->path()) == "osp") {
      result.push_back(it->path());
    }
  }
  return result;
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:17,代码来源:ProjectVersioningFixture.cpp


示例20: m_uuid

FileReference::FileReference(const openstudio::path& p)
  : m_uuid(createUUID()),
    m_versionUUID(createUUID()),
    m_name(toString(p)),
    m_displayName(toString(p.filename())),
    m_path(completeAndNormalize(p)),
    m_timestampLast(),
    m_checksumCreate(checksum(m_path)),
    m_checksumLast(m_checksumCreate)
{
  try {
    m_fileType = FileReferenceType(getFileExtension(p));
  }
  catch (...) {
    m_fileType = FileReferenceType::Unknown;
  }
  update(openstudio::path());
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:18,代码来源:FileReference.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ detail::WorkspaceObject_Impl类代码示例发布时间:2022-05-31
下一篇:
C++ opensim::Body类代码示例发布时间: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