コード例 #1
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
void
cre2_error_arg (const cre2_regexp_t *re, cre2_string_t *arg)
{
  const std::string &argstr = TO_CONST_RE2(re)->error_arg();
  arg->data   = argstr.data();
  arg->length = argstr.length();
}
コード例 #2
0
ファイル: cre2.cpp プロジェクト: rjmcguire/cre2
int
cre2_match (const cre2_regexp_t *re , const char *text,
	    int textlen, int startpos, int endpos, cre2_anchor_t anchor,
	    cre2_string_t *match, int nmatch)
{
  re2::StringPiece	text_re2(text, textlen);
  re2::StringPiece	match_re2[nmatch];
  RE2::Anchor		anchor_re2 = RE2::UNANCHORED;
  bool			retval; // 0 for no match
                                // 1 for successful matching
  switch (anchor) {
  case CRE2_ANCHOR_START:
    anchor_re2 = RE2::ANCHOR_START;
    break;
  case CRE2_ANCHOR_BOTH:
    anchor_re2 = RE2::ANCHOR_BOTH;
    break;
  case CRE2_UNANCHORED:
    break;
  }
  retval = TO_CONST_RE2(re)->Match(text_re2, startpos, endpos, anchor_re2, match_re2, nmatch);
  if (retval) {
    for (int i=0; i<nmatch; i++) {
      match[i].data   = match_re2[i].data();
      match[i].length = match_re2[i].length();
    }
  }
  return (retval)? 1 : 0;
}
コード例 #3
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
int
cre2_match (const cre2_regexp_t *re , const char *text,
	    int textlen, int startpos, int endpos, cre2_anchor_t anchor,
	    cre2_string_t *match, int nmatch)
{
  re2::StringPiece	text_re2(text, textlen);
  std::vector<re2::StringPiece>	match_re2(nmatch);
  RE2::Anchor		anchor_re2 = to_cre2_anchor(anchor);
  bool			retval; // 0 for no match
				// 1 for successful matching
  retval = TO_CONST_RE2(re)->Match(text_re2, startpos, endpos, anchor_re2, match_re2.data(), nmatch);
  if (retval) {
    for (int i=0; i<nmatch; i++) {
      match[i].data   = match_re2[i].data();
      match[i].length = match_re2[i].length();
    }
  }
  return (retval)? 1 : 0;
}
コード例 #4
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
int
cre2_program_size (const cre2_regexp_t *re)
{
  return TO_CONST_RE2(re)->ProgramSize();
}
コード例 #5
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
int
cre2_num_capturing_groups (const cre2_regexp_t *re)
{
  return TO_CONST_RE2(re)->NumberOfCapturingGroups();
}
コード例 #6
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
const char *
cre2_error_string (const cre2_regexp_t *re)
{
  return TO_CONST_RE2(re)->error().c_str();
}
コード例 #7
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
int
cre2_error_code (const cre2_regexp_t *re)
{
  return int(TO_CONST_RE2(re)->error_code());
}
コード例 #8
0
ファイル: cre2.cpp プロジェクト: mpouttuclarke/cre2
const char *
cre2_pattern (const cre2_regexp_t *re)
{
  return TO_CONST_RE2(re)->pattern().c_str();
}