コード例 #1
0
ファイル: Terminal.cpp プロジェクト: wmarkow/arduino-terminal
AbstractCommand* Terminal::getCommandByName(char* commandName)
{
	for(uint8_t q = 0 ; q < commands->getSize() ; q ++)
	{
		AbstractCommand* command = commands->get(q);
		if(strcmp_P(commandName, (char*)command->getName()) == 0)
		{
			return command;
		}
	}

	return 0;
}
コード例 #2
0
ファイル: Terminal.cpp プロジェクト: wmarkow/arduino-terminal
void Terminal::processHelp()
{
	if(commands->getSize() == 0)
	{
		serial->println(F("No commands available."));
		return;
	}

	for(uint8_t q = 0 ; q < commands->getSize() ; q ++)
	{
		AbstractCommand* command = commands->get(q);
		serial->println(command->getName());
	}
}
コード例 #3
0
ファイル: SyncMLProcessor.cpp プロジェクト: ruphy/kfunambol
/*
* Return the index number of occurrence of this command. If doesn't exists return NULL;
* The first command has number 0.
*/
AbstractCommand* SyncMLProcessor::getCommand(SyncBody* syncBody, const char*commandName, int index) {

    int iterator = 0, found = 0;
    ArrayList* list     = syncBody->getCommands();
    AbstractCommand* a  = NULL;
    const char* name = NULL;
    do {
        a = (AbstractCommand*)getArrayElement(list, iterator);
        if (a) {
            name = a->getName();    // is returned the pointer to the element not a new element
            if (name && strcmp(name, commandName) == 0) {
                if (found == index)
                    break;
                else
                    found++;
            }
        }
        ++iterator;
    } while(a);

    return a;
}