mail[Wesnoth-commits] r44586 - in /trunk/src: config.cpp config.hpp variable.cpp variable.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on July 23, 2010 - 16:43:
Author: silene
Date: Fri Jul 23 16:43:28 2010
New Revision: 44586

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44586&view=rev
Log:
Cleaned typing of proxy iterators a bit.

Modified:
    trunk/src/config.cpp
    trunk/src/config.hpp
    trunk/src/variable.cpp
    trunk/src/variable.hpp

Modified: trunk/src/config.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config.cpp?rev=44586&r1=44585&r2=44586&view=diff
==============================================================================
--- trunk/src/config.cpp (original)
+++ trunk/src/config.cpp Fri Jul 23 16:43:28 2010
@@ -679,7 +679,7 @@
        return children.empty() && values.empty();
 }
 
-config::any_child config::all_children_iterator::operator*() const
+config::all_children_iterator::reference 
config::all_children_iterator::operator*() const
 {
        return any_child(&i_->pos->first, i_->pos->second[i_->index]);
 }

Modified: trunk/src/config.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/config.hpp?rev=44586&r1=44585&r2=44586&view=diff
==============================================================================
--- trunk/src/config.hpp (original)
+++ trunk/src/config.hpp Fri Jul 23 16:43:28 2010
@@ -341,26 +341,26 @@
 
        struct all_children_iterator
        {
-               typedef any_child value_type;
-               typedef std::forward_iterator_tag iterator_category;
-               typedef int difference_type;
-               typedef any_child *pointer;
-               typedef any_child reference;
-               typedef std::vector<child_pos>::const_iterator Itor;
-               explicit all_children_iterator(const Itor &i): i_(i) {}
-
-               all_children_iterator &operator++() { ++i_; return *this; }
-               all_children_iterator operator++(int) { return 
all_children_iterator(i_++); }
-
                struct arrow_helper
                {
                        any_child data;
                        arrow_helper(const all_children_iterator &i): 
data(*i) {}
-                       any_child *operator->() { return &data; }
+                       const any_child *operator->() const { return &data; }
                };
 
-               any_child operator*() const;
-               arrow_helper operator->() const { return *this; }
+               typedef any_child value_type;
+               typedef std::forward_iterator_tag iterator_category;
+               typedef int difference_type;
+               typedef const arrow_helper pointer;
+               typedef const any_child reference;
+               typedef std::vector<child_pos>::const_iterator Itor;
+               explicit all_children_iterator(const Itor &i): i_(i) {}
+
+               all_children_iterator &operator++() { ++i_; return *this; }
+               all_children_iterator operator++(int) { return 
all_children_iterator(i_++); }
+
+               reference operator*() const;
+               pointer operator->() const { return *this; }
 
                bool operator==(const all_children_iterator &i) const { 
return i_ == i.i_; }
                bool operator!=(const all_children_iterator &i) const { 
return i_ != i.i_; }

Modified: trunk/src/variable.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.cpp?rev=44586&r1=44585&r2=44586&view=diff
==============================================================================
--- trunk/src/variable.cpp (original)
+++ trunk/src/variable.cpp Fri Jul 23 16:43:28 2010
@@ -394,12 +394,12 @@
        return i;
 }
 
-std::pair<const std::string,const vconfig> 
vconfig::all_children_iterator::operator*() const
-{
-       return std::make_pair<const std::string, const vconfig>(get_key(), 
get_child());
-}
-
-vconfig::all_children_iterator::pointer_proxy 
vconfig::all_children_iterator::operator->() const
+vconfig::all_children_iterator::reference 
vconfig::all_children_iterator::operator*() const
+{
+       return value_type(get_key(), get_child());
+}
+
+vconfig::all_children_iterator::pointer 
vconfig::all_children_iterator::operator->() const
 {
        pointer_proxy p = { value_type(get_key(), get_child()) };
        return p;

Modified: trunk/src/variable.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.hpp?rev=44586&r1=44585&r2=44586&view=diff
==============================================================================
--- trunk/src/variable.hpp (original)
+++ trunk/src/variable.hpp Fri Jul 23 16:43:28 2010
@@ -75,22 +75,23 @@
        bool has_attribute(const std::string& key) const { return 
cfg_->has_attribute(key); }
        bool empty() const { return (null() || cfg_->empty()); }
 
-       struct all_children_iterator {
+       struct all_children_iterator
+       {
+               struct pointer_proxy;
+
                typedef std::pair<const std::string, const vconfig> 
value_type;
                typedef std::forward_iterator_tag iterator_category;
                typedef int difference_type;
-               typedef const value_type *pointer;
-               typedef value_type& reference;
+               typedef const pointer_proxy pointer;
+               typedef const value_type reference;
                typedef config::all_children_iterator Itor;
                explicit all_children_iterator(const Itor &i, const config 
*cache_key = NULL);
 
                all_children_iterator& operator++();
                all_children_iterator  operator++(int);
 
-               struct pointer_proxy;
-
-               value_type operator*() const;
-               pointer_proxy operator->() const;
+               reference operator*() const;
+               pointer operator->() const;
 
                std::string get_key() const;
                const vconfig get_child() const;
@@ -121,7 +122,7 @@
 struct vconfig::all_children_iterator::pointer_proxy
 {
        value_type p;
-       pointer operator->() const { return &p; }
+       const value_type *operator->() const { return &p; }
 };
 
 namespace variable




Related Messages


Powered by MHonArc, Updated Fri Jul 23 17:00:16 2010