Exemple #1
0
void Bot::setAttribute(const StringPimpl &name, 
					   const StringPimpl &value) 
	throw(InternalProgrammerErrorException &)
{
	if(name == "name" && (!value.empty()))
	{
		m_pimpl->m_botPredicateName = value;
	}
}
int DatabaseManager::getRecordTotalCount(const StringPimpl &key)
{
	StringPimpl sizeAsString = getRecord(m_reserved + key + "_@size_@", true);
	if(sizeAsString.empty())
	{
		return 0;
	}
	else
	{
		return sizeAsString.getInteger();
	}
}
Exemple #3
0
void TopicStar::setAttribute(const StringPimpl &name, const StringPimpl &value) throw(InternalProgrammerErrorException &)
{
	try
	{
		if(name == "index" && (!value.empty()))
		{
			m_pimpl->m_index = value.getInteger();
		}
	}
	catch(NumberFormatException &)
	{
		//Error, the cast to a numeric value failed
		FrameworkFactory *factory = FrameworkFactory::getInstance();
		IdentificationManager *ident = IdentificationManager::getInstance();
		GraphBuilderFramework *builder = factory->getGraphBuilderFramework();
		builder->getCallBacks().topicStarTagNumericConversionError("Index string is not numeric, " + value, ident->getUserId(), ident->getBotId(), ident->getEndUserId()); 
	}
}
///@todo redo this without annoying tokenizer.  Use a for loop
void TemplateSideThat::setAttribute(const StringPimpl &name, const StringPimpl &value) throw(InternalProgrammerErrorException &)
{
	if(name == "index" && (!value.empty()))
	{
		string valueString(value.c_str());
		typedef tokenizer<char_separator<char> > tokenize;
		typedef tokenizer<char_separator<char> >::const_iterator CI;
		char_separator<char> sep(",");
		tokenize pathTokens(valueString, sep);
		int i = 0;
		for(CI it = pathTokens.begin(); it != pathTokens.end(); ++it, ++i)
		{
			string s;
			if(i == 0)
			{				
				try
				{
					//This is the first index which is a previous bot response
					s = *it;
					trim(s);
					m_pimpl->m_previousBotResponse = lexical_cast<int>(s);
				}
				catch(bad_lexical_cast &)
				{
					//User Error, the cast to a numeric value failed
					string msg("First index string is not a valid number, ");
					msg += s.c_str();
					FrameworkFactory *factory = FrameworkFactory::getInstance();
					IdentificationManager *ident = IdentificationManager::getInstance();
					GraphBuilderFramework *builder = factory->getGraphBuilderFramework();
					builder->getCallBacks().thatTagNumericConversionError(msg.c_str(), ident->getUserId(), ident->getBotId(), ident->getEndUserId());
				}
			}
			else if(i == 1)
			{			
				try
				{
					//This is the second index which is a sentence
					s = *it;
					trim(s);
					m_pimpl->m_sentence = lexical_cast<int>(s);
				}
				catch(bad_lexical_cast &)
				{
					string msg("Second index string is not a valid number, ");
					msg += s.c_str();
					FrameworkFactory *factory = FrameworkFactory::getInstance();
					IdentificationManager *ident = IdentificationManager::getInstance();
					GraphBuilderFramework *builder = factory->getGraphBuilderFramework();
					builder->getCallBacks().thatTagNumericConversionError(msg.c_str(), ident->getUserId(), ident->getBotId(), ident->getEndUserId());
					//User Error, the cast to a numeric value failed
				}
			}
			else
			{
				//User error, the i index is past 2
				FrameworkFactory *factory = FrameworkFactory::getInstance();
				IdentificationManager *ident = IdentificationManager::getInstance();
				GraphBuilderFramework *builder = factory->getGraphBuilderFramework();
				builder->getCallBacks().thatTagNumericConversionError("The index is past 2", ident->getUserId(), ident->getBotId(), ident->getEndUserId());
			}
		}	
	}
}