Esempio n. 1
0
StringPimpl Size::getString() const
	throw(InternalProgrammerErrorException &)
{
	try
	{
		return lexical_cast<String>(m_pimpl->m_builder.getSize()).c_str();
	}
	catch(bad_lexical_cast &)
	{
		logging("Error, Bad lexical cast");
		throw InternalProgrammerErrorExceptionImpl("[StringPimpl Size::getString() const], bad lexical cast");
		return StringPimpl();
	}
}
Esempio n. 2
0
void InnerTemplate::handleInnerTag(const shared_ptr<Tag> &tag) throw(InternalProgrammerErrorException &)
{
	LOG_BOT_METHOD("void InnerTemplate::handleInnerTag(const shared_ptr<Tag> &tag)");

	if(tag->instanceOf("InnerTemplate"))
	{
		shared_ptr<InnerTemplate> it = static_pointer_cast<InnerTemplate>(tag);
		add(it);
	}
	else
	{
		logging("Internal programmer error.  Bad cast, this is not a InnerCategory");
		throw InternalProgrammerErrorExceptionImpl(
			"[void InnerTemplate::handleInnerTag(const shared_ptr<Tag> &tag)], Bad cast, this is not an InnerTemplate"
				                                  );
	}
}
Esempio n. 3
0
void TestCasesHandler::endElement(const XMLCh *const name)
{

	/*
	 * Important note. No error handling needs to take place and match up end tags
	 * with the begining tags.
     *
	 * The reason is that the SAX parser is going to handle all the endElement
	 * Errors.
	 */

	try
	{
		Transcode element(name);
		cout << "</" << element.getString() << ">" << endl;
		const string messageString(element.getChar());

		if(!m_tagStack.empty())
		{
			Tag *tag = m_tagStack.top();
			m_tagStack.pop();

			if(!m_tagStack.empty())
			{
				m_tagStack.top()->handleInnerTag(tag);
				m_currentStartElement = m_tagStack.top();
			}
			else
			{
				cout << "Tag stack empty, not doing anything" << endl;
			}
		}
		else
		{
			cout << "Internal programmer Error the stack is empty" << endl;
			throw InternalProgrammerErrorExceptionImpl("[void ConfigurationHandler::endElement(const XMLCh *const name)] the stack is empty)");
		}
	}	
	catch(nullString &)
	{
		//Do nothing
		cout << "caught nullString on someChars.getChar()" << endl;
	}
}
Esempio n. 4
0
StringPimpl Condition::getString() const
	throw(InternalProgrammerErrorException &)
{
	LOG_BOT_METHOD("StringPimpl Condition::getString() const");
	if(this->isBlockCondition())
	{
		logging("This is a block condition");
		if(m_pimpl->m_builder.predicateMatch(m_pimpl->m_predicateName.c_str(), m_pimpl->m_aimlPattern.c_str()))
		{
			logging("Matched the aimlpattern to the predicate's pattern");
			logging("Returning the string");
			return getStringFromSentence(m_pimpl->m_sentence);
		}
		else
		{
			logging("Did not match the aimlpattern, returning empty string");
			return StringPimpl();
		}
	}
	else 
	{
		logging("This is either a single or multi-predicate condition");		
		
		typedef ListSharedPtrInnerTemplate::const_iterator CI;

		for(CI it = m_pimpl->m_sentence.begin(); it != m_pimpl->m_sentence.end(); ++it) 
		{
			if((*it)->instanceOf("Li"))
			{
				shared_ptr<Li> li = std::static_pointer_cast<Li>(*it);
				StringPimpl liPredicateName = li->getPredicateName();
				StringPimpl liAimlPattern = li->getAimlPattern();

				if(li->isDefaultListItem())
				{
					logging("Encountered default list item.  Returning its string");
					String s = li->getString().c_str();
					trim(s);
					return s.c_str();
				}
				else if(this->isSinglePredicateCondition())
				{
					logging("This is a single Predicate condition");
					if(m_pimpl->m_builder.predicateMatch(m_pimpl->m_predicateName.c_str(), liAimlPattern.c_str()))
					{
						String s = (*it)->getString().c_str();
						trim(s);
						return s.c_str();
					}
				}
				else if(isMutliPredicateCondition())
				{
					logging("This is a multi-predicate condition");
					if(m_pimpl->m_builder.predicateMatch(liPredicateName.c_str(), liAimlPattern.c_str()))
					{
						String s = (*it)->getString().c_str();
						trim(s);
						return s.c_str();
					}
				}
				else
				{
					logging("Inernal programmer Error, the condition block code is corrupted.");
					throw InternalProgrammerErrorExceptionImpl("[StringPimpl Condition::getString()] Condition block code is corrupted.");
					return StringPimpl();
				}
			}
			else if((*it)->instanceOf("PlainWord"))
			{
				//Check for plain word.  If it is a plain word skip to the next
				continue;	
			}
			else
			{
				//Not a plain word, something else.  Throw a bad cast.
				logging("Internal programmer error.  Bad cast, was expecting a Li");
				throw InternalProgrammerErrorExceptionImpl("[StringPimpl Condition::getString() const].  Bad cast, was expecting a Li");
				return StringPimpl();
			}
		}
			
		logging("Nothing matched. Returning empty string");
		return StringPimpl();

	}
}