当前位置: 首页>>代码示例>>C++>>正文


C++ RE::PartialMatch方法代码示例

本文整理汇总了C++中pcrecpp::RE::PartialMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ RE::PartialMatch方法的具体用法?C++ RE::PartialMatch怎么用?C++ RE::PartialMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pcrecpp::RE的用法示例。


在下文中一共展示了RE::PartialMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shellHistoryAdd

void shellHistoryAdd( const char * line ) {
    if ( line[0] == '\0' )
        return;

    // dont record duplicate lines
    static string lastLine;
    if ( lastLine == line )
        return;
    lastLine = line;

    // We don't want any .auth() or .createUser() shell helpers added, but we want to
    // be able to add things like `.author`, so be smart about how this is
    // detected by using regular expresions. This is so we can avoid storing passwords
    // in the history file in plaintext.
    static pcrecpp::RE hiddenHelpers(
            "\\.\\s*(auth|createUser|updateUser|changeUserPassword)\\s*\\(");
    // Also don't want the raw user management commands to show in the shell when run directly
    // via runCommand.
    static pcrecpp::RE hiddenCommands(
                "(run|admin)Command\\s*\\(\\s*{\\s*(createUser|updateUser)\\s*:");
    if (!hiddenHelpers.PartialMatch(line) && !hiddenCommands.PartialMatch(line))
    {
        linenoiseHistoryAdd( line );
    }
}
开发者ID:Mickael-van-der-Beek,项目名称:mongo,代码行数:25,代码来源:dbshell.cpp

示例2: makeRequestCommand

// static protected
MemcacheCommand MemcacheCommand::makeRequestCommand(u_char* data,
                                                    int length,
                                                    string sourceAddress,
                                                    string destinationAddress)
{
  // set <key> <flags> <exptime> <bytes> [noreply]\r\n
  static string commandName = "set";
  static pcrecpp::RE re(commandName + string(" (\\S+) \\d+ \\d+ (\\d+)"),
                        pcrecpp::RE_Options(PCRE_MULTILINE));
  string key;
  int size = -1;
  string input = "";

  for (int i = 0; i < length; i++) {
    int cid = (int)data[i];
    if (isprint(cid) || cid == 10 || cid == 13) {
      input += static_cast<char>(data[i]);
    }
  }
  if (input.length() < 11) { // set k 0 0 1
    return MemcacheCommand();
  }

  re.PartialMatch(input, &key, &size);
  if (size >= 0) {
    return MemcacheCommand(MC_REQUEST, sourceAddress, destinationAddress, commandName, key, size);
  }
  return MemcacheCommand();
}
开发者ID:douban,项目名称:memkeys,代码行数:30,代码来源:memcache_command.cpp

示例3: shellHistoryAdd

void shellHistoryAdd( const char * line ) {
    if ( line[0] == '\0' )
        return;

    // dont record duplicate lines
    static string lastLine;
    if ( lastLine == line )
        return;
    lastLine = line;

    // We don't want any .auth() or .addUser() commands added, but we want to
    // be able to add things like `.author`, so be smart about how this is
    // detected by using regular expresions.
    static pcrecpp::RE hiddenCommands("\\.(auth|addUser)\\s*\\(");
    if (!hiddenCommands.PartialMatch(line))
    {
        linenoiseHistoryAdd( line );
    }
}
开发者ID:carthagezz,项目名称:mongo,代码行数:19,代码来源:dbshell.cpp

示例4: parseResponse

bool MemcacheCommand::parseResponse(u_char *data, int length)
{
  static pcrecpp::RE re("VALUE (\\S+) \\d+ (\\d+)",
                        pcrecpp::RE_Options(PCRE_MULTILINE));
  bool found_response = false;
  string key;
  int size = -1;
  string input = "";
  for (int i = 0; i < length; i++) {
    int cid = (int)data[i];
    if (isprint(cid) || cid == 10 || cid == 13) {
      input += (char)data[i];
    }
  }
  re.PartialMatch(input, &key, &size);
  if (size >= 0) {
    objectSize = size;
    objectKey = key;
    found_response = true;
  }
  return found_response;
}
开发者ID:burkeen,项目名称:memkeys,代码行数:22,代码来源:memcache_command.cpp

示例5: makeResponseCommand

// static protected
MemcacheCommand MemcacheCommand::makeResponseCommand(u_char *data,
                                                     int length,
                                                     string sourceAddress,
                                                     string destinationAddress)
{
  // VALUE <key> <flags> <bytes> [<cas unique>]\r\n
  static string commandName = "get";
  static pcrecpp::RE re("(VALUE (\\S+) \\d+ (\\d+))",
                        pcrecpp::RE_Options(PCRE_MULTILINE));
  static int minimum_length = 11; // 'VALUE a 0 1'

  string whole;
  string key;
  int size = -1;

  MemcacheCommand mc(MC_RESPONSE, sourceAddress, destinationAddress, commandName);
  int offset = 0;
  while (length - offset >= minimum_length) {
    //Logger::getLogger("command")->debug(CONTEXT, "%.*s", length, data + offset);
    if (!re.PartialMatch(data + offset, &whole, &key, &size)) {
      break;
    }
    //Logger::getLogger("command")->debug(whole);
    //Logger::getLogger("command")->debug(key);
    if (size >= 0) {
      mc.pushObject(key, size);
      offset += whole.length() + 2 + size + 2; // 2 for '\r\n', 2 for '\r\n'
    } else {
      break;
    }
  }

  if (mc.getObjectNumber() > 0) {
    return mc;
  } else {
    return MemcacheCommand();
  }
}
开发者ID:douban,项目名称:memkeys,代码行数:39,代码来源:memcache_command.cpp


注:本文中的pcrecpp::RE::PartialMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。