update CmdParse code

This commit is contained in:
hyzboy 2019-12-02 11:01:54 +08:00
parent a3ef6866ae
commit 166868f21e
3 changed files with 21 additions and 5 deletions

View File

@ -16,7 +16,8 @@ namespace hgl
public:
CmdParse(const OSStringList &);
virtual ~CmdParse();
CmdParse(const int,os_char **);
virtual ~CmdParse()=default;
int Find(const OSString &)const; ///<查找一个指定字串开头的参数是否存在

View File

@ -9,3 +9,16 @@ option(CM_UTIL_SUPPORT_JSON "Build JSON Parse/make module." ON)
if(CM_UTIL_SUPPORT_JSON)
add_subdirectory(json)
endif(CM_UTIL_SUPPORT_JSON)
SET(CMD_SOURCE ${CMUTIL_ROOT_INCLUDE_PATH}/hgl/util/cmd/CmdParse.h
cmd/CmdParse.cpp)
#SET(TIME_SOURCE ${CMUTIL_ROOT_INCLUDE_PATH}/hgl/util/time/Timer.h
# time/Timer.cpp)
SOURCE_GROUP("Command Line" FILES ${CMD_SOURCE})
#SOURCE_GROUP("Time" FILES ${TIME_SOURCE})
add_cm_library(CMUtil "CM/Util" ${CMD_SOURCE}
# ${TIME_SOURCE}
)

View File

@ -1,5 +1,5 @@
#include<hgl/ut/CmdParse.h>
#include<hgl/Str.h>
#include<hgl/util/cmd/CmdParse.h>
#include<hgl/type/StrChar.h>
namespace hgl
{
@ -10,10 +10,12 @@ namespace hgl
args=_args;
}
CmdParse::~CmdParse()
CmdParse::CmdParse(const int argc,os_char **argv)
{
for(int i=0;i<argc;i++)
args.Add(argv[i]);
}
int CmdParse::Find(const OSString &flag)const
{
return args.Find(flag,flag.Length());