+#ifndef WXREGEX_USING_RE_SEARCH
+
+// the array of offsets for the matches, the usual POSIX regmatch_t array.
+class wxRegExMatches
+{
+public:
+ typedef regmatch_t *match_type;
+
+ wxRegExMatches(size_t n) { m_matches = new regmatch_t[n]; }
+ ~wxRegExMatches() { delete [] m_matches; }
+
+ // we just use casts here because the fields of regmatch_t struct may be 64
+ // bit but we're limited to size_t in our public API and are not going to
+ // change it because operating on strings longer than 4GB using it is
+ // absolutely impractical anyhow
+ size_t Start(size_t n) const
+ {
+ return wx_truncate_cast(size_t, m_matches[n].rm_so);
+ }
+
+ size_t End(size_t n) const
+ {
+ return wx_truncate_cast(size_t, m_matches[n].rm_eo);
+ }
+
+ regmatch_t *get() const { return m_matches; }
+
+private:
+ regmatch_t *m_matches;
+};
+
+#else // WXREGEX_USING_RE_SEARCH
+
+// the array of offsets for the matches, the struct used by the GNU lib
+class wxRegExMatches
+{
+public:
+ typedef re_registers *match_type;
+
+ wxRegExMatches(size_t n)
+ {
+ m_matches.num_regs = n;
+ m_matches.start = new regoff_t[n];
+ m_matches.end = new regoff_t[n];
+ }
+
+ ~wxRegExMatches()
+ {
+ delete [] m_matches.start;
+ delete [] m_matches.end;
+ }
+
+ size_t Start(size_t n) const { return m_matches.start[n]; }
+ size_t End(size_t n) const { return m_matches.end[n]; }
+
+ re_registers *get() { return &m_matches; }
+
+private:
+ re_registers m_matches;
+};
+
+#endif // WXREGEX_USING_RE_SEARCH
+