示例#1
0
protocol_strategy_factory<char>::ptr wrap_legacy_protocol(
		const std::string& delimiter, 
		const ProtocolStrategyPtr& strategy)
{
	return spl::make_shared<delimiter_based_chunking_strategy_factory<char>>(
			delimiter,
			spl::make_shared<to_unicode_adapter_factory>(
					strategy->GetCodepage(),
					spl::make_shared<legacy_strategy_adapter_factory>(strategy)));
}
void stateful_protocol_strategy_wrapper::Parse(
	const wchar_t* pData, int charCount, ClientInfoPtr pClientInfo)
{
	purge_dead_clients();

	std::weak_ptr<ClientInfo> weak(pClientInfo);
	ProtocolStrategyPtr strategy;
	auto strategy_iter = strategies_.find(weak);

	if (strategy_iter == strategies_.end())
	{
		strategy = factory_();
		strategies_.insert(std::make_pair(weak, strategy));
	}
	else
	{
		strategy = strategy_iter->second;
	}

	strategy->Parse(pData, charCount, pClientInfo);
}
示例#3
0
	virtual void parse(const std::basic_string<wchar_t>& data)
	{
		auto p = data.c_str();
		strategy_->Parse(p, static_cast<int>(data.length()), client_info_);
	}