class Appl: addArgs function added.

This commit is contained in:
Roland Jax
2014-06-02 22:04:08 +02:00
parent bc7b4d91b0
commit 370cac97fb
6 changed files with 36 additions and 8 deletions
+12 -2
View File
@@ -34,6 +34,12 @@ Appl::~Appl()
m_params.clear();
}
void Appl::addArgs(const std::string argTxt, const int argNum)
{
m_argTxt = argTxt;
m_argNum = argNum;
}
void Appl::addItem(const char* name, Param param, const char* shortname,
const char* longname, const char* description,
Datatype datatype, Optiontype optiontype)
@@ -56,8 +62,12 @@ void Appl::addItem(const char* name, Param param, const char* shortname,
void Appl::printArgs()
{
std::cerr << std::endl << "Usage:" << std::endl << " "
<< m_argv[0].substr(2) << " [Options]" << std::endl
<< std::endl << "Options:" << std::endl;
<< m_argv[0].substr(2) << " [Options]" ;
if (m_argTxt.size() != 0)
std::cerr << " " << m_argTxt;
std::cerr << std::endl << std::endl << "Options:" << std::endl;
for (a_it = m_args.begin(); a_it < m_args.end(); a_it++) {
const char* c = (strlen(a_it->shortname) == 1) ? a_it->shortname : " ";
+6
View File
@@ -61,6 +61,9 @@ public:
~Appl();
void addArgs(const std::string argTxt, const int argNum);
std::string getArg(const int argNum) const { return m_argv[m_argc - 1 - m_argNum + argNum]; }
void addItem(const char* name, Param param, const char* shortname,
const char* longname, const char* description,
Datatype datatype, Optiontype optiontype);
@@ -84,6 +87,9 @@ private:
Optiontype optiontype;
};
std::string m_argTxt;
int m_argNum;
int m_argc;
std::vector<std::string> m_argv;
+1 -1
View File
@@ -67,7 +67,7 @@ TCPSocket* TCPClient::connect(const std::string& server, const int& port)
}
address.sin_family = AF_INET;
address.sin_port = port;
address.sin_port = htons(port);
int sfd = socket(AF_INET, SOCK_STREAM, 0);
if (sfd < 0)