Mirror reflection library - Lagoon run-time layer 0.5.13

lagoon/range/link.hpp

Go to the documentation of this file.
00001 
00010 #ifndef LAGOON_RANGE_LINK_1011291729_HPP
00011 #define LAGOON_RANGE_LINK_1011291729_HPP
00012 
00013 #include <lagoon/range/utils.hpp>
00014 #include <cassert>
00015 #include <list>
00016 
00017 LAGOON_NAMESPACE_BEGIN
00018 
00019 namespace aux {
00020 
00021 template <class Range>
00022 class linked : public leaping_base
00023 {
00024 private:
00025     // the linked list of ranges
00026     std::list<Range> ranges;
00027 
00028     void skip_empty(void)
00029     {
00030         while(!ranges.empty())
00031         {
00032             if(ranges.front().empty())
00033                 ranges.pop_front();
00034             else break;
00035         }
00036     }
00037 public:
00038     linked(void){ }
00039 
00041     linked(const std::initializer_list<Range>& rngs)
00042      : ranges(rngs)
00043     {
00044         skip_empty();
00045     }
00046 
00048     bool empty(void) const
00049     {
00050         return ranges.empty();
00051     }
00052 
00054     void step_front(void)
00055     {
00056         assert(!empty());
00057         ranges.front().step_front();
00058         skip_empty();
00059     }
00060 
00061     size_t leap_front(size_t leap)
00062     {
00063         return leaping_base::do_leap_front(*this, leap);
00064     }
00065 
00067     auto front(void) const -> decltype(ranges.front().front())
00068     {
00069         assert(!empty());
00070         return ranges.front().front();
00071     }
00072 
00074     void append(const Range& rng)
00075     {
00076         if(!rng.empty()) ranges.push_back(rng);
00077     }
00078 };
00079 
00080 } // namespace aux
00081 
00082 #ifdef MIRROR_DOCUMENTATION_ONLY
00083 
00084 
00092 template <class Range>
00093 UnspecifiedRange link(const std::initializer_list<Range>& ranges);
00094 #else
00095 
00096 // link ranges
00097 template <class Range>
00098 aux::linked<Range> link(const std::initializer_list<Range>& ranges)
00099 {
00100     return aux::linked<Range>(ranges);
00101 }
00102 
00103 #endif
00104 
00105 LAGOON_NAMESPACE_END
00106 
00107 #endif //include guard
00108 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.