智慧 + 毅力 = 无所不能

正确性、健壮性、可靠性、效率、易用性、可读性、可复用性、兼容性、可移植性...

导航

解析CmdLine参数

Posted on 2015-05-13 16:28  Bill Yuan  阅读(1752)  评论(0编辑  收藏  举报
UBOOL ParseParam( const TCHAR* Stream, const TCHAR* Param, UBOOL bAllowQuoted )
{
    const TCHAR* Start = Stream;
    if( *Stream )
    {
        while( (Start = appStrfind(Start + 1,Param)) != NULL )
        {
            if( Start > Stream && (Start[-1] == '-' || Start[-1] == '/') )
            {
                const TCHAR* End = Start + appStrlen(Param);
                if ( End == NULL || *End == 0 || appIsWhitespace(*End) )
                {
                    return TRUE;
                }

                if( bAllowQuoted )
                {
                    if( Start[-2] == '\"' && *End == '\"' )
                    {
                        return TRUE;
                    }
                }
            }
        }
    }
    return FALSE;
}