当前位置: 首页>>代码示例>>C++>>正文


C++ f8String::find方法代码示例

本文整理汇总了C++中f8String::find方法的典型用法代码示例。如果您正苦于以下问题:C++ f8String::find方法的具体用法?C++ f8String::find怎么用?C++ f8String::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在f8String的用法示例。


在下文中一共展示了f8String::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: process

//-------------------------------------------------------------------------------------------------
bool Session::process(const f8String& from)
{
	unsigned seqnum(0);

	try
	{
		const f8String::size_type fpos(from.find("34="));
		if (fpos == f8String::npos)
		{
			//cerr << "Session::process throwing for " << from << endl;
			throw InvalidMessage(from);
		}

		seqnum = fast_atoi<unsigned>(from.data() + fpos + 3, default_field_separator);

		bool retry_plog(false);
		if (_plogger && _plogger->has_flag(Logger::inbound))
		{
			if (_state != States::st_wait_for_logon)
				plog(from, 1);
			else
				retry_plog = true;
		}

		const Message *msg(Message::factory(_ctx, from, _loginParameters._no_chksum_flag, _loginParameters._permissive_mode_flag));
		if (!msg)
		{
			GlobalLogger::log("Fatal: factory failed to generate a valid message");
			return false;
		}

		if ((_control & printnohb) && msg->get_msgtype() != Common_MsgType_HEARTBEAT)
			cout << *msg << endl;
		else if (_control & print)
			cout << *msg << endl;

		bool result(false), admin_result(msg->is_admin() ? handle_admin(seqnum, msg) : true);
		if (msg->get_msgtype().size() > 1)
			goto application_call;
		else switch(msg->get_msgtype()[0])
		{
		default:
application_call:
			if (activation_check(seqnum, msg))
				result = handle_application(seqnum, msg);
			break;
		case Common_MsgByte_HEARTBEAT:
			result = handle_heartbeat(seqnum, msg);
			break;
		case Common_MsgByte_TEST_REQUEST:
			result = handle_test_request(seqnum, msg);
			break;
		case Common_MsgByte_RESEND_REQUEST:
			result = handle_resend_request(seqnum, msg);
			break;
		case Common_MsgByte_REJECT:
			result = handle_reject(seqnum, msg);
			break;
		case Common_MsgByte_SEQUENCE_RESET:
			result = handle_sequence_reset(seqnum, msg);
			break;
		case Common_MsgByte_LOGOUT:
			result = handle_logout(seqnum, msg);
			break;
		case Common_MsgByte_LOGON:
			result = handle_logon(seqnum, msg);
			break;
		}

		++_next_receive_seq;
		if (retry_plog)
			plog(from, 1);
		if (_persist)
		{
			f8_scoped_spin_lock guard(_per_spl, _connection->get_pmodel() == pm_coro);
			_persist->put(_next_send_seq, _next_receive_seq);
			//cout << "Persisted:" << _next_send_seq << " and " << _next_receive_seq << endl;
		}
		delete msg;
		return result && admin_result;
	}
	catch (f8Exception& e)
	{
		//cerr << "process:: f8exception" << ' ' << seqnum << ' ' << e.what() << endl;

		log(e.what());
		if (!e.force_logoff())
		{
			send(generate_reject(seqnum, e.what()));
		}
		else
		{
			if (_state == States::st_logon_received && !_loginParameters._silent_disconnect)
			{
				send(generate_logout(e.what()), true, 0, true); // so it won't increment
				do_state_change(States::st_logoff_sent);
			}
			stop();
		}
//.........这里部分代码省略.........
开发者ID:Lezval,项目名称:fix8,代码行数:101,代码来源:session.cpp

示例2: process

//-------------------------------------------------------------------------------------------------
bool Session::process(const f8String& from)
{
	unsigned seqnum(0);

	try
	{
		const f8String::size_type fpos(from.find("34="));
		if (fpos == f8String::npos)
		{
			//cerr << "Session::process throwing for " << from << endl;
			throw InvalidMessage(from);
		}

		seqnum = fast_atoi<unsigned>(from.data() + fpos + 3, default_field_separator);

		bool retry_plog(false);
		if (_plogger && _plogger->has_flag(Logger::inbound))
		{
			if (_state != States::st_wait_for_logon)
				plog(from, 1);
			else
				retry_plog = true;
		}

		scoped_ptr<Message> msg(Message::factory(_ctx, from));
		if (!msg.get())
		{
			GlobalLogger::log("Fatal: factory failed to generate a valid message");
			return false;
		}

		if ((_control & printnohb) && msg->get_msgtype() != Common_MsgType_HEARTBEAT)
			cout << *msg << endl;
		else if (_control & print)
			cout << *msg << endl;
		bool result((msg->is_admin() ? handle_admin(seqnum, msg.get()) : true)
			&& (this->*_handlers.find_ref(msg->get_msgtype()))(seqnum, msg.get()));
		++_next_receive_seq;
		if (retry_plog)
			plog(from, 1);
		if (_persist)
		{
			f8_scoped_spin_lock guard(_per_spl, _connection->get_pmodel() == pm_coro);
			_persist->put(_next_send_seq, _next_receive_seq);
			//cout << "Persisted:" << _next_send_seq << " and " << _next_receive_seq << endl;
		}
		return result;

	}
	catch (f8Exception& e)
	{
		//cerr << "process:: f8exception" << ' ' << seqnum << ' ' << e.what() << endl;

		log(e.what());
		if (!e.force_logoff())
		{
			send(generate_reject(seqnum, e.what()));
		}
		else
		{
			if (_state == States::st_logon_received && !_loginParameters._silent_disconnect)
			{
				send(generate_logout(e.what()), 0, true); // so it won't increment
				_state = States::st_logoff_sent;
			}
			stop();
		}
	}
	catch (Poco::Net::NetException& e)
	{
		//cerr << "process:: Poco::Net::NetException" << endl;
		log(e.what());
	}
	catch (exception& e)
	{
		//cerr << "process:: std::exception" << endl;
		log(e.what());
	}

	return false;
}
开发者ID:vdt,项目名称:fix8,代码行数:82,代码来源:session.cpp


注:本文中的f8String::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。