Пример #1
0
Connection::Connection(Arguments& args) :
	m_context(nullptr)
{
	wstring arg;

	if (!args.Probe(arg))
		return;

	do
	{
		if (arg == L"/gate")
		{
			args.SwitchToNext();
			if (!args.GetNext(m_deviceName))
				throw WException(ERROR_INVALID_PARAMETER, L"Error, mismatched argument for command 'gate'");

			if (m_deviceName.compare(0, 1, L"\\") != 0)
				m_deviceName.insert(0, L"\\\\.\\");
		}
		else
		{
			break;
		}
	} 
	while (args.Probe(arg));
}
Пример #2
0
CommandTemplatePtr LoadCommandsTemplate(Arguments& args, CommandMode& mode)
{
	wstring templateType;

	if (mode.GetModeType() == CommandModeType::Uninstall)
		return CommandTemplatePtr(new SingleCommand(args, mode.GetModeType()));

	if (!args.Probe(templateType))
		throw WException(ERROR_INVALID_PARAMETER, L"Error, unknown perform mode, please use 'hiddencli /help'");

	if (templateType == L"/multi")
	{
		args.SwitchToNext();
		return CommandTemplatePtr(new MultipleCommands(args, mode.GetModeType()));
	}
	else if (templateType == L"/config")
	{
		args.SwitchToNext();
		return CommandTemplatePtr(new MultipleCommandsFromFile(args, mode.GetModeType()));
	}
	
	return CommandTemplatePtr(new SingleCommand(args, mode.GetModeType()));
}