Esempio n. 1
0
str::str(const str& copy)
{
    // Allocate enough memory first
    this->init(copy.getLen());

    // Simply use assignment operator code above
    *this = copy;
}
void CommandProcessor::getHelpText(str& helpForCmd, str& output)
{
    // If there is a parameter, get help for this specific command
    // where this parameter itself is a command name
    if(helpForCmd.getLen() > 0)
    {
        output = CMD_INVALID_STR;
        for(unsigned int i=0; i < mCmdHandlerVector.size(); i++)
        {
            CmdProcessorType &cp = mCmdHandlerVector[i];
            if(helpForCmd.compareToIgnoreCase(cp.pCommandStr))
            {
                output = (0 == cp.pCmdHelpText || '\0' == cp.pCmdHelpText[0]) ? NO_HELP_STR : cp.pCmdHelpText;
                break;
            }
        }
    }
    else {
        getRegisteredCommandList(output);
    }
}
void CommandProcessor::pointToParameters(str& input, const char* pCmdToRemove)
{
    // There may be a space, so need to copy from after the space if it exists
    const int cmdLen = strlen(pCmdToRemove);
    input.eraseFirst( input.getLen() > cmdLen ? cmdLen+1 : cmdLen);
}