本文整理汇总了C++中openstudio::path::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ path::empty方法的具体用法?C++ path::empty怎么用?C++ path::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio::path
的用法示例。
在下文中一共展示了path::empty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: makePathAbsolute
bool FileReference::makePathAbsolute(const openstudio::path& searchDirectory) {
// trivial completion
openstudio::path currentPath = path();
if (currentPath.is_complete() && openstudio::filesystem::exists(currentPath)) {
return true;
}
openstudio::path workingPath(currentPath);
// if currentPath is complete but does not exist, go to extreme measures
if (currentPath.is_complete()) {
workingPath = currentPath.filename();
}
if (searchDirectory.empty()) {
return false;
}
openstudio::path newPath = openstudio::filesystem::complete(workingPath,searchDirectory);
if (newPath.empty() || !openstudio::filesystem::exists(newPath)) {
return false;
}
m_path = completeAndNormalize(newPath);
m_versionUUID = createUUID();
return true;
}