GH #48: Need getArgs() accessor

GH #48: Need getArgs() accessor to Util::Application to retrieve
start-up arguments
This commit is contained in:
aleks-f
2013-01-05 15:54:12 -06:00
parent 73a3a5e288
commit 7e8797fb5a
4 changed files with 45 additions and 18 deletions

View File

@@ -105,6 +105,8 @@ class Util_API Application: public Subsystem
/// Unicode command line arguments.
{
public:
typedef std::vector<std::string> ArgVec;
enum ExitCode
/// Commonly used exit status codes.
/// Based on the definitions in the 4.3BSD <sysexits.h> header file.
@@ -168,7 +170,7 @@ public:
/// Unicode command line arguments from wmain().
#endif
void init(const std::vector<std::string>& args);
void init(const ArgVec& args);
/// Processes the application's command line arguments
/// and sets the application's properties (e.g.,
/// "application.path", "application.name", etc.).
@@ -265,6 +267,15 @@ public:
/// "application.logger" configuration property. If that property
/// is not specified, the logger is "Application".
const ArgVec& argv() const;
/// Returns reference to vector of the application's arguments as
/// specified on the command line. If user overrides the
/// Application::main(const ArgVec&) function, it will receive
/// only the command line parameters that were not processed in
/// Application::processOptons(). This function returns the
/// full set of command line parameters as received in
/// main(argc, argv*).
const OptionSet& options() const;
/// Returns the application's option set.
@@ -367,7 +378,7 @@ protected:
private:
void setup();
void setArgs(int argc, char* argv[]);
void setArgs(const std::vector<std::string>& args);
void setArgs(const ArgVec& args);
void getApplicationPath(Poco::Path& path) const;
void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
@@ -375,13 +386,13 @@ private:
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;
typedef std::vector<std::string> ArgVec;
ConfigPtr _pConfig;
SubsystemVec _subsystems;
bool _initialized;
std::string _command;
ArgVec _args;
ArgVec _argv;
ArgVec _unprocessedArgs;
OptionSet _options;
bool _unixOptions;
Poco::Logger* _pLogger;
@@ -435,6 +446,12 @@ inline Poco::Logger& Application::logger() const
}
inline const Application::ArgVec& Application::argv() const
{
return _argv;
}
inline const OptionSet& Application::options() const
{
return _options;