personprocessor.h

来自「J-Alice是一个用C++实现的Ailcebot的克隆。它可以做为一个mini」· C头文件 代码 · 共 96 行

H
96
字号
/**
 * PersonProcessor - Retrieves the bot's name (shortcut)
 *
 * @author	Jonathan Roewen
 */
#ifndef PERSON_PROCESSOR_H
#define PERSON_PROCESSOR_H

#include "AimlProcessor.h"
#include "Substituter.h"
#include "Kernel.h"

#include <string>

using namespace std;

class PersonProcessor : public AimlProcessor
{
public:
	~PersonProcessor() { }
	
	string getName() const {
		return "person";
	}
	string getVersion() const {
		return "1.0";
	}
	string process(Match *m, PElement e, Responder *r, const string &id) {
		string result = "";
		string index = e->getAttribute("index");
		if (index.empty()) {
			index = "1";
		}
		if (e->hasChildren()) {
			result = Kernel::process(m, e, r, id);
		} else {
			result = m->getInputStar(index[0] - '0');
		}
		return Substituter::person(result);
	}
};

class Person2Processor : public AimlProcessor
{
public:
	~Person2Processor() { }
	
	string getName() const {
		return "person2";
	}
	string getVersion() const {
		return "1.0";
	}
	string process(Match *m, PElement e, Responder *r, const string &id) {
		string result = "";
		string index = e->getAttribute("index");
		if (index.empty()) {
			index = "1";
		}
		if (e->hasChildren()) {
			result = Kernel::process(m, e, r, id);
		} else {
			result = m->getInputStar(index[0] - '0');
		}
		return Substituter::substitute(result, "person2");
	}
};

class GenderProcessor : public AimlProcessor
{
public:
	~GenderProcessor() { }
	
	string getName() const {
		return "gender";
	}
	string getVersion() const {
		return "1.0";
	}
	string process(Match *m, PElement e, Responder *r, const string &id) {
		string result = "";
		string index = e->getAttribute("index");
		if (index.empty()) {
			index = "1";
		}
		if (e->hasChildren()) {
			result = Kernel::process(m, e, r, id);
		} else {
			result = m->getInputStar(index[0] - '0');
		}
		return Substituter::substitute(result, "gender");
	}
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?