Permalink
Browse files

Allow retrieving argument list from Util::Application.

  • Loading branch information...
1 parent 4b2fbab commit 5c6cb796e5261e0d8353a506d6093c0e159c34b6 @pprindeville committed Dec 31, 2012
Showing with 16 additions and 7 deletions.
  1. +14 −5 Util/include/Poco/Util/Application.h
  2. +2 −2 Util/include/Poco/Util/ServerApplication.h
@@ -134,6 +134,8 @@ class Util_API Application: public Subsystem
PRIO_SYSTEM = 100
};
+ typedef std::vector<std::string> ArgVec;
+
Application();
/// Creates the Application.
@@ -168,7 +170,7 @@ class Util_API Application: public Subsystem
/// 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.).
@@ -336,7 +338,7 @@ class Util_API Application: public Subsystem
void setLogger(Poco::Logger& logger);
/// Sets the logger used by the application.
- virtual int main(const std::vector<std::string>& args);
+ virtual int main(const ArgVec& args);
/// The application's main logic.
///
/// Unprocessed command line arguments are passed in args.
@@ -361,21 +363,22 @@ class Util_API Application: public Subsystem
void init();
/// Common initialization code.
+ const ArgVec& getArgs() const;
+
~Application();
/// Destroys the Application and deletes all registered subsystems.
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;
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;
@@ -463,6 +466,12 @@ inline Poco::Timespan Application::uptime() const
}
+inline const Application::ArgVec& Application::getArgs() const
+{
+ return _args;
+}
+
+
} } // namespace Poco::Util
@@ -489,7 +498,7 @@ inline Poco::Timespan Application::uptime() const
#define POCO_APP_MAIN(App) \
int pocoAppMain(const char* appName, ...) \
{ \
- std::vector<std::string> args; \
+ ArgVec args; \
args.push_back(std::string(appName)); \
va_list vargs; \
va_start(vargs, appName); \
@@ -162,7 +162,7 @@ class Util_API ServerApplication: public Application
/// Runs the application by performing additional initializations
/// and calling the main() method.
- int run(const std::vector<std::string>& args);
+ int run(const ArgVec& args);
/// Runs the application by performing additional initializations
/// and calling the main() method.
@@ -265,7 +265,7 @@ class Util_API ServerApplication: public Application
#define POCO_SERVER_MAIN(App) \
int pocoSrvMain(const char* appName, ...) \
{ \
- std::vector<std::string> args; \
+ ArgVec args; \
args.push_back(std::string(appName)); \
va_list vargs; \
va_start(vargs, appName); \

0 comments on commit 5c6cb79

Please sign in to comment.