X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fstrings%2Fregmatch.h;h=6af309ea72185ea91e43706c1ef38538ced51976;hb=9990be018b49e5aae27218e1b8c6aefdb63b38a7;hp=19cac11027dac128f6cdd537fe771d3a2316a2d9;hpb=b56eb5ec1da675da0c66abc53c1e4f6c4e4cccbd;p=libs%2Fcore.git diff --git a/source/strings/regmatch.h b/source/strings/regmatch.h index 19cac11..6af309e 100644 --- a/source/strings/regmatch.h +++ b/source/strings/regmatch.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspstrings -Copyright © 2007 Mikko Rasa -Distributed under the LGPL -*/ - #ifndef MSP_STRINGS_REGMATCH_H_ #define MSP_STRINGS_REGMATCH_H_ @@ -31,24 +24,23 @@ public: */ struct Group { - bool match; //< Whether or not this group matched - unsigned begin; //< First offset of the match - unsigned end; //< One-past-last offset - unsigned length; //< Length of the match (end-begin) - std::string str; //< The part of the string that matched - - Group(): match(false) { } - operator bool() const { return match; } - }; + typedef std::string::size_type size_type; + + bool match = false; //< Whether or not this group matched + size_type begin; //< First offset of the match + size_type end; //< One-past-last offset + size_type length; //< Length of the match (end-begin) + std::string str; //< The part of the string that matched - typedef std::vector GroupArray; + explicit operator bool() const { return match; } + }; private: - GroupArray groups; + std::vector groups; public: /** Constructs a RegMatch representing a non-match. */ - RegMatch() { } + RegMatch() = default; /** Constructs a new RegMatch from a string and groups. The length and str members of each group are computed and need not be set. Intended to be used @@ -73,7 +65,7 @@ public: /** Shorthand for the group() function. */ const Group &operator[](unsigned i) const { return group(i); } - operator bool() const { return !empty(); } + explicit operator bool() const { return !empty(); } }; } // namespace Msp