mail[Wesnoth-commits] r20095 - in /trunk/src/serialization: string_utils.cpp string_utils.hpp


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

Header


Content

Posted by patrick_X99 on September 04, 2007 - 05:02:
Author: sapient
Date: Tue Sep  4 05:01:44 2007
New Revision: 20095

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20095&view=rev
Log:
add a utility for parsing multiple ranges

Modified:
    trunk/src/serialization/string_utils.cpp
    trunk/src/serialization/string_utils.hpp

Modified: trunk/src/serialization/string_utils.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/string_utils.cpp?rev=20095&r1=20094&r2=20095&view=diff
==============================================================================
--- trunk/src/serialization/string_utils.cpp (original)
+++ trunk/src/serialization/string_utils.cpp Tue Sep  4 05:01:44 2007
@@ -472,6 +472,17 @@
                res.second = res.first;
 
        return res;
+}
+
+std::vector< std::pair< int, int > > parse_ranges(std::string const &str)
+{
+       std::vector< std::pair< int, int > > to_return;
+       std::vector<std::string> strs = utils::split(str);
+       std::vector<std::string>::const_iterator i, i_end=strs.end();
+       for(i = strs.begin(); i != i_end; ++i) {
+               to_return.push_back(parse_range(*i));
+       }
+       return to_return;
 }
 
 int byte_size_from_utf8_first(unsigned char ch)

Modified: trunk/src/serialization/string_utils.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/string_utils.hpp?rev=20095&r1=20094&r2=20095&view=diff
==============================================================================
--- trunk/src/serialization/string_utils.hpp (original)
+++ trunk/src/serialization/string_utils.hpp Tue Sep  4 05:01:44 2007
@@ -58,6 +58,7 @@
 std::vector< std::string > quoted_split(std::string const &val, char c= ',',
                                         int flags = REMOVE_EMPTY | 
STRIP_SPACES, char quote = '\\');
 std::pair< int, int > parse_range(std::string const &str);
+std::vector< std::pair< int, int > > parse_ranges(std::string const &str);
 int apply_modifier( const int number, const std::string &amount, const int 
minimum = 0);
 std::string &escape(std::string &str, const std::string& special_chars);
 std::string &escape(std::string &str);




Related Messages


Powered by MHonArc, Updated Tue Sep 04 06:00:17 2007