本文整理汇总了C++中path::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ path::begin方法的具体用法?C++ path::begin怎么用?C++ path::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类path
的用法示例。
在下文中一共展示了path::begin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findPathFlow
F findPathFlow(const path& p) const {
F minFlow = resCap(*p.begin(), *(p.begin() + 1));
for (typename path::const_iterator v = p.begin(); v != p.end() - 1; ++v) {
minFlow = std::min(minFlow, resCap(*v, *(v + 1)));
}
return minFlow;
}
示例2: checkBeginEndBasic
void checkBeginEndBasic() {
using namespace fs;
using It = path::iterator;
{
path const p;
ASSERT_SAME_TYPE(It, decltype(p.begin()));
ASSERT_SAME_TYPE(It, decltype(p.end()));
assert(p.begin() == p.end());
}
{
path const p("foo");
It default_constructed;
default_constructed = p.begin();
assert(default_constructed == p.begin());
assert(default_constructed != p.end());
default_constructed = p.end();
assert(default_constructed == p.end());
assert(default_constructed != p.begin());
}
{
path p("//root_name//first_dir////second_dir");
const path expect[] = {"/", "root_name", "first_dir", "second_dir"};
assert(checkCollectionsEqual(p.begin(), p.end(), std::begin(expect), std::end(expect)));
assert(checkCollectionsEqualBackwards(p.begin(), p.end(), std::begin(expect), std::end(expect)));
}
{
path p("////foo/bar/baz///");
const path expect[] = {"/", "foo", "bar", "baz", ""};
assert(checkCollectionsEqual(p.begin(), p.end(), std::begin(expect), std::end(expect)));
assert(checkCollectionsEqualBackwards(p.begin(), p.end(), std::begin(expect), std::end(expect)));
}
}
示例3: checkIteratorConcepts
void checkIteratorConcepts() {
using namespace fs;
using It = path::iterator;
using Traits = std::iterator_traits<It>;
ASSERT_SAME_TYPE(Traits::iterator_category, std::bidirectional_iterator_tag);
ASSERT_SAME_TYPE(Traits::value_type, path);
ASSERT_SAME_TYPE(Traits::pointer, path const*);
ASSERT_SAME_TYPE(Traits::reference, path const&);
{
It it;
ASSERT_SAME_TYPE(It&, decltype(++it));
ASSERT_SAME_TYPE(It, decltype(it++));
ASSERT_SAME_TYPE(It&, decltype(--it));
ASSERT_SAME_TYPE(It, decltype(it--));
ASSERT_SAME_TYPE(Traits::reference, decltype(*it));
ASSERT_SAME_TYPE(Traits::pointer, decltype(it.operator->()));
ASSERT_SAME_TYPE(std::string const&, decltype(it->native()));
ASSERT_SAME_TYPE(bool, decltype(it == it));
ASSERT_SAME_TYPE(bool, decltype(it != it));
}
{
path const p;
ASSERT_SAME_TYPE(It, decltype(p.begin()));
ASSERT_SAME_TYPE(It, decltype(p.end()));
assert(p.begin() == p.end());
}
}
示例4: remove_dir
void remove_dir(path& p)
{
assert(p.begin() != p.end());
path tmp;
for (path::iterator i = boost::next(p.begin()); i != p.end(); ++i)
tmp /= *i;
p = tmp;
}
示例5:
path
decapitate(const path& p)
{
path ret;
for (auto it = p.begin(); it != p.end(); ++it)
if (it != p.begin())
ret /= *it;
return ret;
}
示例6: lexically_relative
path lexically_relative(const path& p, const path& base)
{
std::pair<path::iterator, path::iterator> mm
= detail::mismatch(p.begin(), p.end(), base.begin(), base.end());
if (mm.first == p.begin() && mm.second == base.begin())
return path();
if (mm.first == p.end() && mm.second == base.end())
return detail::dot_path();
path tmp;
for (; mm.second != base.end(); ++mm.second)
tmp /= detail::dot_dot_path();
for (; mm.first != p.end(); ++mm.first)
tmp /= *mm.first;
return tmp;
}
示例7: resolve
path Attributes::resolve(path name)
{
Attribute *a = _search_attr(attrs, name.generic_string());
if (a && a->link().size() == 0)
return name;
path partial;
for(auto it=name.begin();it!=name.end();++it) {
partial /= *it;
a = _search_attr(attrs, partial.generic_string());
if (a) {
if (a->link().size()) {
path rest(a->link());
++it;
//everything matched - this is a link!
if (it == name.end())
return a->link();
for(;it!=name.end();++it)
rest /= *it;
return resolve(rest);
}
else //name is no valid path!
return name;
}
}
return name;
}
示例8: Relative
path::iterator Relative(const path &testPath, const path &subPath)
{
path::iterator tIter = testPath.begin();
path::iterator sIter = subPath.begin();
for (;;) {
if (sIter == subPath.end()) {
return tIter;
} else if (tIter == testPath.end()) {
// testpath is shorter
return testPath.end();
} else if (*tIter != *sIter) {
return testPath.end();
}
++tIter;
++sIter;
}
}
示例9: NaiveUncomplete
path NaiveUncomplete ( const path file, const path base )
{
if ( file.has_root_path() ) {
if ( file.root_path() != base.root_path() ) {
return file;
} else {
return NaiveUncomplete ( file.relative_path(), base.relative_path() );
}
} else {
if ( file.has_root_path() ) {
throw "cannot uncomplete a path relative path from a rooted base";
} else {
typedef path::const_iterator path_iterator;
path_iterator path_it = file.begin();
path_iterator base_it = base.begin();
while ( path_it != file.end() && base_it != base.end() ) {
if ( *path_it != *base_it ) {
break;
}
++path_it; ++base_it;
}
path result;
for ( ; base_it != base.end(); ++base_it ) {
result /= "..";
}
for ( ; path_it != file.end(); ++path_it ) {
result /= *path_it;
}
return result;
}
}
} // NaiveUncomplete
示例10: normalize
inline path
normalize (path const& p)
{
path result;
for (path::iterator i (p.begin ()), e (p.end ()); i != e; ++i)
{
if (*i != ".") result /= path (*i, native);
}
return result;
}
示例11: relativize
// Return path when appended to parent will resolve to same as child
path relativize(path parent, path child){
parent = canonical(parent);
child = canonical(child);
// Find common base
path::const_iterator parent_iter(parent.begin()), child_iter(child.begin());
path::const_iterator child_end(child.end()), parent_end(parent.end());
while(parent_iter != parent_end && child_iter != child_end && *parent_iter == *child_iter)
++parent_iter, ++child_iter;
// Navigate backwards in directory to reach previously found base
path ret;
while(parent_iter != parent_end)
{
if( (*parent_iter) != "." )
ret /= "..";
++parent_iter;
}
// Now navigate down the directory branch
ret.append(child_iter, child.end());
return ret;
}
示例12: expandvars
path CUtils::expandvars(path p) {
path rp;
path::iterator it = p.begin();
while (it != p.end()) {
cerr << *it << endl;
string elem(it->string());
if(elem.compare("~") == 0) {
elem = string(getenv("HOME"));
}
if(elem.find_first_of('$') == 0) {
const char* envvar = getenv( elem.substr(1).c_str() );
if(envvar != NULL) {
elem = envvar;
}
}
rp /= elem;
cerr << " " << rp << endl;
++it;
}
return rp;
}
示例13: pushFlowThrowPath
void pushFlowThrowPath(const path& p, const F& pFlow) {
for (typename path::const_iterator v = p.begin(); v != p.end() - 1; ++v) {
flows.at(*v).at(*(v + 1)) += pFlow;
flows.at(*(v + 1)).at(*v) -= pFlow;
}
}
示例14: lexically_normal
path lexically_normal(const path& p)
{
if (p.empty())
return p;
path temp;
path::iterator start(p.begin());
path::iterator last(p.end());
path::iterator stop(last--);
for (path::iterator itr(start); itr != stop; ++itr)
{
// ignore "." except at start and last
if (itr->native().size() == 1
&& (itr->native())[0] == dot
&& itr != start
&& itr != last) continue;
// ignore a name and following ".."
if (!temp.empty()
&& itr->native().size() == 2
&& (itr->native())[0] == dot
&& (itr->native())[1] == dot) // dot dot
{
string_type lf(temp.filename().native());
if (lf.size() > 0
&& (lf.size() != 1
|| (lf[0] != dot
&& lf[0] != separator))
&& (lf.size() != 2
|| (lf[0] != dot
&& lf[1] != dot
# ifdef BOOST_WINDOWS_API
&& lf[1] != colon
# endif
)
)
)
{
temp.remove_filename();
//// if not root directory, must also remove "/" if any
//if (temp.native().size() > 0
// && temp.native()[temp.native().size()-1]
// == separator)
//{
// string_type::size_type rds(
// root_directory_start(temp.native(), temp.native().size()));
// if (rds == string_type::npos
// || rds != temp.native().size()-1)
// {
// temp.m_pathname.erase(temp.native().size()-1);
// }
//}
path::iterator next(itr);
if (temp.empty() && ++next != stop
&& next == last && *last == detail::dot_path())
{
temp /= detail::dot_path();
}
continue;
}
}
temp /= *itr;
};
if (temp.empty())
temp /= detail::dot_path();
return temp;
}