本文整理汇总了C++中openstudio::path::extension方法的典型用法代码示例。如果您正苦于以下问题:C++ path::extension方法的具体用法?C++ path::extension怎么用?C++ path::extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstudio::path
的用法示例。
在下文中一共展示了path::extension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iterateFileName
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;
}
}
示例2: 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;
}
}