예제 #1
0
bool CommandHolder::IsEqualFirstName(const std::string& cmd_first_name) const {
  DCHECK(count_space(cmd_first_name) == 0) << "Command (" << cmd_first_name << ") should be without spaces.";
  if (white_spaces_count_ == 0) {
    return IsEqualName(cmd_first_name);
  }

  for (size_t i = 0; i < name.size(); ++i) {
    char c = name[i];
    if (std::isspace(c)) {
      return common::FullEqualsASCII(cmd_first_name, name.substr(0, i), false);
    }
  }

  return IsEqualName(cmd_first_name);
}
예제 #2
0
bool CommandHolder::IsCommand(commands_args_t argv, size_t* offset) const {
  if (argv.empty()) {
    return false;
  }

  const size_t uargc = argv.size();
  if (uargc == white_spaces_count_) {
    return false;
  }

  CHECK(uargc > white_spaces_count_);
  std::vector<command_buffer_t> merged;
  for (size_t i = 0; i < white_spaces_count_ + 1; ++i) {
    merged.push_back(argv[i]);
  }

  command_buffer_t ws = common::JoinString(merged, " ");
  if (!IsEqualName(ws)) {
    return false;
  }

  if (offset) {
    *offset = white_spaces_count_ + 1;
  }
  return true;
}
예제 #3
0
파일: XmlTree.cpp 프로젝트: dbremner/WinLib
	Attribute const * Node::FindAttribute (std::string const & name) const 
	{
		ConstAttribIter it = 
				std::find_if (_attributes.begin (),
						      _attributes.end (),
						      IsEqualName (name));
		if (it != _attributes.end ())
		{
			return *it;
		}
		return 0;
	}
예제 #4
0
파일: XmlTree.cpp 프로젝트: dbremner/WinLib
	Node const * Node::FindFirstChildNamed (std::string const & name) const 
	{
		ConstChildIter it = 
				std::find_if (_children.begin (),
						      _children.end (),
						      IsEqualName (name));
		if (it != _children.end ())
		{
			return *it;
		}
		return 0;
	}