From 5431b8f9b47eee386564527fafdae34e1001be9b Mon Sep 17 00:00:00 2001 From: Thunder422 Date: Sun, 9 Dec 2012 08:55:49 -0500 Subject: [PATCH] provide access to version string from command line class renamed version() to isVersionOption() to mirror isHelpOption() added new public version() to provide access to the version string --- commandline.cpp | 16 +++++++++++----- commandline.h | 3 ++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/commandline.cpp b/commandline.cpp index bfac27b..e24deab 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -47,7 +47,7 @@ CommandLine::CommandLine(const QStringList &args) // NOTE: leave m_returnCode set to -1 to start GUI, // parse command line arguments - if (version(args)) + if (isVersionOption(args)) { m_returnCode = 0; return; @@ -116,15 +116,14 @@ void CommandLine::coutClose(void) } -// function to print version number -bool CommandLine::version(const QStringList &args) +// function to check if version option was specified and to process it +bool CommandLine::isVersionOption(const QStringList &args) { if (args.count() != 2 || args.at(1) != "-v") { return false; // not our option or extra/invalid options } - cout() << tr("%1 version %2").arg(m_programName) - .arg(ibcp_RELEASE_STRING + 7) << endl; + cout() << tr("%1 version %2").arg(m_programName).arg(version()) << endl; return true; } @@ -143,4 +142,11 @@ int CommandLine::copyrightYear(void) const } +// function to return the version number string +QString CommandLine::version(void) const +{ + return QString(ibcp_RELEASE_STRING + 7); +} + + // end: commandline.cpp diff --git a/commandline.h b/commandline.h index 116993e..a15f55e 100644 --- a/commandline.h +++ b/commandline.h @@ -33,9 +33,9 @@ class CommandLine { Q_DECLARE_TR_FUNCTIONS(CommandLine) - bool version(const QStringList &args); QTextStream &cout(FILE *stream = stdout); void coutClose(void); + bool isVersionOption(const QStringList &args); bool isHelpOption(const QStringList &args) const; static const char *s_gplStatement[]; @@ -59,6 +59,7 @@ class CommandLine { return m_programName; } + QString version(void) const; int copyrightYear(void) const; static const char **gplStatement(void) {