37 #if defined(_UNICODE) || defined(UNICODE) 53 HPipe * hStdinWritePipe,
54 HPipe * hStdoutReadPipe,
55 HPipe * hStderrReadPipe = NULL,
56 bool closeStdinIfStdinWritePipeIsNull =
true 72 bool closeStdinIfStdinStrEmpty =
true 78 String const & stdinStr =
"",
80 bool closeStdinIfStdinStrEmpty =
true 107 Mixed const & desiredParams,
108 Mixed const & desiredOptions,
109 Mixed const & desiredFlags,
110 Mixed const & optionSymbols =
"=,:" 132 Mixed const &
getParam(
String const & name,
Mixed const & defValue =
"" )
const {
return this->hasParam(name) ? _params[name] : defValue; }
134 Mixed const &
getOption(
String const & name,
Mixed const & defValue =
"" )
const {
return this->hasOption(name) ? _options[name] : defValue; }
141 size_t getParamIndexInArgv(
String const & name )
const {
return _paramIndexesInArgv.find(name) != _paramIndexesInArgv.end() ? _paramIndexesInArgv.at(name) :
npos; }
143 size_t getOptionIndexInArgv(
String const & name )
const {
return _optionIndexesInArgv.find(name) != _optionIndexesInArgv.end() ? _optionIndexesInArgv.at(name) :
npos; }
145 size_t getFlagIndexInArgv(
String const & name )
const {
return _flagIndexesInArgv.find(name) != _flagIndexesInArgv.end() ? _flagIndexesInArgv.at(name) :
npos; }
147 size_t getValueIndexInArgv(
String const & value )
const {
return _valueIndexesInArgv.find(value) != _valueIndexesInArgv.end() ? _valueIndexesInArgv.at(value) :
npos; }
173 char const **
getArgv()
const {
return _argv; }
185 std::map< String, size_t > _paramIndexesInArgv;
187 std::map< String, size_t > _optionIndexesInArgv;
189 std::map< String, size_t > _flagIndexesInArgv;
191 std::map< String, size_t > _valueIndexesInArgv;
201 virtual bool tryLock() = 0;
202 virtual bool lock() = 0;
203 virtual bool unlock() = 0;
230 virtual bool tryLock()
override;
231 virtual bool lock()
override;
232 virtual bool unlock()
override;
244 dllFuncNotFound = 0x00000100,
264 static String GetModulePath(
void * funcInModule );
271 operator bool()
const {
return _hDllModule != NULL; }
272 operator ModuleHandle()
const {
return _hDllModule; }
275 char const * errStr()
const;
278 template <
typename _PfnType >
290 operator bool()
const {
return _pfn != NULL; }
296 void *
get()
const {
return reinterpret_cast<void *
>(_pfn); }
299 template <
typename... _ArgType >
303 return (*_pfn)( std::forward<_ArgType>(arg)... );
311 template <
typename _PfnType >
314 _PfnType pfn = (_PfnType)this->funcAddr(funcName);
320 ModuleHandle _hDllModule;
349 bool create(
int shmKey,
size_t size );
376 template <
typename _PodType >
389 this->create( shmKey, size );
397 bool create(
int shmKey,
size_t size = -1 )
402 _PodType * operator -> ()
404 return reinterpret_cast<_PodType *
>( this->
get() );
410 #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)
Mixed const & getFlag(size_t i) const
获取指定索引的旗标
Mixed const & getParam(String const &name, Mixed const &defValue="") const
获取指定名字的参数
FuncTraits< PfnType >::ReturnType call(_ArgType &&...arg)
函数调用
size_t getFlagsCount() const
获取旗标个数
Mixed const & getValue(size_t i) const
获取指定索引的值
bool hasFlag(String const &name) const
是否有此旗标
Function< _PfnType > func(AnsiString const &funcName)
获取指定名字的Function对象,失败抛异常
Mixed & getOptions()
获取全部选项
String GetExec(String const &cmd, String const &stdinStr="", String *stderrStr=NULL, bool closeStdinIfStdinStrEmpty=true)
执行命令,返回标准输出内容
bool create(int shmKey, size_t size=-1)
创建共享内存
DllLoaderError(int errType, AnsiString const &errStr)
size_t CommandLineToArgvA(AnsiString const &cmd, AnsiStringArray *argv)
Mixed const & getOption(String const &name, Mixed const &defValue="") const
获取指定名字的选项
#define DISABLE_OBJECT_COPY(clsname)
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
获取选项个数
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数组。不支持命令行& && | ||
int ExecCommand(String const &cmd, String const &stdinStr, String *stdoutStr, String *stderrStr=NULL, bool closeStdinIfStdinStrEmpty=true)
新建子进程执行指定命令,等待子进程结束,并把字符串重定向了标准设备
SharedMemoryT(int shmKey, size_t size=-1)
构造函数1
#define WINUX_FUNC_DECL(ret)
bool create(int shmKey, size_t size)
创建共享内存
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中的索引
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
函数名
char const ** getArgv() const
获取argv