Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17654
Modified Files:
match_results.hpp regex_iterator.hpp regex_token_iterator.hpp
Log Message:
fix some doc bugs, simpler regex_token_iterator_impl::next()
Index: match_results.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/match_results.hpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- match_results.hpp 24 May 2007 23:25:40 -0000 1.19
+++ match_results.hpp 29 May 2007 07:28:52 -0000 1.20
@@ -250,6 +250,7 @@
/// \post regex_id() == 0
/// \post size() == 0
/// \post empty() == true
+ /// \post str() == string_type()
match_results()
: regex_id_(0)
, sub_matches_()
@@ -322,8 +323,9 @@
return *this;
}
- /// Returns the number of sub_match elements stored in *this.
- ///
+ /// Returns one plus the number of marked sub-expressions in the regular
+ /// expression that was matched if *this represents the result of a
+ /// successful match. Otherwise returns 0.
size_type size() const
{
return this->sub_matches_.size();
@@ -351,7 +353,7 @@
return this->sub_matches_[ sub ].matched ? std::distance(this->base_,
this->sub_matches_[ sub ].first) : -1;
}
- /// Returns string_type((*this)[sub]).
+ /// Returns (*this)[sub].str().
///
string_type str(size_type sub = 0) const
{
@@ -359,13 +361,14 @@
}
/// Returns a reference to the sub_match object representing the sequence
that
- /// matched marked sub-expression sub. If sub == 0 then returns a
reference to a sub_match object
- /// representing the sequence that matched the whole regular expression.
- /// \pre sub \< (*this).size().
- template<typename Index>
- const_reference operator [](Index const &index) const
+ /// matched marked sub-expression sub. If sub == 0 then returns a
reference to
+ /// a sub_match object representing the sequence that matched the whole
regular
+ /// expression. If sub >= size() then returns a sub_match object
representing an
+ /// unmatched sub-expression.
+ template<typename Sub>
+ const_reference operator [](Sub const &sub) const
{
- return this->at_(index);
+ return this->at_(sub);
}
/// Returns a reference to the sub_match object representing the character
sequence from
@@ -400,7 +403,7 @@
return this->sub_matches_.end();
}
- /// Returns a true value if(*this)[0].matched, else returns a false value.
+ /// Returns a true value if (*this)[0].matched, else returns a false value.
///
operator bool_type() const
{
Index: regex_iterator.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_iterator.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- regex_iterator.hpp 17 Apr 2007 05:02:32 -0000 1.7
+++ regex_iterator.hpp 29 May 2007 07:28:52 -0000 1.8
@@ -164,7 +164,7 @@
/// only if that fails and provided what[0].second != suffix().second does
it look for a (possibly
/// zero length) match starting from what[0].second + 1. If no further
match is found then sets
/// *this equal to the end of sequence iterator.
- /// \post (*this)-\>size() == pre-\>mark_count()
+ /// \post (*this)-\>size() == pre-\>mark_count() + 1
/// \post (*this)-\>empty() == false
/// \post (*this)-\>prefix().first == An iterator denoting the end point
of the previous match found
/// \post (*this)-\>prefix().last == (**this)[0].first
Index: regex_token_iterator.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_token_iterator.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- regex_token_iterator.hpp 29 May 2007 03:06:10 -0000 1.7
+++ regex_token_iterator.hpp 29 May 2007 07:28:52 -0000 1.8
@@ -16,6 +16,7 @@
#endif
#include <vector>
+#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
@@ -46,9 +47,10 @@
)
: iter_(begin, cur, end, rex, flags, not_null)
, result_()
- , n_((-2 == n) ? static_cast<int>(subs.size()) - 1 : n)
+ , n_((-2 == n) ? (int)subs.size() - 1 : n)
, subs_()
{
+ BOOST_ASSERT(0 != subs.size());
this->subs_.swap(subs);
}
@@ -57,30 +59,20 @@
if(-1 != this->n_)
{
BidiIter cur = this->iter_.state_.cur_;
- if(++this->n_ != static_cast<int>(this->subs_.size()))
- {
- this->result_ = (-1 == this->subs_[ this->n_ ])
- ? this->iter_.what_.prefix().str()
- : this->iter_.what_[ this->subs_[ this->n_ ] ].str();
- return true;
- }
- else if(this->iter_.next())
+ if(0 != (++this->n_ %= (int)this->subs_.size()) ||
this->iter_.next())
{
- this->n_ = 0;
this->result_ = (-1 == this->subs_[ this->n_ ])
? this->iter_.what_.prefix().str()
: this->iter_.what_[ this->subs_[ this->n_ ] ].str();
return true;
}
- else if(cur != this->iter_.state_.end_ && -1 == this->subs_[ 0 ])
+ else if(-1 == this->subs_[ this->n_-- ] && cur !=
this->iter_.state_.end_)
{
- this->n_ = -1;
this->result_ = value_type(cur, this->iter_.state_.end_);
return true;
}
}
- this->n_ = -1;
return false;
}
@@ -150,11 +142,16 @@
/// INTERNAL ONLY
typedef detail::regex_token_iterator_impl<BidiIter> impl_type_;
+ /// \post \c *this is the end of sequence iterator.
regex_token_iterator()
: impl_()
{
}
+ /// \param begin The beginning of the character range to search.
+ /// \param end The end of the character range to search.
+ /// \param rex The regex pattern to search for.
+ /// \pre \c [begin,end) is a valid range.
regex_token_iterator
(
BidiIter begin
@@ -166,25 +163,33 @@
this->next_();
}
- template<typename SubMatches>
+ /// \param begin The beginning of the character range to search.
+ /// \param end The end of the character range to search.
+ /// \param rex The regex pattern to search for.
+ /// \pre \c [begin,end) is a valid range.
+ /// \pre \c subs is either an integer greater or equal to -1,
+ /// or else an array or non-empty \c std::vector\<\> of such integers.
+ template<typename Subs>
regex_token_iterator
(
BidiIter begin
, BidiIter end
, basic_regex<BidiIter> const &rex
- , SubMatches const &sub_matches
+ , Subs const &subs
, regex_constants::match_flag_type flags = regex_constants::match_default
)
- : impl_(new impl_type_(begin, begin, end, &rex, flags,
detail::to_vector(sub_matches)))
+ : impl_(new impl_type_(begin, begin, end, &rex, flags,
detail::to_vector(subs)))
{
this->next_();
}
+ /// \post <tt>*this == that</tt>
regex_token_iterator(regex_token_iterator<BidiIter> const &that)
: impl_(that.impl_) // COW
{
}
+ /// \post <tt>*this == that</tt>
regex_token_iterator<BidiIter> &operator =(regex_token_iterator<BidiIter>
const &that)
{
this->impl_ = that.impl_; // COW
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs