41 #if defined(_UNICODE) || defined(UNICODE) 57 HPipe * hStdinWritePipe,
58 HPipe * hStdoutReadPipe,
59 HPipe * hStderrReadPipe = NULL,
60 bool closeStdinIfStdinWritePipeIsNull =
true 76 bool closeStdinIfStdinStrEmpty =
true 88 String const & stdinStr = $T(
""),
90 bool closeStdinIfStdinStrEmpty =
true 117 Mixed const & desiredParams,
118 Mixed const & desiredOptions,
119 Mixed const & desiredFlags,
120 Mixed const & optionSymbols = $T(
"=,:")
142 Mixed const &
getParam(
String const & name,
Mixed const & defValue = $T(
"") )
const {
return this->hasParam(name) ? _params[name] : defValue; }
144 Mixed const &
getOption(
String const & name,
Mixed const & defValue = $T(
"") )
const {
return this->hasOption(name) ? _options[name] : defValue; }
151 size_t getParamIndexInArgv(
String const & name )
const {
return _paramIndexesInArgv.find(name) != _paramIndexesInArgv.end() ? _paramIndexesInArgv.at(name) :
npos; }
153 size_t getOptionIndexInArgv(
String const & name )
const {
return _optionIndexesInArgv.find(name) != _optionIndexesInArgv.end() ? _optionIndexesInArgv.at(name) :
npos; }
155 size_t getFlagIndexInArgv(
String const & name )
const {
return _flagIndexesInArgv.find(name) != _flagIndexesInArgv.end() ? _flagIndexesInArgv.at(name) :
npos; }
157 size_t getValueIndexInArgv(
String const & value )
const {
return _valueIndexesInArgv.find(value) != _valueIndexesInArgv.end() ? _valueIndexesInArgv.at(value) :
npos; }
195 std::map< String, size_t > _paramIndexesInArgv;
197 std::map< String, size_t > _optionIndexesInArgv;
199 std::map< String, size_t > _flagIndexesInArgv;
201 std::map< String, size_t > _valueIndexesInArgv;
211 virtual bool tryLock() = 0;
212 virtual bool lock() = 0;
213 virtual bool unlock() = 0;
242 virtual bool tryLock()
override;
243 virtual bool lock()
override;
244 virtual bool unlock()
override;
257 dllFuncNotFound = 0x00000100,
277 static String GetModulePath(
void * funcInModule );
284 operator bool()
const {
return _hDllModule != NULL; }
285 operator ModuleHandle()
const {
return _hDllModule; }
288 char const * errStr()
const;
291 template <
typename _PfnType >
303 operator bool()
const {
return _pfn != NULL; }
309 void *
get()
const {
return reinterpret_cast<void *
>(_pfn); }
312 template <
typename... _ArgType >
316 return (*_pfn)( std::forward<_ArgType>(arg)... );
324 template <
typename _PfnType >
327 _PfnType pfn = (_PfnType)this->funcAddr(funcName);
334 ModuleHandle _hDllModule;
424 size_t getFileSize()
const;
441 void *
get()
const {
return _p; }
444 template <
typename _Ty >
445 _Ty *
get()
const {
return reinterpret_cast<_Ty *
>(_p); }
448 size_t size()
const {
return _size; }
450 operator bool()
const;
493 bool create(
String const & shmName,
size_t size );
505 void *
get() {
return _data ? _data : this->lock(); }
522 template <
typename _PodType >
535 this->create( shmName, size );
550 _PodType * operator -> () {
return this->
get(); }
555 #endif // __SYSTEM_HPP__ XString< char > AnsiString
bool hasValue(String const &value) const
是否有此值
size_t getParamsCount() const
获取参数个数
XString< wchar > UnicodeString
size_t getValuesCount() const
获取值个数
Mixed & getParams()
获取全部参数
ScopeGuard(ILockObj &lockObj)
winux::tchar const ** getArgv() const
获取argv
Mixed const & getFlag(size_t i) const
获取指定索引的旗标
FuncTraits< PfnType >::ReturnType call(_ArgType &&...arg)
函数调用
size_t getFlagsCount() const
获取旗标个数
Mixed const & getValue(size_t i) const
获取指定索引的值
uint GetPid(void)
获取当前进程ID
bool hasFlag(String const &name) const
是否有此旗标
Function< _PfnType > func(AnsiString const &funcName)
获取指定名字的Function对象,失败抛异常
Mixed & getOptions()
获取全部选项
Mixed const & getParam(String const &name, Mixed const &defValue=$T("")) const
获取指定名字的参数
size_t size() const
获取数据大小
DllLoaderError(int errType, AnsiString const &errStr)
size_t CommandLineToArgvA(AnsiString const &cmd, AnsiStringArray *argv)
#define DISABLE_OBJECT_COPY(clsname)
String GetExec(String const &cmd, String const &stdinStr=$T(""), String *stderrStr=NULL, bool closeStdinIfStdinStrEmpty=true)
执行命令,返回标准输出内容
SharedMemoryT(String const &shmName, size_t size=-1)
构造函数1
String dllModuleFile
DLL模块文件
static constexpr size_t const npos
非位置,值为-1。
HProcess ExecCommandEx(String const &cmd, HPipe *hStdinWritePipe, HPipe *hStdoutReadPipe, HPipe *hStderrReadPipe=NULL, bool closeStdinIfStdinWritePipeIsNull=true)
新建子进程执行指定命令,并用管道重定向了标准设备
XStringArray< char > AnsiStringArray
size_t getOptionsCount() const
获取选项个数
bool create(String const &shmName, size_t size)
创建共享内存
Function(AnsiString const &funcName, PfnType pfn)
SystemError(int errType, AnsiString const &errStr)
bool hasParam(String const &name) const
是否有此参数
size_t getParamIndexInArgv(String const &name) const
获取指定参数在argv中的索引
size_t CommandLineToArgv(AnsiString const &cmd, AnsiStringArray *argv)
把命令行解析成Argv数组。不支持命令行& && | ||
uint GetTid(void)
获取当前线程ID
int ExecCommand(String const &cmd, String const &stdinStr, String *stdoutStr, String *stderrStr=NULL, bool closeStdinIfStdinStrEmpty=true)
新建子进程执行指定命令,等待子进程结束,并把字符串重定向了标准设备
#define WINUX_FUNC_DECL(ret)
void * get()
获取数据指针(自动lock())
int getArgc() const
获取argc
bool hasOption(String const &name) const
是否有此选项
size_t getOptionIndexInArgv(String const &name) const
获取指定选项在argv中的索引
XStringArray< wchar > UnicodeStringArray
size_t getValueIndexInArgv(String const &value) const
获取指定值在argv中的索引
Mixed const & getOption(String const &name, Mixed const &defValue=$T("")) const
获取指定名字的选项
bool create(String const &shmName, size_t size=-1)
创建共享内存
size_t getFlagIndexInArgv(String const &name) const
获取指定旗标在argv中的索引
XStringArray< tchar > StringArray
size_t CommandLineToArgvW(UnicodeString const &cmd, UnicodeStringArray *argv)
void(*)() funcAddr(AnsiString const &funcName)
获取指定名字的函数地址
AnsiString const & getFuncName() const
函数名