argv is now stored internally as a std::vector container
This commit is contained in:
parent
4acca85a13
commit
5a6644de98
|
@ -1,3 +1,6 @@
|
||||||
|
2021-03-31 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* argv is now stored internally as a std::vector container
|
||||||
|
|
||||||
2021-03-30 Markus Gans <guru.mail@muenster.de>
|
2021-03-30 Markus Gans <guru.mail@muenster.de>
|
||||||
* Stops terminal refresh during dialog resizing until all
|
* Stops terminal refresh during dialog resizing until all
|
||||||
child widgets have been redrawn
|
child widgets have been redrawn
|
||||||
|
|
|
@ -81,10 +81,9 @@ struct timeval FApplication::time_last_event {};
|
||||||
|
|
||||||
// constructors and destructor
|
// constructors and destructor
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FApplication::FApplication (const int& _argc, char* _argv[])
|
FApplication::FApplication (const int& arg_c, char* arg_v[])
|
||||||
: FWidget{processParameters(_argc, _argv)}
|
: FWidget{processParameters(Args(arg_v, arg_v + arg_c))}
|
||||||
, app_argc{_argc}
|
, app_args{arg_v, arg_v + arg_c}
|
||||||
, app_argv{_argv}
|
|
||||||
{
|
{
|
||||||
if ( quit_now )
|
if ( quit_now )
|
||||||
return;
|
return;
|
||||||
|
@ -101,14 +100,6 @@ FApplication::FApplication (const int& _argc, char* _argv[])
|
||||||
// First define the application object
|
// First define the application object
|
||||||
internal::var::app_object = this;
|
internal::var::app_object = this;
|
||||||
|
|
||||||
if ( ! (_argc && _argv) )
|
|
||||||
{
|
|
||||||
using CString = char*;
|
|
||||||
static std::array<CString, 1> empty{{CString("")}};
|
|
||||||
app_argc = 0;
|
|
||||||
app_argv = empty.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,12 +523,22 @@ inline void FApplication::setCmdOptionsMap (CmdMap& cmd_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::cmdOptions (const int& argc, char* argv[])
|
void FApplication::cmdOptions (const Args& args)
|
||||||
{
|
{
|
||||||
// Interpret the command line options
|
// Interpret the command line options
|
||||||
|
|
||||||
CmdMap cmd_map{};
|
CmdMap cmd_map{};
|
||||||
setCmdOptionsMap(cmd_map);
|
setCmdOptionsMap(cmd_map);
|
||||||
|
auto argc = int(args.size());
|
||||||
|
std::vector<const char*> argv(argc);
|
||||||
|
std::transform ( args.begin()
|
||||||
|
, args.end()
|
||||||
|
, argv.begin()
|
||||||
|
, [] (const std::string& str)
|
||||||
|
{
|
||||||
|
return str.data();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
|
@ -546,7 +547,8 @@ void FApplication::cmdOptions (const int& argc, char* argv[])
|
||||||
std::vector<CmdOption> long_options{};
|
std::vector<CmdOption> long_options{};
|
||||||
setLongOptions(long_options);
|
setLongOptions(long_options);
|
||||||
auto p = reinterpret_cast<const struct option*>(long_options.data());
|
auto p = reinterpret_cast<const struct option*>(long_options.data());
|
||||||
const int opt = getopt_long (argc, argv, "", p, &idx);
|
auto argv_data = const_cast<char**>(argv.data());
|
||||||
|
const int opt = getopt_long (argc, argv_data, "", p, &idx);
|
||||||
|
|
||||||
if ( opt == -1 )
|
if ( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
@ -1228,16 +1230,15 @@ void FApplication::sendWheelEvent ( const FMouseData& md
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
FWidget* FApplication::processParameters (const Args& args)
|
||||||
{
|
{
|
||||||
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
if ( args.size() > 1 && (args[1] == "--help" || args[1] == "-h") )
|
||||||
|| std::strcmp(argv[1], "-h") == 0 ) )
|
|
||||||
{
|
{
|
||||||
showParameterUsage();
|
showParameterUsage();
|
||||||
FApplication::exit(EXIT_SUCCESS);
|
FApplication::exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdOptions (argc, argv);
|
cmdOptions (args);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ class FApplication : public FWidget
|
||||||
public:
|
public:
|
||||||
// Typedef
|
// Typedef
|
||||||
using FLogPtr = std::shared_ptr<FLog>;
|
using FLogPtr = std::shared_ptr<FLog>;
|
||||||
|
using Args = std::vector<std::string>;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FApplication (const int&, char*[]);
|
FApplication (const int&, char*[]);
|
||||||
|
@ -113,8 +114,7 @@ class FApplication : public FWidget
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
FString getClassName() const override;
|
FString getClassName() const override;
|
||||||
int getArgc() const;
|
Args getArgs() const;
|
||||||
char** getArgv() const;
|
|
||||||
static FApplication* getApplicationObject();
|
static FApplication* getApplicationObject();
|
||||||
static FWidget* getKeyboardWidget();
|
static FWidget* getKeyboardWidget();
|
||||||
static FLogPtr& getLog();
|
static FLogPtr& getLog();
|
||||||
|
@ -172,7 +172,7 @@ class FApplication : public FWidget
|
||||||
static void setTerminalEncoding (const FString&);
|
static void setTerminalEncoding (const FString&);
|
||||||
static void setLongOptions(std::vector<CmdOption>&);
|
static void setLongOptions(std::vector<CmdOption>&);
|
||||||
static void setCmdOptionsMap (CmdMap&);
|
static void setCmdOptionsMap (CmdMap&);
|
||||||
static void cmdOptions (const int&, char*[]);
|
static void cmdOptions (const Args&);
|
||||||
static FStartOptions& getStartOptions();
|
static FStartOptions& getStartOptions();
|
||||||
static void showParameterUsage();
|
static void showParameterUsage();
|
||||||
void destroyLog();
|
void destroyLog();
|
||||||
|
@ -221,7 +221,7 @@ class FApplication : public FWidget
|
||||||
void sendWheelEvent ( const FMouseData&
|
void sendWheelEvent ( const FMouseData&
|
||||||
, const FPoint&
|
, const FPoint&
|
||||||
, const FPoint& ) const;
|
, const FPoint& ) const;
|
||||||
static FWidget* processParameters (const int&, char*[]);
|
static FWidget* processParameters (const Args&);
|
||||||
void processResizeEvent() const;
|
void processResizeEvent() const;
|
||||||
void processCloseWidget();
|
void processCloseWidget();
|
||||||
void processLogger() const;
|
void processLogger() const;
|
||||||
|
@ -231,8 +231,7 @@ class FApplication : public FWidget
|
||||||
static bool isNextEventTimeout();
|
static bool isNextEventTimeout();
|
||||||
|
|
||||||
// Data members
|
// Data members
|
||||||
int app_argc{};
|
Args app_args{};
|
||||||
char** app_argv{};
|
|
||||||
uInt64 key_timeout{100000}; // 100 ms
|
uInt64 key_timeout{100000}; // 100 ms
|
||||||
uInt64 dblclick_interval{500000}; // 500 ms
|
uInt64 dblclick_interval{500000}; // 500 ms
|
||||||
std::streambuf* default_clog_rdbuf{std::clog.rdbuf()};
|
std::streambuf* default_clog_rdbuf{std::clog.rdbuf()};
|
||||||
|
@ -258,12 +257,8 @@ inline FString FApplication::getClassName() const
|
||||||
{ return "FApplication"; }
|
{ return "FApplication"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline int FApplication::getArgc() const
|
inline FApplication::Args FApplication::getArgs() const
|
||||||
{ return app_argc; }
|
{ return app_args; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
inline char** FApplication::getArgv() const
|
|
||||||
{ return app_argv; }
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline void FApplication::cb_exitApp (FWidget* w) const
|
inline void FApplication::cb_exitApp (FWidget* w) const
|
||||||
|
|
Loading…
Reference in New Issue