innertemplateaimltags.h

来自「AIML的实现」· C头文件 代码 · 共 1,701 行 · 第 1/3 页

H
1,701
字号
#ifndef CUSTOMHTML_INNERTEMPLATEAIMLTAGS_H#define CUSTOMHTML_INNERTEMPLATEAIMLTAGS_H/* * RebeccaAIML, Artificial Intelligence Markup Language  * C++ api and engine. * * Copyright (C) 2005 Frank Hassanabad * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA *//* * All AIML innertemplate tags * */#include <rebecca/framework/Gender.h>#include <rebecca/framework/Bot.h>#include <rebecca/framework/Condition.h>#include <rebecca/framework/Date.h>#include <rebecca/framework/Formal.h>#include <rebecca/framework/Gender.h>#include <rebecca/framework/Get.h>#include <rebecca/framework/Gossip.h>#include <rebecca/framework/Id.h>#include <rebecca/framework/Input.h>#include <rebecca/framework/Li.h>#include <rebecca/framework/LowerCase.h>#include <rebecca/framework/Pattern.h>#include <rebecca/framework/Person.h>#include <rebecca/framework/Person2.h>#include <rebecca/framework/Random.h>#include <rebecca/framework/Sentence.h>#include <rebecca/framework/Set.h>#include <rebecca/framework/Size.h>#include <rebecca/framework/Srai.h>#include <rebecca/framework/Star.h>#include <rebecca/framework/System.h>#include <rebecca/framework/TemplateSideThat.h>#include <rebecca/framework/ThatStar.h>#include <rebecca/framework/Think.h>#include <rebecca/framework/TopicStar.h>#include <rebecca/framework/UpperCase.h>#include <rebecca/framework/NonImplemented.h>#include <rebecca/framework/Version.h>#include <rebecca/framework/GraphBuilderFramework.h>#include <string>/* Disable Windows VC 7.x warning about  * it ignoring the throw specification */#ifdef _WIN32#    pragma warning ( push )#    pragma warning( disable : 4290 )#endifnamespace customTag{namespace impl{using namespace rebecca::framework;using namespace std;using namespace boost;/** * The Custom Gender class that overrides * the regular Gender AIML XML Tag */class CustomGender : public Gender{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf() and		 * to set the builder reference		 *		 * \param builder A reference 		 * to the graph builder framework that 		 * can be used to set and get information 		 * from the AIML engine.		 */		CustomGender(GraphBuilderFramework &builder) throw()			: Gender(builder) 		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomGender");		} 		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;gender&gt;");			StringPimpl s = InnerTemplateListImpl::getString();			returnString += s.c_str();			returnString += "&lt;/gender&gt;";			return returnString.c_str();		}};/** * The Custom Bot class that overrides * the regular Bot AIML XML Tag */class CustomBot : public Bot{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf() and		 * to set the builder reference		 *		 * \param builder A reference 		 * to the graph builder framework that 		 * can be used to set and get information 		 * from the AIML engine.		 */		CustomBot(GraphBuilderFramework &builder) throw()			: Bot(builder) 		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomBot");				} 		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;bot name=\"" + m_value + "\"/&gt;");			return returnString.c_str();		}		/**		 * Sets the attribute to a value.		 *		 * This is overriden to gain access to the attribute.		 * 		 * \param name The name of the AIML XML attribute		 *		 * \param value The value of the AIML XML attribute         *		 * \throw Does not throw anything		 */		virtual void setAttribute(const StringPimpl &name, const StringPimpl &value) 			throw(InternalProgrammerErrorException &)		{			m_value = value.c_str();		}	private:		/**		 * Attribute value		 */		string m_value;};/** * The Custom Condition class that overrides * the regular Condition AIML XML Tag */class CustomCondition : public Condition{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf() and		 * to set the builder reference		 *		 * \param builder A reference 		 * to the graph builder framework that 		 * can be used to set and get information 		 * from the AIML engine.		 */		CustomCondition(GraphBuilderFramework &builder) throw()			: Condition(builder) 		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomCondition");				} 				/**		 * Add the tag to the internal data structure		 *		 * \param tag The tag to add		 *		 * \throw Does not throw anything		 */		virtual void add(const shared_ptr<InnerTemplate> &tag) 			throw(InternalProgrammerErrorException &)		{			m_list.add(tag);		}		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;condition");			if(!m_name.empty())			{				returnString += " name=\"" + m_name + "\"";			}						if(!m_value.empty())			{				returnString += " value=\"" + m_value + "\"";			}						returnString += "&gt;";			returnString += m_list.getString().c_str();			returnString += "&lt;/condition&gt";			return returnString.c_str();					}		/**		 * Sets the attribute to a value.		 *		 * This is overriden to gain access to the attribute.		 * 		 * \param name The name of the AIML XML attribute		 *		 * \param value The value of the AIML XML attribute         *		 * \throw Does not throw anything		 */		virtual void setAttribute(const StringPimpl &name, const StringPimpl &value) 			throw(InternalProgrammerErrorException &)		{			string stringName(name.c_str());			string stringValue(value.c_str());						if(stringName == "name")			{				m_name = stringValue;			}			else if(stringName == "value")			{				m_value = stringValue;			}		}	private:		/**		 * Use this for the internal data structure		 * hold values for when add is called on this		 * class		 */		InnerTemplateListImpl m_list;		/**		 * The attribute name		 */		string m_name;		/**		 * The attribute value		 */		string m_value;};/** * The Custom Li class that overrides * the regular Li AIML XML Tag */class CustomLi : public Li{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf()		 */		CustomLi() throw()		{           /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomLi");		}		/**		 * Sets the attribute to a value.		 *		 * This is overriden to gain access to the attribute.		 * 		 * \param name The name of the AIML XML attribute		 *		 * \param value The value of the AIML XML attribute         *		 * \throw Does not throw anything		 */		virtual void setAttribute(const StringPimpl &name, const StringPimpl &value) 			throw(InternalProgrammerErrorException &)		{			string stringName(name.c_str());			string stringValue(value.c_str());						if(stringName == "name")			{				m_name = stringValue;			}			else if(stringName == "value")			{				m_value = stringValue;			}		}		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;li");			if(!m_name.empty())			{				returnString += " name=\"" + m_name + "\"";			}						if(!m_value.empty())			{				returnString += " value=\"" + m_value + "\"";			}						returnString += "&gt;";			returnString += InnerTemplateListImpl::getString().c_str();			returnString += "&lt;/li&gt";			return returnString.c_str();					}	private:		/**		 * Name of the attribute		 */		string m_name;		/**		 * Value of the attribute		 */		string m_value;};/** * The Custom Date class that overrides * the regular Date AIML XML Tag */class CustomDate : public Date{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf()		 */		CustomDate() throw()		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomDate");				} 		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;date/&gt;");			return returnString.c_str();		}};/** * The Custom Formal class that overrides * the regular Formal AIML XML Tag */class CustomFormal : public Formal{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf()		 */		CustomFormal() throw()		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomFormal");				} 		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;formal&gt;");			returnString += InnerTemplateListImpl::getString().c_str();			returnString += "&lt;/formal&gt";			return returnString.c_str();					}};/** * The Custom Gossip class that overrides * the regular Gossip AIML XML Tag */class CustomGossip : public Gossip{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf() and		 * to set the builder reference		 *		 * \param builder A reference 		 * to the graph builder framework that 		 * can be used to set and get information 		 * from the AIML engine.		 */		CustomGossip(GraphBuilderFramework &builder) throw()			: Gossip(builder)		{            /*			* Add the name of this class.  Otherwise if I 			* didn't do this I could not call Tag::instanceOf()			* this an instance of this class and get back a true.			*/			addInstanceOf("CustomGossip");				} 		/**		 * Returns the html string name of		 * the AIML XML name of this class		 * and any AIML XML tags that are 		 * inside of this AIML XML Tag		 *		 * \return the htm string name of the		 * AIML XML Tag and any inner tags		 *		 * \throw Does not throw anything		 */		virtual StringPimpl getString() const			throw(InternalProgrammerErrorException &)		{			string returnString("&lt;gossip&gt;");			returnString += InnerTemplateListImpl::getString().c_str();			returnString += "&lt;/gossip&gt";			return returnString.c_str();					}};/** * The Custom Get class that overrides * the regular Get AIML XML Tag */class CustomGet : public Get{	public:		/**		 * Default constructor to 		 * call Tag::addInstanceOf() and		 * to set the builder reference		 *		 * \param builder A reference 		 * to the graph builder framework that 		 * can be used to set and get information 		 * from the AIML engine.

⌨️ 快捷键说明

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