185 lines
3.5 KiB
C++
185 lines
3.5 KiB
C++
#ifndef _CAPSERVER_PARAMS_HPP_
|
|
#define _CAPSERVER_PARAMS_HPP_
|
|
#ifndef _COMMON_BLOCK_HPP_
|
|
#include <common/block.hpp>
|
|
#endif
|
|
#ifndef _CAPSERVER_NAMEVALUE_HPP_
|
|
#include <CapServer/NameValuePair.hpp>
|
|
#endif
|
|
|
|
class Params
|
|
{
|
|
public:
|
|
typedef enum Request{Server,Client,Settings,None};
|
|
Params(int argc,char **argv);
|
|
Params();
|
|
virtual ~Params();
|
|
Request getRequest(void)const;
|
|
String getServer(void)const;
|
|
String getHost(void)const;
|
|
String getPort(void)const;
|
|
String getDevice(void)const;
|
|
bool getRetain(void)const;
|
|
bool getDebug(void)const;
|
|
String getTimeout(void)const;
|
|
bool getShowSrcDlg(void)const;
|
|
void setArgs(int argc,char **argv);
|
|
void showParams(void);
|
|
private:
|
|
int getParams(int argc,char **argv);
|
|
String getValue(const String &key)const;
|
|
void setValue(const String &key,const String &value);
|
|
String getRun(void)const;
|
|
void setServer(const String &server);
|
|
void setHost(const String &host);
|
|
void setPort(const String &port);
|
|
void setDevice(const String &device);
|
|
void setRetain(bool retain);
|
|
void setDebug(bool debug);
|
|
void setTimeout(const String &timeout);
|
|
void setShowSrcDlg(bool showSrcDlg);
|
|
|
|
Block<NameValuePair> mNameValuePairs;
|
|
String mRunKey;
|
|
String mServerKey;
|
|
String mHostKey;
|
|
String mPortKey;
|
|
String mDeviceKey;
|
|
String mRetainKey;
|
|
String mDebugKey;
|
|
String mShowSrcDlgKey;
|
|
String mTimeoutKey;
|
|
};
|
|
|
|
inline
|
|
Params::Params(int argc,char **argv)
|
|
: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"),
|
|
mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg"), mTimeoutKey("timeout")
|
|
{
|
|
getParams(argc,argv);
|
|
}
|
|
|
|
inline
|
|
Params::Params()
|
|
: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"),
|
|
mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg"), mTimeoutKey("timeout")
|
|
{
|
|
}
|
|
|
|
inline
|
|
Params::~Params()
|
|
{
|
|
}
|
|
|
|
inline
|
|
String Params::getRun(void)const
|
|
{
|
|
return getValue(mRunKey);
|
|
}
|
|
|
|
inline
|
|
String Params::getServer(void)const
|
|
{
|
|
return getValue(mServerKey);
|
|
}
|
|
|
|
inline
|
|
String Params::getHost(void)const
|
|
{
|
|
return getValue(mHostKey);
|
|
}
|
|
|
|
inline
|
|
String Params::getPort(void)const
|
|
{
|
|
return getValue(mPortKey);
|
|
}
|
|
|
|
inline
|
|
String Params::getDevice(void)const
|
|
{
|
|
return getValue(mDeviceKey);
|
|
}
|
|
|
|
inline
|
|
bool Params::getRetain(void)const
|
|
{
|
|
String strRetain(getValue(mRetainKey));
|
|
if(strRetain=="true")return true;
|
|
return false;
|
|
}
|
|
|
|
inline
|
|
bool Params::getDebug(void)const
|
|
{
|
|
String strDebug(getValue(mDebugKey));
|
|
if(strDebug=="true")return true;
|
|
return false;
|
|
}
|
|
|
|
inline
|
|
bool Params::getShowSrcDlg(void)const
|
|
{
|
|
String strValue(getValue(mShowSrcDlgKey));
|
|
if(strValue=="true")return true;
|
|
return false;
|
|
}
|
|
|
|
inline
|
|
void Params::setServer(const String &server)
|
|
{
|
|
setValue(mServerKey,server);
|
|
}
|
|
|
|
inline
|
|
void Params::setHost(const String &host)
|
|
{
|
|
setValue(mHostKey,host);
|
|
}
|
|
|
|
inline
|
|
void Params::setPort(const String &port)
|
|
{
|
|
setValue(mPortKey,port);
|
|
}
|
|
|
|
inline
|
|
void Params::setDevice(const String &device)
|
|
{
|
|
setValue(mDeviceKey,device);
|
|
}
|
|
|
|
inline
|
|
void Params::setRetain(bool retain)
|
|
{
|
|
if(retain)setValue(mRetainKey,"true");
|
|
else setValue(mRetainKey,"false");
|
|
}
|
|
|
|
inline
|
|
void Params::setDebug(bool debug)
|
|
{
|
|
if(debug)setValue(mDebugKey,"true");
|
|
else setValue(mDebugKey,"false");
|
|
}
|
|
|
|
inline
|
|
void Params::setShowSrcDlg(bool showSrcDlg)
|
|
{
|
|
if(showSrcDlg)setValue(mShowSrcDlgKey,"true");
|
|
else setValue(mShowSrcDlgKey,"false");
|
|
}
|
|
|
|
inline
|
|
String Params::getTimeout(void)const
|
|
{
|
|
return getValue(mTimeoutKey);
|
|
}
|
|
|
|
inline
|
|
void Params::setTimeout(const String &timeout)
|
|
{
|
|
setValue(mTimeoutKey,timeout);
|
|
}
|
|
#endif
|