#include "parameter.hpp"
#include <iostream>

void CommandlineParameter::setArgs( int argc, char** argv )
{
    for( int n=1; n<argc; ++n )
    {
        std::string argument( argv[n] );
        m_Arguments.push_back( argument );
    }
}

bool CommandlineParameter::checkToken( std::string token, std::string& param )
{
    for( int n=0; n<(int)m_Arguments.size(); ++n )
    {
        size_t pos = m_Arguments[n].find(token);

        if( pos != std::string::npos )
        {
            param = "";

            pos = m_Arguments[n].find_last_of( "=" );

            if( pos != std::string::npos )
            {
                param = m_Arguments[n].substr( pos + 1 );
            }

            return( true );
        }
    }

    return( false );
}

bool CommandlineParameter::checkToken( std::string token )
{
    std::string dummy;
    return( checkToken( token, dummy ) );
}

