2014-10-22 15:27:38 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
|
* Copyright (C) 2014 Synergy Si, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
|
*
|
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "base/String.h"
|
|
|
|
|
#include "common/stdvector.h"
|
|
|
|
|
|
2014-10-22 15:35:28 +00:00
|
|
|
class CServerArgs;
|
|
|
|
|
class CClientArgs;
|
|
|
|
|
class CToolArgs;
|
2014-10-22 15:27:38 +00:00
|
|
|
class CArgsBase;
|
2014-10-22 15:35:28 +00:00
|
|
|
class CApp;
|
2014-10-22 15:27:38 +00:00
|
|
|
|
|
|
|
|
class CArgParser {
|
|
|
|
|
|
|
|
|
|
public:
|
2014-10-22 15:35:28 +00:00
|
|
|
CArgParser(CApp* app);
|
|
|
|
|
|
|
|
|
|
bool parseServerArgs(CServerArgs& args, int argc, const char* const* argv);
|
|
|
|
|
bool parseClientArgs(CClientArgs& args, int argc, const char* const* argv);
|
2014-10-22 15:27:38 +00:00
|
|
|
bool parsePlatformArg(CArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
|
2014-10-27 16:39:18 +00:00
|
|
|
bool parseToolArgs(CToolArgs& args, int argc, const char* const* argv);
|
2014-10-22 15:35:28 +00:00
|
|
|
bool parseGenericArgs(int argc, const char* const* argv, int& i);
|
|
|
|
|
void setArgsBase(CArgsBase& argsBase) { m_argsBase = &argsBase; }
|
2014-10-22 15:27:38 +00:00
|
|
|
|
|
|
|
|
static bool isArg(int argi, int argc, const char* const* argv,
|
|
|
|
|
const char* name1, const char* name2,
|
|
|
|
|
int minRequiredParameters = 0);
|
2014-10-22 15:35:28 +00:00
|
|
|
static void splitCommandString(CString& command, std::vector<CString>& argv);
|
|
|
|
|
static bool searchDoubleQuotes(CString& command, size_t& left,
|
|
|
|
|
size_t& right, size_t startPos = 0);
|
|
|
|
|
static void removeDoubleQuotes(CString& arg);
|
|
|
|
|
static const char** getArgv(std::vector<CString>& argsArray);
|
|
|
|
|
static CString assembleCommand(std::vector<CString>& argsArray,
|
|
|
|
|
CString ignoreArg = "", int parametersRequired = 0);
|
|
|
|
|
|
2014-10-22 15:27:38 +00:00
|
|
|
private:
|
2014-10-22 15:35:28 +00:00
|
|
|
void updateCommonArgs(const char* const* argv);
|
|
|
|
|
bool checkUnexpectedArgs();
|
|
|
|
|
|
2014-10-22 15:27:38 +00:00
|
|
|
static CArgsBase& argsBase() { return *m_argsBase; }
|
|
|
|
|
|
|
|
|
|
private:
|
2014-10-22 15:35:28 +00:00
|
|
|
CApp* m_app;
|
|
|
|
|
|
2014-10-22 15:27:38 +00:00
|
|
|
static CArgsBase* m_argsBase;
|
|
|
|
|
};
|