Logo Search packages:      
Sourcecode: apertium version File versions  Download package

string TransferWord::access ( map< char const *, pair< int, int > > &  m,
string &  str,
char const *  part 
) [private]

Accesses the source/target side of a word using the specified part

Parameters:
m tipically s or t
str tipically s_str or t_str
part regular expression to match/access
Returns:
reference to matched/accessed string

Definition at line 40 of file TransferWord.C.

References getRegex().

Referenced by source(), and target().

{
  map<char const *, pair<int, int> >::iterator it = m.find(part);

  if(it == m.end())
  {
    regmatch_t result;
    int errorcode = regexec(&(getRegex(part)), str.c_str(), 1, &result, 0);

    
    if(errorcode != 0)
    {
      m[part] = pair<int, int>(0,0);
      return "";
    }
    else
    {
      m[part] = pair<int, int>(result.rm_so, result.rm_eo);
      return str.substr(result.rm_so, result.rm_eo - result.rm_so);
    }
  }
  else
  {
    return str.substr(it->second.first, it->second.second - it->second.first);
  }
}


Generated by  Doxygen 1.6.0   Back to index