コード例 #1
0
ファイル: Command.cpp プロジェクト: KingLebron/safmq
	virtual Command* build(int commandID, ServiceThread* service) {
		CommandMap::iterator i = commandsV1.find((SAFMQ_COM_CMD)commandID);
		if (i != commandsV1.end()) {
			return (i->second)(service);
		}
		return NULL;
	}
コード例 #2
0
ファイル: MiscKeyHandler.cpp プロジェクト: ilpropheta/anvedi
bool CursorDependantKeyHandler::onKeyPressed( QShell& shell, QKeyEvent* e )
{
	static CommandMap fns = CreateCursorDependantFunctions();
	auto it = fns.find(e->key());
	if (it != end(fns))
	{
		MoveCursorAtEndIfBadPosition(shell);
		return it->second(shell, e);
	}
	return false;
}
コード例 #3
0
ファイル: gifbxconverter.cpp プロジェクト: Tiriath/GI
CommandMap ParseCommands(int argc, char* argv[]){

	CommandMap parameters;

	int command_index = -1;	//Last command's index
	string key;				//Last command's name
	vector<string> values;	//Last command's values

	//Parameters beginning with a "-" are keys, the rest are values...
	for (int arg_index = 0; arg_index < argc; ++arg_index){

		if (argv[arg_index][0] == kCommandToken){

			// Add a command_index entry inside the parameter map
			key = command_index > -1 ?
				argv[command_index] :
				kGlobalCommand;

			parameters.insert(make_pair(key, values));

			values.clear();

			command_index = arg_index;

		}
		else
		{

			// Add a new value to the previous command
			values.push_back(argv[arg_index]);

		}

	}

	//Add the last values...
	key = command_index > -1 ?
		argv[command_index] :
		kGlobalCommand;

	parameters.insert(make_pair(key, values));

	return parameters;

}
コード例 #4
0
ファイル: MiscKeyHandler.cpp プロジェクト: ilpropheta/anvedi
CommandMap CreateCursorDependantFunctions()
{
	CommandMap fns;
	REGISTER_FUNCTION(Qt::Key_Backspace, [](QShell& shell, QKeyEvent* e){
		if (CursorCanWrite(shell) && (shell.textCursor().hasSelection() || CursorBlockDifference(shell) > 0))
		{
			shell.processKeyEvent(e);
		}
		return true;
	});
	REGISTER_FUNCTION(Qt::Key_Enter, [](QShell& shell, QKeyEvent* e){
		if (e->modifiers().testFlag(Qt::ShiftModifier))
		{
			shell.processKeyEvent(e);
			return true;
		}
		return false;
	});
	fns.insert(make_pair(Qt::Key_Return, fns[Qt::Key_Enter]));

	return fns;
}
コード例 #5
0
ファイル: MiscKeyHandler.cpp プロジェクト: ilpropheta/anvedi
bool MiscKeyHandler::onKeyPressed( QShell& shell, QKeyEvent* e )
{
	static vector<int> specKeys = SpecialKeys();
	static CommandMap fns = CreateCursorIndependantFunctions();
	auto key = e->key();
	
	if (e->matches(QKeySequence::Copy) || e->matches(QKeySequence::Undo) || 
		e->matches(QKeySequence::Redo) || find(begin(specKeys), end(specKeys), key) != end(specKeys))
	{
		shell.processKeyEvent(e);
		return true;
	}

	auto it = fns.find(key);
	if (it != end(fns))
	{
		auto res = it->second(shell, e);
		AcceptEvent(shell, e);
		return res;
	}

	return false;
}
コード例 #6
0
static void ComposeFunctions( const KBData &composition, KBSTATE k )
{
    std::string s = composition.data;
    while ( s.length() ) {
        std::string::size_type where = s.find( " " );
        std::string t = s.substr( 0, where );
        if (where != std::string::npos)
            s = s.substr( where+1 );
        else
            s = "";
        where = t.find( "(" );
        std::string args;
        if (where != string::npos) {
            args = t.substr( where+1 );
            std::string::size_type paren = args.find( ")" );
            if (paren != string::npos)
                args = args.substr( 0, paren );
            t = t.substr( 0, where );
        }
        CommandMap::iterator i = commandMap.find( t );
        if ( i != commandMap.end() )
            (*i).second( args, k );
    }
}
コード例 #7
0
ファイル: gifbxconverter.cpp プロジェクト: Tiriath/GI
void Run(CommandMap & commands){


	FbxScene * scene = nullptr;

	try{

		auto & fbx = FBX::GetInstance();

		// IMPORT
		cout << "Importing..." << std::endl;

		auto input = commands.find(kInputCommand);

		scene = fbx.Import(input->second.front());

		//EXECUTION

		//if (commands.find(kTriangulateCommand) != commands.end()){

		cout << "Triangulating (this could take a couple of minutes)..." << std::endl;

		fbx.Triangulate(*scene);

		//}

		CommandMap::iterator cmd;
	
		if (commands.find(kRemap) != commands.end()){

			cout << "Re-mapping mesh attributes..." << std::endl;

			fbx.RemapAttributes(*scene);

		}
		
		if ((cmd = commands.find(kExtension)) != commands.end()){

			cout << "Normalizing texture paths..." << std::endl;

			fbx.NormalizeTexturePaths(*scene, 
									  input->second.front(),
									  cmd->second.size() <= 0 ? "" : cmd->second.front());

		}

		// EXPORT

		cout << "Exporting to FBX..." << std::endl;

		auto output = commands.find(kOutputCommand);

		fbx.Export(*scene, output->second.front());

		// YAY!

		cout << "Done!" << std::endl;

	}
	catch (std::exception & e){

		//Darn...
		cout << e.what() << std::endl;

	}

	//Cleanup
	if (scene != nullptr){

		scene->Destroy();

	}

}