本文整理汇总了C++中URI::base_path方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::base_path方法的具体用法?C++ URI::base_path怎么用?C++ URI::base_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::base_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_filename
std::string build_filename(const URI& input, const Uint rank)
{
const URI my_dir = input.base_path();
const std::string basename = input.base_name();
const URI result(my_dir / (basename + "_P" + to_str(rank) + ".cfbin"));
return result.path();
}
示例2: complete_path
void Component::complete_path ( URI& path ) const
{
using namespace boost::algorithm;
// CFinfo << "PATH [" << path.string() << "]\n" << CFflush;
cf_assert( path.scheme() == URI::Scheme::CPATH );
if(path.empty())
path = "./";
if ( is_null(m_raw_parent) )
throw InvalidURI(FromHere(), "Component \'" + name() + "\' has no parent");
if (m_root.expired())
throw InvalidURI(FromHere(), "Component \'" + name() + "\' has no root");
boost::shared_ptr<Component> parent = m_raw_parent->self();
boost::shared_ptr<Component> root = m_root.lock();
std::string sp = path.path();
if ( path.is_relative() ) // transform it to absolute
{
if ( starts_with(sp,"/") ) // remove leading "/" if any
boost::algorithm::replace_first(sp, "/", "" );
// substitute leading "../" for uri() of parent
if (starts_with(sp,".."))
{
std::string pfp = parent->uri().path();
boost::algorithm::replace_first(sp, "..", pfp);
}
// substitute leading "./" for uri() of this component
else if (starts_with(sp,"."))
{
boost::algorithm::replace_first(sp, ".", uri().path());
}
else
{
sp = uri().path()+"/"+sp;
}
}
cf_assert ( URI(sp).is_absolute() );
// break path in tokens and loop on them, while concatenaitng to a new path
boost::char_separator<char> sep("/");
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
tokenizer tok (sp,sep);
path = "/" ;
std::string last;
for(tokenizer::iterator el=tok.begin(); el!=tok.end(); ++el)
{
if ( equals (*el, ".") ) continue; // substitute any "/./" for nothing
if ( equals (*el, "..") ) // substitute any "../" for base path
path = path.base_path();
else
path /= *el;
}
// CFinfo << "FINAL PATH: [" << path.string() << "]\n" << CFflush;
cf_assert ( path.is_complete() );
}