mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-09-18 18:27:18 +02:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
393
vendor/POCO/Util/include/Poco/Util/AbstractConfiguration.h
vendored
Normal file
393
vendor/POCO/Util/include/Poco/Util/AbstractConfiguration.h
vendored
Normal file
@@ -0,0 +1,393 @@
|
||||
//
|
||||
// AbstractConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: AbstractConfiguration
|
||||
//
|
||||
// Definition of the AbstractConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_AbstractConfiguration_INCLUDED
|
||||
#define Util_AbstractConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/BasicEvent.h"
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API AbstractConfiguration: public Poco::RefCountedObject
|
||||
/// AbstractConfiguration is an abstract base class for different
|
||||
/// kinds of configuration data, such as INI files, property files,
|
||||
/// XML configuration files or the Windows Registry.
|
||||
///
|
||||
/// Configuration property keys have a hierarchical format, consisting
|
||||
/// of names separated by periods. The exact interpretation of key names
|
||||
/// is up to the actual subclass implementation of AbstractConfiguration.
|
||||
/// Keys are case sensitive.
|
||||
///
|
||||
/// All public methods are synchronized, so the class is safe for multithreaded use.
|
||||
/// AbstractConfiguration implements reference counting based garbage collection.
|
||||
///
|
||||
/// Subclasses must override the getRaw(), setRaw() and enumerate() methods.
|
||||
{
|
||||
public:
|
||||
using Keys = std::vector<std::string>;
|
||||
using Ptr = AutoPtr<AbstractConfiguration>;
|
||||
|
||||
class KeyValue
|
||||
/// A key-value pair, used as event argument.
|
||||
{
|
||||
public:
|
||||
KeyValue(const std::string& key, std::string& value):
|
||||
_key(key),
|
||||
_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& key() const
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
const std::string& value() const
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
std::string& value()
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string& _key;
|
||||
std::string& _value;
|
||||
};
|
||||
|
||||
Poco::BasicEvent<KeyValue> propertyChanging;
|
||||
/// Fired before a property value is changed or
|
||||
/// a new property is created.
|
||||
///
|
||||
/// Can be used to check or fix a property value,
|
||||
/// or to cancel the change by throwing an exception.
|
||||
///
|
||||
/// The event delegate can use one of the get...() functions
|
||||
/// to obtain the current property value.
|
||||
|
||||
Poco::BasicEvent<const KeyValue> propertyChanged;
|
||||
/// Fired after a property value has been changed
|
||||
/// or a property has been created.
|
||||
|
||||
Poco::BasicEvent<const std::string> propertyRemoving;
|
||||
/// Fired before a property is removed by a
|
||||
/// call to remove().
|
||||
///
|
||||
/// Note: This will even be fired if the key
|
||||
/// does not exist and the remove operation will
|
||||
/// fail with an exception.
|
||||
|
||||
Poco::BasicEvent<const std::string> propertyRemoved;
|
||||
/// Fired after a property has been removed by
|
||||
/// a call to remove().
|
||||
|
||||
AbstractConfiguration();
|
||||
/// Creates the AbstractConfiguration.
|
||||
|
||||
bool hasProperty(const std::string& key) const;
|
||||
/// Returns true iff the property with the given key exists.
|
||||
|
||||
bool hasOption(const std::string& key) const;
|
||||
/// Returns true iff the property with the given key exists.
|
||||
///
|
||||
/// Same as hasProperty().
|
||||
|
||||
bool has(const std::string& key) const;
|
||||
/// Returns true iff the property with the given key exists.
|
||||
///
|
||||
/// Same as hasProperty().
|
||||
|
||||
std::string getString(const std::string& key) const;
|
||||
/// Returns the string value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
std::string getString(const std::string& key, const std::string& defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's string value,
|
||||
/// otherwise returns the given default value.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
std::string getRawString(const std::string& key) const;
|
||||
/// Returns the raw string value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// References to other properties are not expanded.
|
||||
|
||||
std::string getRawString(const std::string& key, const std::string& defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's raw string value,
|
||||
/// otherwise returns the given default value.
|
||||
/// References to other properties are not expanded.
|
||||
|
||||
int getInt(const std::string& key) const;
|
||||
/// Returns the int value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an int.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
unsigned int getUInt(const std::string& key) const;
|
||||
/// Returns the unsigned int value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an unsigned int.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
int getInt(const std::string& key, int defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's int value,
|
||||
/// otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an int.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
unsigned int getUInt(const std::string& key, unsigned int defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's unsigned int
|
||||
/// value, otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an unsigned int.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
Int64 getInt64(const std::string& key) const;
|
||||
/// Returns the Int64 value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an Int64.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
UInt64 getUInt64(const std::string& key) const;
|
||||
/// Returns the UInt64 value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an UInt64.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
Int64 getInt64(const std::string& key, Int64 defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's Int64 value,
|
||||
/// otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an Int64.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
UInt64 getUInt64(const std::string& key, UInt64 defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's UInt64
|
||||
/// value, otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an UInt64.
|
||||
/// Numbers starting with 0x are treated as hexadecimal.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64)
|
||||
|
||||
double getDouble(const std::string& key) const;
|
||||
/// Returns the double value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to a double.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
double getDouble(const std::string& key, double defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's double value,
|
||||
/// otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to an double.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
bool getBool(const std::string& key) const;
|
||||
/// Returns the boolean value of the property with the given name.
|
||||
/// Throws a NotFoundException if the key does not exist.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to a boolean.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
bool getBool(const std::string& key, bool defaultValue) const;
|
||||
/// If a property with the given key exists, returns the property's boolean value,
|
||||
/// otherwise returns the given default value.
|
||||
/// Throws a SyntaxException if the property can not be converted
|
||||
/// to a boolean.
|
||||
/// The following string values can be converted into a boolean:
|
||||
/// - numerical values: non zero becomes true, zero becomes false
|
||||
/// - strings: true, yes, on become true, false, no, off become false
|
||||
/// Case does not matter.
|
||||
/// If the value contains references to other properties (${<property>}), these
|
||||
/// are expanded.
|
||||
|
||||
virtual void setString(const std::string& key, const std::string& value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
virtual void setInt(const std::string& key, int value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
virtual void setUInt(const std::string& key, unsigned int value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
virtual void setInt64(const std::string& key, Int64 value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
virtual void setUInt64(const std::string& key, UInt64 value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64)
|
||||
|
||||
virtual void setDouble(const std::string& key, double value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
virtual void setBool(const std::string& key, bool value);
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
|
||||
void keys(Keys& range) const;
|
||||
/// Returns in range the names of all keys at root level.
|
||||
|
||||
void keys(const std::string& key, Keys& range) const;
|
||||
/// Returns in range the names of all subkeys under the given key.
|
||||
/// If an empty key is passed, all root level keys are returned.
|
||||
|
||||
const Ptr createView(const std::string& prefix) const;
|
||||
/// Creates a non-mutable view (see ConfigurationView) into the configuration.
|
||||
|
||||
Ptr createView(const std::string& prefix);
|
||||
/// Creates a view (see ConfigurationView) into the configuration.
|
||||
|
||||
std::string expand(const std::string& value) const;
|
||||
/// Replaces all occurrences of ${<property>} in value with the
|
||||
/// value of the <property>. If <property> does not exist,
|
||||
/// nothing is changed.
|
||||
///
|
||||
/// If a circular property reference is detected, a
|
||||
/// CircularReferenceException will be thrown.
|
||||
|
||||
void remove(const std::string& key);
|
||||
/// Removes the property with the given key.
|
||||
///
|
||||
/// Does nothing if the key does not exist.
|
||||
|
||||
void enableEvents(bool enable = true);
|
||||
/// Enables (or disables) events.
|
||||
|
||||
bool eventsEnabled() const;
|
||||
/// Returns true iff events are enabled.
|
||||
|
||||
protected:
|
||||
virtual bool getRaw(const std::string& key, std::string& value) const = 0;
|
||||
/// If the property with the given key exists, stores the property's value
|
||||
/// in value and returns true. Otherwise, returns false.
|
||||
///
|
||||
/// Must be overridden by subclasses.
|
||||
|
||||
virtual void setRaw(const std::string& key, const std::string& value) = 0;
|
||||
/// Sets the property with the given key to the given value.
|
||||
/// An already existing value for the key is overwritten.
|
||||
///
|
||||
/// Must be overridden by subclasses.
|
||||
|
||||
virtual void enumerate(const std::string& key, Keys& range) const = 0;
|
||||
/// Returns in range the names of all subkeys under the given key.
|
||||
/// If an empty key is passed, all root level keys are returned.
|
||||
|
||||
virtual void removeRaw(const std::string& key);
|
||||
/// Removes the property with the given key.
|
||||
///
|
||||
/// Does nothing if the key does not exist.
|
||||
///
|
||||
/// Should be overridden by subclasses; the default
|
||||
/// implementation throws a Poco::NotImplementedException.
|
||||
|
||||
static int parseInt(const std::string& value);
|
||||
/// Returns string as signed integer.
|
||||
/// Decimal and hexadecimal notation is supported.
|
||||
|
||||
static unsigned parseUInt(const std::string& value);
|
||||
/// Returns string as unsigned integer.
|
||||
/// Decimal and hexadecimal notation is supported.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
static Int64 parseInt64(const std::string& value);
|
||||
/// Returns string as 64-bit signed integer.
|
||||
/// Decimal and hexadecimal notation is supported.
|
||||
|
||||
static UInt64 parseUInt64(const std::string& value);
|
||||
/// Returns string as 64-bit unsigned integer.
|
||||
/// Decimal and hexadecimal notation is supported.
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64)
|
||||
|
||||
static bool parseBool(const std::string& value);
|
||||
void setRawWithEvent(const std::string& key, std::string value);
|
||||
|
||||
virtual ~AbstractConfiguration();
|
||||
|
||||
private:
|
||||
std::string internalExpand(const std::string& value) const;
|
||||
std::string uncheckedExpand(const std::string& value) const;
|
||||
|
||||
AbstractConfiguration(const AbstractConfiguration&);
|
||||
AbstractConfiguration& operator = (const AbstractConfiguration&);
|
||||
|
||||
mutable int _depth;
|
||||
bool _eventsEnabled;
|
||||
mutable Poco::Mutex _mutex;
|
||||
|
||||
friend class LayeredConfiguration;
|
||||
friend class ConfigurationView;
|
||||
friend class ConfigurationMapper;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_AbstractConfiguration_INCLUDED
|
554
vendor/POCO/Util/include/Poco/Util/Application.h
vendored
Normal file
554
vendor/POCO/Util/include/Poco/Util/Application.h
vendored
Normal file
@@ -0,0 +1,554 @@
|
||||
//
|
||||
// Application.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
// Module: Application
|
||||
//
|
||||
// Definition of the Application class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Application_INCLUDED
|
||||
#define Util_Application_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Subsystem.h"
|
||||
#include "Poco/Util/LayeredConfiguration.h"
|
||||
#include "Poco/Util/OptionSet.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/Logger.h"
|
||||
#include "Poco/Path.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
#include "Poco/Timespan.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#if defined(POCO_VXWORKS)
|
||||
#include <cstdarg>
|
||||
#endif
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class OptionSet;
|
||||
|
||||
|
||||
class Util_API Application: public Subsystem
|
||||
/// The Application class implements the main subsystem
|
||||
/// in a process. The application class is responsible for
|
||||
/// initializing all its subsystems.
|
||||
///
|
||||
/// Subclasses can and should override the following virtual methods:
|
||||
/// - initialize() (the one-argument, protected variant)
|
||||
/// - uninitialize()
|
||||
/// - reinitialize()
|
||||
/// - defineOptions()
|
||||
/// - handleOption()
|
||||
/// - main()
|
||||
///
|
||||
/// The application's main logic should be implemented in
|
||||
/// the main() method.
|
||||
///
|
||||
/// There may be at most one instance of the Application class
|
||||
/// in a process.
|
||||
///
|
||||
/// The Application class maintains a LayeredConfiguration (available
|
||||
/// via the config() member function) consisting of:
|
||||
/// - a MapConfiguration (priority -100) storing application-specific
|
||||
/// properties, as well as properties from bound command line arguments.
|
||||
/// - a SystemConfiguration (priority 100)
|
||||
/// - the configurations loaded with loadConfiguration().
|
||||
///
|
||||
/// The Application class sets a few default properties in
|
||||
/// its configuration. These are:
|
||||
/// - application.path: the absolute path to application executable
|
||||
/// - application.name: the file name of the application executable
|
||||
/// - application.baseName: the file name (excluding extension) of the application executable
|
||||
/// - application.dir: the path to the directory where the application executable resides
|
||||
/// - application.configDir: the path to the directory where user specific configuration files of the application should be stored.
|
||||
/// - application.cacheDir: the path to the directory where user specific non-essential data files of the application should be stored.
|
||||
/// - application.dataDir: the path to the directory where user specific data files of the application should be stored.
|
||||
/// - application.tempDir: the path to the directory where user specific temporary files and other file objects of the application should be stored.
|
||||
///
|
||||
/// If loadConfiguration() has never been called, application.configDir will be equal to application.dir.
|
||||
///
|
||||
/// The POCO_APP_MAIN macro can be used to implement main(argc, argv).
|
||||
/// POCO_APP_MAIN supports Unicode command line arguments.
|
||||
{
|
||||
public:
|
||||
using ArgVec = std::vector<std::string>;
|
||||
using SubsystemPtr = Poco::AutoPtr<Subsystem>;
|
||||
using SubsystemVec = std::vector<SubsystemPtr>;
|
||||
|
||||
enum ExitCode
|
||||
/// Commonly used exit status codes.
|
||||
/// Based on the definitions in the 4.3BSD <sysexits.h> header file.
|
||||
{
|
||||
EXIT_OK = 0, /// successful termination
|
||||
EXIT_USAGE = 64, /// command line usage error
|
||||
EXIT_DATAERR = 65, /// data format error
|
||||
EXIT_NOINPUT = 66, /// cannot open input
|
||||
EXIT_NOUSER = 67, /// addressee unknown
|
||||
EXIT_NOHOST = 68, /// host name unknown
|
||||
EXIT_UNAVAILABLE = 69, /// service unavailable
|
||||
EXIT_SOFTWARE = 70, /// internal software error
|
||||
EXIT_OSERR = 71, /// system error (e.g., can't fork)
|
||||
EXIT_OSFILE = 72, /// critical OS file missing
|
||||
EXIT_CANTCREAT = 73, /// can't create (user) output file
|
||||
EXIT_IOERR = 74, /// input/output error
|
||||
EXIT_TEMPFAIL = 75, /// temp failure; user is invited to retry
|
||||
EXIT_PROTOCOL = 76, /// remote error in protocol
|
||||
EXIT_NOPERM = 77, /// permission denied
|
||||
EXIT_CONFIG = 78 /// configuration error
|
||||
};
|
||||
|
||||
enum ConfigPriority
|
||||
{
|
||||
PRIO_APPLICATION = -100,
|
||||
PRIO_DEFAULT = 0,
|
||||
PRIO_SYSTEM = 100
|
||||
};
|
||||
|
||||
Application();
|
||||
/// Creates the Application.
|
||||
|
||||
Application(int argc, char* argv[]);
|
||||
/// Creates the Application and calls init(argc, argv).
|
||||
|
||||
void addSubsystem(Subsystem* pSubsystem);
|
||||
/// Adds a new subsystem to the application. The
|
||||
/// application immediately takes ownership of it, so that a
|
||||
/// call in the form
|
||||
/// Application::instance().addSubsystem(new MySubsystem);
|
||||
/// is okay.
|
||||
|
||||
void init(int argc, char* argv[]);
|
||||
/// Processes the application's command line arguments
|
||||
/// and sets the application's properties (e.g.,
|
||||
/// "application.path", "application.name", etc.).
|
||||
///
|
||||
/// Note that as of release 1.3.7, init() no longer
|
||||
/// calls initialize(). This is now called from run().
|
||||
|
||||
#if defined(_WIN32)
|
||||
void init(int argc, wchar_t* argv[]);
|
||||
/// Processes the application's command line arguments
|
||||
/// and sets the application's properties (e.g.,
|
||||
/// "application.path", "application.name", etc.).
|
||||
///
|
||||
/// Note that as of release 1.3.7, init() no longer
|
||||
/// calls initialize(). This is now called from run().
|
||||
///
|
||||
/// This Windows-specific version of init is used for passing
|
||||
/// Unicode command line arguments from wmain().
|
||||
#endif
|
||||
|
||||
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.).
|
||||
///
|
||||
/// Note that as of release 1.3.7, init() no longer
|
||||
/// calls initialize(). This is now called from run().
|
||||
|
||||
bool initialized() const;
|
||||
/// Returns true iff the application is in initialized state
|
||||
/// (that means, has been initialized but not yet uninitialized).
|
||||
|
||||
void setUnixOptions(bool flag);
|
||||
/// Specify whether command line option handling is Unix-style
|
||||
/// (flag == true; default) or Windows/OpenVMS-style (flag == false).
|
||||
///
|
||||
/// This member function should be called from the constructor of
|
||||
/// a subclass to be effective.
|
||||
|
||||
int loadConfiguration(int priority = PRIO_DEFAULT);
|
||||
/// Loads configuration information from a default location.
|
||||
///
|
||||
/// The configuration(s) will be added to the application's
|
||||
/// LayeredConfiguration with the given priority.
|
||||
///
|
||||
/// The configuration file(s) must be located in the same directory
|
||||
/// as the executable or a parent directory of it, and must have the
|
||||
/// same base name as the executable, with one of the following extensions:
|
||||
/// .properties, .ini or .xml.
|
||||
///
|
||||
/// The .properties file, if it exists, is loaded first, followed
|
||||
/// by the .ini file and the .xml file.
|
||||
///
|
||||
/// If the application is built in debug mode (the _DEBUG preprocessor
|
||||
/// macro is defined) and the base name of the application executable
|
||||
/// ends with a 'd', a config file without the 'd' ending its base name is
|
||||
/// also found.
|
||||
///
|
||||
/// Example: Given the application "SampleAppd.exe", built in debug mode.
|
||||
/// Then loadConfiguration() will automatically find a configuration file
|
||||
/// named "SampleApp.properties" if it exists and if "SampleAppd.properties"
|
||||
/// cannot be found.
|
||||
///
|
||||
/// Returns the number of configuration files loaded, which may be zero.
|
||||
///
|
||||
/// This method must not be called before init(argc, argv)
|
||||
/// has been called.
|
||||
|
||||
void loadConfiguration(const std::string& path, int priority = PRIO_DEFAULT);
|
||||
/// Loads configuration information from the file specified by
|
||||
/// the given path. The file type is determined by the file
|
||||
/// extension. The following extensions are supported:
|
||||
/// - .properties - properties file (PropertyFileConfiguration)
|
||||
/// - .ini - initialization file (IniFileConfiguration)
|
||||
/// - .xml - XML file (XMLConfiguration)
|
||||
///
|
||||
/// Extensions are not case sensitive.
|
||||
///
|
||||
/// The configuration will be added to the application's
|
||||
/// LayeredConfiguration with the given priority.
|
||||
|
||||
template <class C> C& getSubsystem() const;
|
||||
/// Returns a reference to the subsystem of the class
|
||||
/// given as template argument.
|
||||
///
|
||||
/// Throws a NotFoundException if such a subsystem has
|
||||
/// not been registered.
|
||||
|
||||
SubsystemVec& subsystems();
|
||||
/// Returns a reference to the subsystem list
|
||||
|
||||
virtual int run();
|
||||
/// Runs the application by performing additional (un)initializations
|
||||
/// and calling the main() method.
|
||||
///
|
||||
/// First calls initialize(), then calls main(), and
|
||||
/// finally calls uninitialize(). The latter will be called
|
||||
/// even if main() throws an exception. If initialize() throws
|
||||
/// an exception, main() will not be called and the exception
|
||||
/// will be propagated to the caller. If uninitialize() throws
|
||||
/// an exception, the exception will be propagated to the caller.
|
||||
|
||||
std::string commandName() const;
|
||||
/// Returns the command name used to invoke the application.
|
||||
|
||||
std::string commandPath() const;
|
||||
/// Returns the full command path used to invoke the application.
|
||||
|
||||
LayeredConfiguration& config() const;
|
||||
/// Returns the application's configuration reference.
|
||||
|
||||
LayeredConfiguration::Ptr configPtr() const;
|
||||
/// Returns the application's configuration smart pointer.
|
||||
|
||||
Poco::Logger& logger() const;
|
||||
/// Returns the application's logger.
|
||||
///
|
||||
/// Before the logging subsystem has been initialized, the
|
||||
/// application's logger is "ApplicationStartup", which is
|
||||
/// connected to a ConsoleChannel.
|
||||
///
|
||||
/// After the logging subsystem has been initialized, which
|
||||
/// usually happens as the first action in Application::initialize(),
|
||||
/// the application's logger is the one specified by the
|
||||
/// "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.
|
||||
|
||||
static Application& instance();
|
||||
/// Returns a reference to the Application singleton.
|
||||
///
|
||||
/// Throws a NullPointerException if no Application instance exists.
|
||||
|
||||
const Poco::Timestamp& startTime() const;
|
||||
/// Returns the application start time (UTC).
|
||||
|
||||
Poco::Timespan uptime() const;
|
||||
/// Returns the application uptime.
|
||||
|
||||
void stopOptionsProcessing();
|
||||
/// If called from an option callback, stops all further
|
||||
/// options processing.
|
||||
///
|
||||
/// If called, the following options on the command line
|
||||
/// will not be processed, and required options will not
|
||||
/// be checked.
|
||||
///
|
||||
/// This is useful, for example, if an option for displaying
|
||||
/// help information has been encountered and no other things
|
||||
/// besides displaying help shall be done.
|
||||
|
||||
const char* name() const;
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
/// Initializes the application and all registered subsystems.
|
||||
/// Subsystems are always initialized in the exact same order
|
||||
/// in which they have been registered.
|
||||
///
|
||||
/// Overriding implementations must call the base class implementation.
|
||||
|
||||
void uninitialize();
|
||||
/// Uninitializes the application and all registered subsystems.
|
||||
/// Subsystems are always uninitialized in reverse order in which
|
||||
/// they have been initialized.
|
||||
///
|
||||
/// Overriding implementations must call the base class implementation.
|
||||
|
||||
void reinitialize(Application& self);
|
||||
/// Re-nitializes the application and all registered subsystems.
|
||||
/// Subsystems are always reinitialized in the exact same order
|
||||
/// in which they have been registered.
|
||||
///
|
||||
/// Overriding implementations must call the base class implementation.
|
||||
|
||||
virtual void defineOptions(OptionSet& options);
|
||||
/// Called before command line processing begins.
|
||||
/// If a subclass wants to support command line arguments,
|
||||
/// it must override this method.
|
||||
/// The default implementation does not define any options itself,
|
||||
/// but calls defineOptions() on all registered subsystems.
|
||||
///
|
||||
/// Overriding implementations should call the base class implementation.
|
||||
|
||||
virtual void handleOption(const std::string& name, const std::string& value);
|
||||
/// Called when the option with the given name is encountered
|
||||
/// during command line arguments processing.
|
||||
///
|
||||
/// The default implementation does option validation, bindings
|
||||
/// and callback handling.
|
||||
///
|
||||
/// Overriding implementations must call the base class implementation.
|
||||
|
||||
void setLogger(Poco::Logger& logger);
|
||||
/// Sets the logger used by the application.
|
||||
|
||||
virtual int main(const std::vector<std::string>& args);
|
||||
/// The application's main logic.
|
||||
///
|
||||
/// Unprocessed command line arguments are passed in args.
|
||||
/// Note that all original command line arguments are available
|
||||
/// via the properties application.argc and application.argv[<n>].
|
||||
///
|
||||
/// Returns an exit code which should be one of the values
|
||||
/// from the ExitCode enumeration.
|
||||
|
||||
bool findFile(Poco::Path& path) const;
|
||||
/// Searches for the file in path in the application directory.
|
||||
///
|
||||
/// If path is absolute, the method immediately returns true and
|
||||
/// leaves path unchanged.
|
||||
///
|
||||
/// If path is relative, searches for the file in the application
|
||||
/// directory and in all subsequent parent directories.
|
||||
/// Returns true and stores the absolute path to the file in
|
||||
/// path if the file could be found. Returns false and leaves path
|
||||
/// unchanged otherwise.
|
||||
|
||||
void init();
|
||||
/// Common initialization code.
|
||||
|
||||
~Application();
|
||||
/// Destroys the Application and deletes all registered subsystems.
|
||||
|
||||
private:
|
||||
void setup();
|
||||
void setArgs(int argc, char* argv[]);
|
||||
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;
|
||||
bool findAppConfigFile(const Path& basePath, const std::string& appName, const std::string& extension, Poco::Path& path) const;
|
||||
|
||||
typedef LayeredConfiguration::Ptr ConfigPtr;
|
||||
typedef Poco::Logger::Ptr LoggerPtr;
|
||||
|
||||
ConfigPtr _pConfig;
|
||||
SubsystemVec _subsystems;
|
||||
bool _initialized;
|
||||
std::string _command;
|
||||
ArgVec _argv;
|
||||
ArgVec _unprocessedArgs;
|
||||
OptionSet _options;
|
||||
bool _unixOptions;
|
||||
Logger* _pLogger;
|
||||
Poco::Timestamp _startTime;
|
||||
bool _stopOptionsProcessing;
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_VXWORKS)
|
||||
std::string _workingDirAtLaunch;
|
||||
#endif
|
||||
|
||||
static Application* _pInstance;
|
||||
|
||||
friend class LoggingSubsystem;
|
||||
|
||||
Application(const Application&);
|
||||
Application& operator = (const Application&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
template <class C> C& Application::getSubsystem() const
|
||||
{
|
||||
for (const auto& pSub: _subsystems)
|
||||
{
|
||||
const Subsystem* pSS(pSub.get());
|
||||
const C* pC = dynamic_cast<const C*>(pSS);
|
||||
if (pC) return *const_cast<C*>(pC);
|
||||
}
|
||||
throw Poco::NotFoundException("The subsystem has not been registered", typeid(C).name());
|
||||
}
|
||||
|
||||
inline Application::SubsystemVec& Application::subsystems()
|
||||
{
|
||||
return _subsystems;
|
||||
}
|
||||
|
||||
|
||||
inline bool Application::initialized() const
|
||||
{
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
|
||||
inline LayeredConfiguration& Application::config() const
|
||||
{
|
||||
return *const_cast<LayeredConfiguration*>(_pConfig.get());
|
||||
}
|
||||
|
||||
|
||||
inline LayeredConfiguration::Ptr Application::configPtr() const
|
||||
{
|
||||
return _pConfig;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::Logger& Application::logger() const
|
||||
{
|
||||
poco_check_ptr (_pLogger);
|
||||
return *_pLogger;
|
||||
}
|
||||
|
||||
|
||||
inline const Application::ArgVec& Application::argv() const
|
||||
{
|
||||
return _argv;
|
||||
}
|
||||
|
||||
|
||||
inline const OptionSet& Application::options() const
|
||||
{
|
||||
return _options;
|
||||
}
|
||||
|
||||
|
||||
inline Application& Application::instance()
|
||||
{
|
||||
poco_check_ptr (_pInstance);
|
||||
return *_pInstance;
|
||||
}
|
||||
|
||||
|
||||
inline const Poco::Timestamp& Application::startTime() const
|
||||
{
|
||||
return _startTime;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::Timespan Application::uptime() const
|
||||
{
|
||||
Poco::Timestamp now;
|
||||
Poco::Timespan uptime = now - _startTime;
|
||||
|
||||
return uptime;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
//
|
||||
// Macro to implement main()
|
||||
//
|
||||
#if defined(_WIN32)
|
||||
#define POCO_APP_MAIN(App) \
|
||||
int wmain(int argc, wchar_t** argv) \
|
||||
{ \
|
||||
Poco::AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
pApp->logger().log(exc); \
|
||||
return Poco::Util::Application::EXIT_CONFIG;\
|
||||
} \
|
||||
return pApp->run(); \
|
||||
}
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#define POCO_APP_MAIN(App) \
|
||||
int pocoAppMain(const char* appName, ...) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
args.push_back(std::string(appName)); \
|
||||
va_list vargs; \
|
||||
va_start(vargs, appName); \
|
||||
const char* arg = va_arg(vargs, const char*); \
|
||||
while (arg) \
|
||||
{ \
|
||||
args.push_back(std::string(arg)); \
|
||||
arg = va_arg(vargs, const char*); \
|
||||
} \
|
||||
va_end(vargs); \
|
||||
Poco::AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(args); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
pApp->logger().log(exc); \
|
||||
return Poco::Util::Application::EXIT_CONFIG;\
|
||||
} \
|
||||
return pApp->run(); \
|
||||
}
|
||||
#else
|
||||
#define POCO_APP_MAIN(App) \
|
||||
int main(int argc, char** argv) \
|
||||
{ \
|
||||
Poco::AutoPtr<App> pApp = new App; \
|
||||
try \
|
||||
{ \
|
||||
pApp->init(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
pApp->logger().log(exc); \
|
||||
return Poco::Util::Application::EXIT_CONFIG;\
|
||||
} \
|
||||
return pApp->run(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Util_Application_INCLUDED
|
94
vendor/POCO/Util/include/Poco/Util/ConfigurationMapper.h
vendored
Normal file
94
vendor/POCO/Util/include/Poco/Util/ConfigurationMapper.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// ConfigurationMapper.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: ConfigurationMapper
|
||||
//
|
||||
// Definition of the ConfigurationMapper class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_ConfigurationMapper_INCLUDED
|
||||
#define Util_ConfigurationMapper_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API ConfigurationMapper: public AbstractConfiguration
|
||||
/// This configuration maps a property hierarchy into another
|
||||
/// hierarchy.
|
||||
///
|
||||
/// For example, given a configuration with the following properties:
|
||||
/// config.value1
|
||||
/// config.value2
|
||||
/// config.sub.value1
|
||||
/// config.sub.value2
|
||||
/// and a ConfigurationView with fromPrefix == "config" and toPrefix == "root.conf", then
|
||||
/// the above properties will be available via the mapper as
|
||||
/// root.conf.value1
|
||||
/// root.conf.value2
|
||||
/// root.conf.sub.value1
|
||||
/// root.conf.sub.value2
|
||||
///
|
||||
/// FromPrefix can be empty, in which case, and given toPrefix == "root",
|
||||
/// the properties will be available as
|
||||
/// root.config.value1
|
||||
/// root.config.value2
|
||||
/// root.config.sub.value1
|
||||
/// root.config.sub.value2
|
||||
///
|
||||
/// This is equivalent to the functionality of the ConfigurationView class.
|
||||
///
|
||||
/// Similarly, toPrefix can also be empty. Given fromPrefix == "config" and
|
||||
/// toPrefix == "", the properties will be available as
|
||||
/// value1
|
||||
/// value2
|
||||
/// sub.value1
|
||||
/// sub.value2
|
||||
///
|
||||
/// If both fromPrefix and toPrefix are empty, no mapping is performed.
|
||||
///
|
||||
/// A ConfigurationMapper is most useful in combination with a
|
||||
/// LayeredConfiguration.
|
||||
{
|
||||
public:
|
||||
ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration::Ptr pConfig);
|
||||
/// Creates the ConfigurationMapper. The ConfigurationMapper
|
||||
/// retains (shared) ownership of the passed configuration.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
|
||||
std::string translateKey(const std::string& key) const;
|
||||
|
||||
~ConfigurationMapper();
|
||||
|
||||
private:
|
||||
ConfigurationMapper(const ConfigurationMapper&);
|
||||
ConfigurationMapper& operator = (const ConfigurationMapper&);
|
||||
|
||||
std::string _fromPrefix;
|
||||
std::string _toPrefix;
|
||||
AbstractConfiguration::Ptr _pConfig;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_ConfigurationMapper_INCLUDED
|
82
vendor/POCO/Util/include/Poco/Util/ConfigurationView.h
vendored
Normal file
82
vendor/POCO/Util/include/Poco/Util/ConfigurationView.h
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// ConfigurationView.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: ConfigurationView
|
||||
//
|
||||
// Definition of the ConfigurationView class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_ConfigurationView_INCLUDED
|
||||
#define Util_ConfigurationView_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API ConfigurationView: public AbstractConfiguration
|
||||
/// This configuration implements a "view" into a sub-hierarchy
|
||||
/// of another configuration.
|
||||
///
|
||||
/// For example, given a configuration with the following properties:
|
||||
/// config.value1
|
||||
/// config.value2
|
||||
/// config.sub.value1
|
||||
/// config.sub.value2
|
||||
/// and a ConfigurationView with the prefix "config", then
|
||||
/// the above properties will be available via the view as
|
||||
/// value1
|
||||
/// value2
|
||||
/// sub.value1
|
||||
/// sub.value2
|
||||
///
|
||||
/// A ConfigurationView is most useful in combination with a
|
||||
/// LayeredConfiguration.
|
||||
///
|
||||
/// If a property is not found in the view, it is searched in
|
||||
/// the original configuration. Given the above example configuration,
|
||||
/// the property named "config.value1" will still be found in the view.
|
||||
///
|
||||
/// The main reason for this is that placeholder expansion (${property})
|
||||
/// still works as expected given a ConfigurationView.
|
||||
{
|
||||
public:
|
||||
ConfigurationView(const std::string& prefix, AbstractConfiguration::Ptr pConfig);
|
||||
/// Creates the ConfigurationView. The ConfigurationView
|
||||
/// retains (shared) ownership of the passed configuration.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
|
||||
std::string translateKey(const std::string& key) const;
|
||||
|
||||
~ConfigurationView();
|
||||
|
||||
private:
|
||||
ConfigurationView(const ConfigurationView&);
|
||||
ConfigurationView& operator = (const ConfigurationView&);
|
||||
|
||||
std::string _prefix;
|
||||
AbstractConfiguration::Ptr _pConfig;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_ConfigurationView_INCLUDED
|
93
vendor/POCO/Util/include/Poco/Util/FilesystemConfiguration.h
vendored
Normal file
93
vendor/POCO/Util/include/Poco/Util/FilesystemConfiguration.h
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// FilesystemConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: FilesystemConfiguration
|
||||
//
|
||||
// Definition of the FilesystemConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_FilesystemConfiguration_INCLUDED
|
||||
#define Util_FilesystemConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/Path.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API FilesystemConfiguration: public AbstractConfiguration
|
||||
/// An implementation of AbstractConfiguration that stores configuration data
|
||||
/// in a directory hierarchy in the filesystem.
|
||||
///
|
||||
/// Every period-separated part of a property name is represented
|
||||
/// as a directory in the filesystem, relative to the base directory.
|
||||
/// Values are stored in files named "data".
|
||||
///
|
||||
/// All changes to properties are immediately persisted in the filesystem.
|
||||
///
|
||||
/// For example, a configuration consisting of the properties
|
||||
///
|
||||
/// logging.loggers.root.channel.class = ConsoleChannel
|
||||
/// logging.loggers.app.name = Application
|
||||
/// logging.loggers.app.channel = c1
|
||||
/// logging.formatters.f1.class = PatternFormatter
|
||||
/// logging.formatters.f1.pattern = [%p] %t
|
||||
///
|
||||
/// is stored in the filesystem as follows:
|
||||
///
|
||||
/// logging/
|
||||
/// loggers/
|
||||
/// root/
|
||||
/// channel/
|
||||
/// class/
|
||||
/// data ("ConsoleChannel")
|
||||
/// app/
|
||||
/// name/
|
||||
/// data ("Application")
|
||||
/// channel/
|
||||
/// data ("c1")
|
||||
/// formatters/
|
||||
/// f1/
|
||||
/// class/
|
||||
/// data ("PatternFormatter")
|
||||
/// pattern/
|
||||
/// data ("[%p] %t")
|
||||
{
|
||||
public:
|
||||
FilesystemConfiguration(const std::string& path);
|
||||
/// Creates a FilesystemConfiguration using the given path.
|
||||
/// All directories are created as necessary.
|
||||
|
||||
void clear();
|
||||
/// Clears the configuration by erasing the configuration
|
||||
/// directory and all its subdirectories and files.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
Poco::Path keyToPath(const std::string& key) const;
|
||||
~FilesystemConfiguration();
|
||||
|
||||
private:
|
||||
Poco::Path _path;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_FilesystemConfiguration_INCLUDED
|
202
vendor/POCO/Util/include/Poco/Util/HelpFormatter.h
vendored
Normal file
202
vendor/POCO/Util/include/Poco/Util/HelpFormatter.h
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
//
|
||||
// HelpFormatter.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: HelpFormatter
|
||||
//
|
||||
// Definition of the HelpFormatter class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_HelpFormatter_INCLUDED
|
||||
#define Util_HelpFormatter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class OptionSet;
|
||||
class Option;
|
||||
|
||||
|
||||
class Util_API HelpFormatter
|
||||
/// This class formats a help message from an OptionSet.
|
||||
{
|
||||
public:
|
||||
HelpFormatter(const OptionSet& options);
|
||||
/// Creates the HelpFormatter, using the given
|
||||
/// options.
|
||||
///
|
||||
/// The HelpFormatter just stores a reference
|
||||
/// to the given OptionSet, so the OptionSet must not
|
||||
/// be destroyed during the lifetime of the HelpFormatter.
|
||||
|
||||
~HelpFormatter();
|
||||
/// Destroys the HelpFormatter.
|
||||
|
||||
void setCommand(const std::string& command);
|
||||
/// Sets the command name.
|
||||
|
||||
const std::string& getCommand() const;
|
||||
/// Returns the command name.
|
||||
|
||||
void setUsage(const std::string& usage);
|
||||
/// Sets the usage string.
|
||||
|
||||
const std::string& getUsage() const;
|
||||
/// Returns the usage string.
|
||||
|
||||
void setHeader(const std::string& header);
|
||||
/// Sets the header string.
|
||||
|
||||
const std::string& getHeader() const;
|
||||
/// Returns the header string.
|
||||
|
||||
void setFooter(const std::string& footer);
|
||||
/// Sets the footer string.
|
||||
|
||||
const std::string& getFooter() const;
|
||||
/// Returns the footer string.
|
||||
|
||||
void format(std::ostream& ostr) const;
|
||||
/// Writes the formatted help text to the given stream.
|
||||
|
||||
void setWidth(int width);
|
||||
/// Sets the line width for the formatted help text.
|
||||
|
||||
int getWidth() const;
|
||||
/// Returns the line width for the formatted help text.
|
||||
///
|
||||
/// The default width is 72.
|
||||
|
||||
void setIndent(int indent);
|
||||
/// Sets the indentation for description continuation lines.
|
||||
|
||||
int getIndent() const;
|
||||
/// Returns the indentation for description continuation lines.
|
||||
|
||||
void setAutoIndent();
|
||||
/// Sets the indentation for description continuation lines so that
|
||||
/// the description text is left-aligned.
|
||||
|
||||
void setUnixStyle(bool flag);
|
||||
/// Enables Unix-style options. Both short and long option names
|
||||
/// are printed if Unix-style is set. Otherwise, only long option
|
||||
/// names are printed.
|
||||
///
|
||||
/// After calling setUnixStyle(), setAutoIndent() should be called
|
||||
/// as well to ensure proper help text formatting.
|
||||
|
||||
bool isUnixStyle() const;
|
||||
/// Returns if Unix-style options are set.
|
||||
|
||||
std::string shortPrefix() const;
|
||||
/// Returns the platform-specific prefix for short options.
|
||||
/// "-" on Unix, "/" on Windows and OpenVMS.
|
||||
|
||||
std::string longPrefix() const;
|
||||
/// Returns the platform-specific prefix for long options.
|
||||
/// "--" on Unix, "/" on Windows and OpenVMS.
|
||||
|
||||
protected:
|
||||
int calcIndent() const;
|
||||
/// Calculates the indentation for the option descriptions
|
||||
/// from the given options.
|
||||
|
||||
void formatOptions(std::ostream& ostr) const;
|
||||
/// Formats all options.
|
||||
|
||||
void formatOption(std::ostream& ostr, const Option& option, int width) const;
|
||||
/// Formats an option, using the platform-specific
|
||||
/// prefixes.
|
||||
|
||||
void formatText(std::ostream& ostr, const std::string& text, int indent) const;
|
||||
/// Formats the given text.
|
||||
|
||||
void formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const;
|
||||
/// Formats the given text.
|
||||
|
||||
void formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const;
|
||||
/// Formats the given word.
|
||||
|
||||
void clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const;
|
||||
/// Formats and then clears the given word.
|
||||
|
||||
private:
|
||||
HelpFormatter(const HelpFormatter&);
|
||||
HelpFormatter& operator = (const HelpFormatter&);
|
||||
|
||||
const OptionSet& _options;
|
||||
int _width;
|
||||
int _indent;
|
||||
std::string _command;
|
||||
std::string _usage;
|
||||
std::string _header;
|
||||
std::string _footer;
|
||||
bool _unixStyle;
|
||||
|
||||
static const int TAB_WIDTH;
|
||||
static const int LINE_WIDTH;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline int HelpFormatter::getWidth() const
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
|
||||
inline int HelpFormatter::getIndent() const
|
||||
{
|
||||
return _indent;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HelpFormatter::getCommand() const
|
||||
{
|
||||
return _command;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HelpFormatter::getUsage() const
|
||||
{
|
||||
return _usage;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HelpFormatter::getHeader() const
|
||||
{
|
||||
return _header;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HelpFormatter::getFooter() const
|
||||
{
|
||||
return _footer;
|
||||
}
|
||||
|
||||
|
||||
inline bool HelpFormatter::isUnixStyle() const
|
||||
{
|
||||
return _unixStyle;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_HelpFormatter_INCLUDED
|
99
vendor/POCO/Util/include/Poco/Util/IniFileConfiguration.h
vendored
Normal file
99
vendor/POCO/Util/include/Poco/Util/IniFileConfiguration.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// IniFileConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: IniFileConfiguration
|
||||
//
|
||||
// Definition of the IniFileConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_IniFileConfiguration_INCLUDED
|
||||
#define Util_IniFileConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
|
||||
|
||||
#ifndef POCO_UTIL_NO_INIFILECONFIGURATION
|
||||
|
||||
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include <map>
|
||||
#include <istream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API IniFileConfiguration: public AbstractConfiguration
|
||||
/// This implementation of a Configuration reads properties
|
||||
/// from a legacy Windows initialization (.ini) file.
|
||||
///
|
||||
/// The file syntax is implemented as follows.
|
||||
/// - a line starting with a semicolon is treated as a comment and ignored
|
||||
/// - a line starting with a square bracket denotes a section key [<key>]
|
||||
/// - every other line denotes a property assignment in the form
|
||||
/// <value key> = <value>
|
||||
///
|
||||
/// The name of a property is composed of the section key and the value key,
|
||||
/// separated by a period (<section key>.<value key>).
|
||||
///
|
||||
/// Property names are not case sensitive. Leading and trailing whitespace is
|
||||
/// removed from both keys and values.
|
||||
{
|
||||
public:
|
||||
IniFileConfiguration();
|
||||
/// Creates an empty IniFileConfiguration.
|
||||
|
||||
IniFileConfiguration(std::istream& istr);
|
||||
/// Creates an IniFileConfiguration and loads the configuration data
|
||||
/// from the given stream, which must be in initialization file format.
|
||||
|
||||
IniFileConfiguration(const std::string& path);
|
||||
/// Creates an IniFileConfiguration and loads the configuration data
|
||||
/// from the given file, which must be in initialization file format.
|
||||
|
||||
void load(std::istream& istr);
|
||||
/// Loads the configuration data from the given stream, which
|
||||
/// must be in initialization file format.
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the configuration data from the given file, which
|
||||
/// must be in initialization file format.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
~IniFileConfiguration();
|
||||
|
||||
private:
|
||||
void parseLine(std::istream& istr);
|
||||
|
||||
struct ICompare
|
||||
{
|
||||
bool operator () (const std::string& s1, const std::string& s2) const;
|
||||
};
|
||||
typedef std::map<std::string, std::string, ICompare> IStringMap;
|
||||
|
||||
IStringMap _map;
|
||||
std::string _sectionKey;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // POCO_UTIL_NO_INIFILECONFIGURATION
|
||||
|
||||
|
||||
#endif // Util_IniFileConfiguration_INCLUDED
|
56
vendor/POCO/Util/include/Poco/Util/IntValidator.h
vendored
Normal file
56
vendor/POCO/Util/include/Poco/Util/IntValidator.h
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// IntValidator.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: IntValidator
|
||||
//
|
||||
// Definition of the IntValidator class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_IntValidator_INCLUDED
|
||||
#define Util_IntValidator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Validator.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API IntValidator: public Validator
|
||||
/// The IntValidator tests whether the option argument,
|
||||
/// which must be an integer, lies within a given range.
|
||||
{
|
||||
public:
|
||||
IntValidator(int min, int max);
|
||||
/// Creates the IntValidator.
|
||||
|
||||
~IntValidator();
|
||||
/// Destroys the IntValidator.
|
||||
|
||||
void validate(const Option& option, const std::string& value);
|
||||
/// Validates the value for the given option by
|
||||
/// testing whether it's an integer that lies within
|
||||
/// a given range.
|
||||
|
||||
private:
|
||||
IntValidator();
|
||||
|
||||
int _min;
|
||||
int _max;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_IntValidator_INCLUDED
|
150
vendor/POCO/Util/include/Poco/Util/JSONConfiguration.h
vendored
Normal file
150
vendor/POCO/Util/include/Poco/Util/JSONConfiguration.h
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
//
|
||||
// JSONConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Util
|
||||
// Module: JSONConfiguration
|
||||
//
|
||||
// Definition of the JSONConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_JSONConfiguration_INCLUDED
|
||||
#define Util_JSONConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
|
||||
|
||||
#ifndef POCO_UTIL_NO_JSONCONFIGURATION
|
||||
|
||||
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include <istream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API JSONConfiguration : public AbstractConfiguration
|
||||
/// This configuration class extracts configuration properties
|
||||
/// from a JSON object. An XPath-like syntax for property
|
||||
/// names is supported to allow full access to the JSON object.
|
||||
///
|
||||
/// Given the following JSON object as an example:
|
||||
/// {
|
||||
/// "config" : {
|
||||
/// "prop1" : "value1",
|
||||
/// "prop2" : 10,
|
||||
/// "prop3" : [
|
||||
/// "element1",
|
||||
/// "element2"
|
||||
/// ],
|
||||
/// "prop4" : {
|
||||
/// "prop5" : false,
|
||||
/// "prop6" : null
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// The following property names would be valid and would
|
||||
/// yield the shown values:
|
||||
///
|
||||
/// config.prop1 --> "value1"
|
||||
/// config.prop3[1] --> "element2"
|
||||
/// config.prop4.prop5 --> false
|
||||
{
|
||||
public:
|
||||
|
||||
JSONConfiguration();
|
||||
/// Creates an empty configuration
|
||||
|
||||
|
||||
JSONConfiguration(const std::string& path);
|
||||
/// Creates a configuration and loads the JSON structure from the given file
|
||||
|
||||
|
||||
JSONConfiguration(std::istream& istr);
|
||||
/// Creates a configuration and loads the JSON structure from the given stream
|
||||
|
||||
|
||||
JSONConfiguration(const JSON::Object::Ptr& object);
|
||||
/// Creates a configuration from the given JSON object
|
||||
|
||||
|
||||
virtual ~JSONConfiguration();
|
||||
/// Destructor
|
||||
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the configuration from the given file
|
||||
|
||||
|
||||
void load(std::istream& istr);
|
||||
/// Loads the configuration from the given stream
|
||||
|
||||
|
||||
void loadEmpty(const std::string& root);
|
||||
/// Loads an empty object containing only a root object with the given name.
|
||||
|
||||
|
||||
void save(std::ostream& ostr, unsigned int indent = 2) const;
|
||||
/// Saves the configuration to the given stream
|
||||
|
||||
|
||||
virtual void setInt(const std::string& key, int value);
|
||||
|
||||
|
||||
virtual void setBool(const std::string& key, bool value);
|
||||
|
||||
|
||||
virtual void setDouble(const std::string& key, double value);
|
||||
|
||||
|
||||
virtual void setString(const std::string& key, const std::string& value);
|
||||
|
||||
|
||||
virtual void removeRaw(const std::string& key);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
bool getRaw(const std::string & key, std::string & value) const;
|
||||
|
||||
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
|
||||
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
JSON::Object::Ptr findStart(const std::string& key, std::string& lastPart);
|
||||
|
||||
|
||||
void getIndexes(std::string& name, std::vector<int>& indexes);
|
||||
|
||||
|
||||
void setValue(const std::string& key, const Poco::DynamicAny& value);
|
||||
|
||||
|
||||
JSON::Object::Ptr _object;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // POCO_UTIL_NO_JSONCONFIGURATION
|
||||
|
||||
|
||||
#endif // Util_JSONConfiguration_INCLUDED
|
||||
|
130
vendor/POCO/Util/include/Poco/Util/LayeredConfiguration.h
vendored
Normal file
130
vendor/POCO/Util/include/Poco/Util/LayeredConfiguration.h
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// LayeredConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: LayeredConfiguration
|
||||
//
|
||||
// Definition of the LayeredConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_LayeredConfiguration_INCLUDED
|
||||
#define Util_LayeredConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <list>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API LayeredConfiguration: public AbstractConfiguration
|
||||
/// A LayeredConfiguration consists of a number of AbstractConfigurations.
|
||||
///
|
||||
/// When reading a configuration property in a LayeredConfiguration,
|
||||
/// all added configurations are searched, in order of their priority.
|
||||
/// Configurations with lower priority values have precedence.
|
||||
///
|
||||
/// When setting a property, the property is always written to the first writeable
|
||||
/// configuration (see addWriteable()).
|
||||
/// If no writeable configuration has been added to the LayeredConfiguration, and an
|
||||
/// attempt is made to set a property, a RuntimeException is thrown.
|
||||
///
|
||||
/// Every configuration added to the LayeredConfiguration has a priority value.
|
||||
/// The priority determines the position where the configuration is inserted,
|
||||
/// with lower priority values coming before higher priority values.
|
||||
///
|
||||
/// If no priority is specified, a priority of 0 is assumed.
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::AutoPtr<LayeredConfiguration>;
|
||||
|
||||
LayeredConfiguration();
|
||||
/// Creates the LayeredConfiguration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig);
|
||||
/// Adds a read-only configuration to the back of the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig, const std::string& label);
|
||||
/// Adds a read-only configuration with the given label to the back of the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig, int priority);
|
||||
/// Adds a read-only configuration to the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig, const std::string& label, int priority);
|
||||
/// Adds a read-only configuration with the given label to the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig, int priority, bool writeable);
|
||||
/// Adds a configuration to the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void add(AbstractConfiguration::Ptr pConfig, const std::string& label, int priority, bool writeable);
|
||||
/// Adds a configuration with the given label to the LayeredConfiguration.
|
||||
/// The LayeredConfiguration takes shared ownership of the given configuration.
|
||||
|
||||
void addWriteable(AbstractConfiguration::Ptr pConfig, int priority);
|
||||
/// Adds a writeable configuration to the LayeredConfiguration.
|
||||
/// The LayeredConfiguration does not take ownership of the given
|
||||
/// configuration. In other words, the configuration's reference
|
||||
/// count is incremented.
|
||||
|
||||
AbstractConfiguration::Ptr find(const std::string& label) const;
|
||||
/// Finds and returns the configuration with the given label.
|
||||
///
|
||||
/// Returns null if no such configuration can be found.
|
||||
|
||||
void removeConfiguration(AbstractConfiguration::Ptr pConfig);
|
||||
/// Removes the given configuration from the LayeredConfiguration.
|
||||
///
|
||||
/// Does nothing if the given configuration is not part of the
|
||||
/// LayeredConfiguration.
|
||||
|
||||
protected:
|
||||
struct ConfigItem
|
||||
{
|
||||
typedef AbstractConfiguration::Ptr ACPtr;
|
||||
ACPtr pConfig;
|
||||
int priority;
|
||||
bool writeable;
|
||||
std::string label;
|
||||
};
|
||||
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
|
||||
int lowest() const;
|
||||
int highest() const;
|
||||
void insert(const ConfigItem& item);
|
||||
|
||||
~LayeredConfiguration();
|
||||
|
||||
private:
|
||||
LayeredConfiguration(const LayeredConfiguration&);
|
||||
LayeredConfiguration& operator = (const LayeredConfiguration&);
|
||||
|
||||
typedef std::list<ConfigItem> ConfigList;
|
||||
|
||||
ConfigList _configs;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_LayeredConfiguration_INCLUDED
|
137
vendor/POCO/Util/include/Poco/Util/LoggingConfigurator.h
vendored
Normal file
137
vendor/POCO/Util/include/Poco/Util/LoggingConfigurator.h
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// LoggingConfigurator.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: LoggingConfigurator
|
||||
//
|
||||
// Definition of the LoggingConfigurator class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_LoggingConfigurator_INCLUDED
|
||||
#define Util_LoggingConfigurator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Formatter.h"
|
||||
#include "Poco/Channel.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API LoggingConfigurator
|
||||
/// This utility class uses a configuration object to configure the
|
||||
/// logging subsystem of an application.
|
||||
///
|
||||
/// The LoggingConfigurator sets up and connects formatters, channels
|
||||
/// and loggers. To accomplish its work, the LoggingConfigurator relies on the
|
||||
/// functionality provided by the LoggingFactory and LoggingRegistry classes.
|
||||
///
|
||||
/// The LoggingConfigurator expects all configuration data to be under a root
|
||||
/// property named "logging".
|
||||
///
|
||||
/// Configuring Formatters
|
||||
///
|
||||
/// A formatter is configured using the "logging.formatters" property. Every
|
||||
/// formatter has an internal name, which is only used for referring to it
|
||||
/// during configuration time. This name becomes part of the property name.
|
||||
/// Every formatter has a mandatory "class" property, which specifies the actual
|
||||
/// class implementing the formatter. Any other properties are passed on to
|
||||
/// the formatter by calling its setProperty() method.
|
||||
///
|
||||
/// A typical formatter definition looks as follows:
|
||||
/// logging.formatters.f1.class = PatternFormatter
|
||||
/// logging.formatters.f1.pattern = %s: [%p] %t
|
||||
/// logging.formatters.f1.times = UTC
|
||||
///
|
||||
/// Configuring Channels
|
||||
///
|
||||
/// A channel is configured using the "logging.channels" property. Like with
|
||||
/// Formatters, every channel has an internal name, which is used during
|
||||
/// configuration only. The name becomes part of the property name.
|
||||
/// Every channel has a mandatory "class" property, which specifies the actual
|
||||
/// class implementing the channel. Any other properties are passed on to
|
||||
/// the formatter by calling its setProperty() method.
|
||||
///
|
||||
/// For convenience, the "formatter" property of a channel is treated
|
||||
/// specifically. The "formatter" property can either be used to refer to
|
||||
/// an already defined formatter, or it can be used to specify an "inline"
|
||||
/// formatter definition. In either case, when a "formatter" property is
|
||||
/// present, the channel is automatically "wrapped" in a FormattingChannel
|
||||
/// object.
|
||||
///
|
||||
/// Similarly, a channel supports also a "pattern" property, which results
|
||||
/// in the automatic instantiation of a FormattingChannel object with a
|
||||
/// connected PatternFormatter.
|
||||
///
|
||||
/// Examples:
|
||||
/// logging.channels.c1.class = ConsoleChannel
|
||||
/// logging.channels.c1.formatter = f1
|
||||
/// logging.channels.c2.class = FileChannel
|
||||
/// logging.channels.c2.path = ${system.tempDir}/sample.log
|
||||
/// logging.channels.c2.formatter.class = PatternFormatter
|
||||
/// logging.channels.c2.formatter.pattern = %s: [%p] %t
|
||||
/// logging.channels.c3.class = ConsoleChannel
|
||||
/// logging.channels.c3.pattern = %s: [%p] %t
|
||||
///
|
||||
/// Configuring Loggers
|
||||
///
|
||||
/// A logger is configured using the "logging.loggers" property. Like with
|
||||
/// channels and formatters, every logger has an internal name, which, however,
|
||||
/// is only used to ensure the uniqueness of the property names. Note that this
|
||||
/// name is different from the logger's full name, which is used to access
|
||||
/// the logger at runtime.
|
||||
/// Every logger except the root logger has a mandatory "name" property which
|
||||
/// is used to specify the logger's full name.
|
||||
/// Furthermore, a "channel" property is supported, which can either refer
|
||||
/// to a named channel, or which can contain an inline channel definition.
|
||||
///
|
||||
/// Examples:
|
||||
/// logging.loggers.root.channel = c1
|
||||
/// logging.loggers.root.level = warning
|
||||
/// logging.loggers.l1.name = logger1
|
||||
/// logging.loggers.l1.channel.class = ConsoleChannel
|
||||
/// logging.loggers.l1.channel.pattern = %s: [%p] %t
|
||||
/// logging.loggers.l1.level = information
|
||||
{
|
||||
public:
|
||||
LoggingConfigurator();
|
||||
/// Creates the LoggingConfigurator.
|
||||
|
||||
~LoggingConfigurator();
|
||||
/// Destroys the LoggingConfigurator.
|
||||
|
||||
void configure(AbstractConfiguration::Ptr pConfig);
|
||||
/// Configures the logging subsystem based on
|
||||
/// the given configuration.
|
||||
///
|
||||
/// A ConfigurationView can be used to pass only
|
||||
/// a part of a larger configuration.
|
||||
|
||||
private:
|
||||
void configureFormatters(AbstractConfiguration::Ptr pConfig);
|
||||
void configureChannels(AbstractConfiguration::Ptr pConfig);
|
||||
void configureLoggers(AbstractConfiguration::Ptr pConfig);
|
||||
Poco::Formatter::Ptr createFormatter(AbstractConfiguration::Ptr pConfig);
|
||||
Poco::Channel::Ptr createChannel(AbstractConfiguration::Ptr pConfig);
|
||||
void configureChannel(Channel::Ptr pChannel, AbstractConfiguration::Ptr pConfig);
|
||||
void configureLogger(AbstractConfiguration::Ptr pConfig);
|
||||
|
||||
LoggingConfigurator(const LoggingConfigurator&);
|
||||
LoggingConfigurator& operator = (const LoggingConfigurator&);
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_LoggingConfigurator_INCLUDED
|
52
vendor/POCO/Util/include/Poco/Util/LoggingSubsystem.h
vendored
Normal file
52
vendor/POCO/Util/include/Poco/Util/LoggingSubsystem.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// LoggingSubsystem.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
// Module: LoggingSubsystem
|
||||
//
|
||||
// Definition of the LoggingSubsystem class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_LoggingSubsystem_INCLUDED
|
||||
#define Util_LoggingSubsystem_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Subsystem.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API LoggingSubsystem: public Subsystem
|
||||
/// The LoggingSubsystem class initializes the logging
|
||||
/// framework using the LoggingConfigurator.
|
||||
///
|
||||
/// It also sets the Application's logger to
|
||||
/// the logger specified by the "application.logger"
|
||||
/// property, or to "Application" if the property
|
||||
/// is not specified.
|
||||
{
|
||||
public:
|
||||
LoggingSubsystem();
|
||||
const char* name() const;
|
||||
|
||||
protected:
|
||||
void initialize(Application& self);
|
||||
void uninitialize();
|
||||
~LoggingSubsystem();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_LoggingSubsystem_INCLUDED
|
64
vendor/POCO/Util/include/Poco/Util/MapConfiguration.h
vendored
Normal file
64
vendor/POCO/Util/include/Poco/Util/MapConfiguration.h
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// MapConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: MapConfiguration
|
||||
//
|
||||
// Definition of the MapConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_MapConfiguration_INCLUDED
|
||||
#define Util_MapConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API MapConfiguration: public AbstractConfiguration
|
||||
/// An implementation of AbstractConfiguration that stores configuration data in a map.
|
||||
{
|
||||
public:
|
||||
MapConfiguration();
|
||||
/// Creates an empty MapConfiguration.
|
||||
|
||||
void copyTo(AbstractConfiguration& config);
|
||||
/// Copies all configuration properties to the given configuration.
|
||||
|
||||
void clear();
|
||||
/// Clears the configuration.
|
||||
|
||||
protected:
|
||||
typedef std::map<std::string, std::string> StringMap;
|
||||
typedef StringMap::const_iterator iterator;
|
||||
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
~MapConfiguration();
|
||||
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
|
||||
private:
|
||||
StringMap _map;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_MapConfiguration_INCLUDED
|
332
vendor/POCO/Util/include/Poco/Util/Option.h
vendored
Normal file
332
vendor/POCO/Util/include/Poco/Util/Option.h
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
//
|
||||
// Option.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: Option
|
||||
//
|
||||
// Definition of the Option class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Option_INCLUDED
|
||||
#define Util_Option_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/OptionCallback.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Application;
|
||||
class Validator;
|
||||
|
||||
|
||||
class Util_API Option
|
||||
/// This class represents and stores the properties
|
||||
/// of a command line option.
|
||||
///
|
||||
/// An option has a full name, an optional short name,
|
||||
/// a description (used for printing a usage statement),
|
||||
/// and an optional argument name.
|
||||
/// An option can be optional or required.
|
||||
/// An option can be repeatable, which means that it can
|
||||
/// be given more than once on the command line.
|
||||
///
|
||||
/// An option can be part of an option group. At most one
|
||||
/// option of each group may be specified on the command
|
||||
/// line.
|
||||
///
|
||||
/// An option can be bound to a configuration property.
|
||||
/// In this case, a configuration property will automatically
|
||||
/// receive the option's argument value.
|
||||
///
|
||||
/// A callback method can be specified for options. This method
|
||||
/// is called whenever an option is specified on the command line.
|
||||
///
|
||||
/// Option argument values can be automatically validated using a
|
||||
/// Validator.
|
||||
///
|
||||
/// Option instances are value objects.
|
||||
///
|
||||
/// Typically, after construction, an Option object is immediately
|
||||
/// passed to an Options object.
|
||||
///
|
||||
/// An Option object can be created by chaining the constructor
|
||||
/// with any of the setter methods, as in the following example:
|
||||
///
|
||||
/// Option versionOpt("include", "I", "specify an include directory")
|
||||
/// .required(false)
|
||||
/// .repeatable(true)
|
||||
/// .argument("directory");
|
||||
{
|
||||
public:
|
||||
Option();
|
||||
/// Creates an empty Option.
|
||||
|
||||
Option(const Option& option);
|
||||
/// Creates an option from another one.
|
||||
|
||||
Option(const std::string& fullName, const std::string& shortName);
|
||||
/// Creates an option with the given properties.
|
||||
|
||||
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false);
|
||||
/// Creates an option with the given properties.
|
||||
|
||||
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argRequired = false);
|
||||
/// Creates an option with the given properties.
|
||||
|
||||
~Option();
|
||||
/// Destroys the Option.
|
||||
|
||||
Option& operator = (const Option& option);
|
||||
/// Assignment operator.
|
||||
|
||||
void swap(Option& option);
|
||||
/// Swaps the option with another one.
|
||||
|
||||
Option& shortName(const std::string& name);
|
||||
/// Sets the short name of the option.
|
||||
|
||||
Option& fullName(const std::string& name);
|
||||
/// Sets the full name of the option.
|
||||
|
||||
Option& description(const std::string& text);
|
||||
/// Sets the description of the option.
|
||||
|
||||
Option& required(bool flag);
|
||||
/// Sets whether the option is required (flag == true)
|
||||
/// or optional (flag == false).
|
||||
|
||||
Option& repeatable(bool flag);
|
||||
/// Sets whether the option can be specified more than once
|
||||
/// (flag == true) or at most once (flag == false).
|
||||
|
||||
Option& argument(const std::string& name, bool required = true);
|
||||
/// Specifies that the option takes an (optional or required)
|
||||
/// argument.
|
||||
|
||||
Option& noArgument();
|
||||
/// Specifies that the option does not take an argument (default).
|
||||
|
||||
Option& group(const std::string& group);
|
||||
/// Specifies the option group the option is part of.
|
||||
|
||||
Option& binding(const std::string& propertyName);
|
||||
/// Binds the option to the configuration property with the given name.
|
||||
///
|
||||
/// The configuration will automatically receive the option's argument.
|
||||
|
||||
Option& binding(const std::string& propertyName, AbstractConfiguration* pConfig);
|
||||
/// Binds the option to the configuration property with the given name,
|
||||
/// using the given AbstractConfiguration.
|
||||
///
|
||||
/// The configuration will automatically receive the option's argument.
|
||||
|
||||
Option& callback(const AbstractOptionCallback& cb);
|
||||
/// Binds the option to the given method.
|
||||
///
|
||||
/// The callback method will be called when the option
|
||||
/// has been specified on the command line.
|
||||
///
|
||||
/// Usage:
|
||||
/// callback(OptionCallback<MyApplication>(this, &MyApplication::myCallback));
|
||||
|
||||
Option& validator(Validator* pValidator);
|
||||
/// Sets the validator for the given option.
|
||||
///
|
||||
/// The Option takes ownership of the Validator and
|
||||
/// deletes it when it's no longer needed.
|
||||
|
||||
const std::string& shortName() const;
|
||||
/// Returns the short name of the option.
|
||||
|
||||
const std::string& fullName() const;
|
||||
/// Returns the full name of the option.
|
||||
|
||||
const std::string& description() const;
|
||||
/// Returns the description of the option.
|
||||
|
||||
bool required() const;
|
||||
/// Returns true if the option is required, false if not.
|
||||
|
||||
bool repeatable() const;
|
||||
/// Returns true if the option can be specified more than
|
||||
/// once, or false if at most once.
|
||||
|
||||
bool takesArgument() const;
|
||||
/// Returns true if the options takes an (optional) argument.
|
||||
|
||||
bool argumentRequired() const;
|
||||
/// Returns true if the argument is required.
|
||||
|
||||
const std::string& argumentName() const;
|
||||
/// Returns the argument name, if specified.
|
||||
|
||||
const std::string& group() const;
|
||||
/// Returns the option group the option is part of,
|
||||
/// or an empty string, if the option is not part of
|
||||
/// a group.
|
||||
|
||||
const std::string& binding() const;
|
||||
/// Returns the property name the option is bound to,
|
||||
/// or an empty string in case it is not bound.
|
||||
|
||||
AbstractOptionCallback* callback() const;
|
||||
/// Returns a pointer to the callback method for the option,
|
||||
/// or NULL if no callback has been specified.
|
||||
|
||||
Validator* validator() const;
|
||||
/// Returns the option's Validator, if one has been specified,
|
||||
/// or NULL otherwise.
|
||||
|
||||
AbstractConfiguration::Ptr config() const;
|
||||
/// Returns the configuration, if specified, or NULL otherwise.
|
||||
|
||||
bool matchesShort(const std::string& option) const;
|
||||
/// Returns true if the given option string matches the
|
||||
/// short name.
|
||||
///
|
||||
/// The first characters of the option string must match
|
||||
/// the short name of the option (case sensitive),
|
||||
/// or the option string must partially match the full
|
||||
/// name (case insensitive).
|
||||
|
||||
bool matchesFull(const std::string& option) const;
|
||||
/// Returns true if the given option string matches the
|
||||
/// full name.
|
||||
///
|
||||
/// The option string must match the full
|
||||
/// name (case insensitive).
|
||||
|
||||
bool matchesPartial(const std::string& option) const;
|
||||
/// Returns true if the given option string partially matches the
|
||||
/// full name.
|
||||
///
|
||||
/// The option string must partially match the full
|
||||
/// name (case insensitive).
|
||||
|
||||
void process(const std::string& option, std::string& arg) const;
|
||||
/// Verifies that the given option string matches the
|
||||
/// requirements of the option, and extracts the option argument,
|
||||
/// if present.
|
||||
///
|
||||
/// If the option string is okay and carries an argument,
|
||||
/// the argument is returned in arg.
|
||||
///
|
||||
/// Throws a MissingArgumentException if a required argument
|
||||
/// is missing. Throws an UnexpectedArgumentException if an
|
||||
/// argument has been found, but none is expected.
|
||||
|
||||
private:
|
||||
std::string _shortName;
|
||||
std::string _fullName;
|
||||
std::string _description;
|
||||
bool _required;
|
||||
bool _repeatable;
|
||||
std::string _argName;
|
||||
bool _argRequired;
|
||||
std::string _group;
|
||||
std::string _binding;
|
||||
Validator* _pValidator;
|
||||
AbstractOptionCallback* _pCallback;
|
||||
AbstractConfiguration::Ptr _pConfig;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
|
||||
|
||||
inline const std::string& Option::shortName() const
|
||||
{
|
||||
return _shortName;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Option::fullName() const
|
||||
{
|
||||
return _fullName;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Option::description() const
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
|
||||
inline bool Option::required() const
|
||||
{
|
||||
return _required;
|
||||
}
|
||||
|
||||
|
||||
inline bool Option::repeatable() const
|
||||
{
|
||||
return _repeatable;
|
||||
}
|
||||
|
||||
|
||||
inline bool Option::takesArgument() const
|
||||
{
|
||||
return !_argName.empty();
|
||||
}
|
||||
|
||||
|
||||
inline bool Option::argumentRequired() const
|
||||
{
|
||||
return _argRequired;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Option::argumentName() const
|
||||
{
|
||||
return _argName;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Option::group() const
|
||||
{
|
||||
return _group;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& Option::binding() const
|
||||
{
|
||||
return _binding;
|
||||
}
|
||||
|
||||
|
||||
inline AbstractOptionCallback* Option::callback() const
|
||||
{
|
||||
return _pCallback;
|
||||
}
|
||||
|
||||
|
||||
inline Validator* Option::validator() const
|
||||
{
|
||||
return _pValidator;
|
||||
}
|
||||
|
||||
|
||||
inline AbstractConfiguration::Ptr Option::config() const
|
||||
{
|
||||
return _pConfig;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_Option_INCLUDED
|
109
vendor/POCO/Util/include/Poco/Util/OptionCallback.h
vendored
Normal file
109
vendor/POCO/Util/include/Poco/Util/OptionCallback.h
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// OptionCallback.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: OptionCallback
|
||||
//
|
||||
// Definition of the OptionCallback class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_OptionCallback_INCLUDED
|
||||
#define Util_OptionCallback_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API AbstractOptionCallback
|
||||
/// Base class for OptionCallback.
|
||||
{
|
||||
public:
|
||||
virtual void invoke(const std::string& name, const std::string& value) const = 0;
|
||||
/// Invokes the callback member function.
|
||||
|
||||
virtual AbstractOptionCallback* clone() const = 0;
|
||||
/// Creates and returns a copy of the object.
|
||||
|
||||
virtual ~AbstractOptionCallback();
|
||||
/// Destroys the AbstractOptionCallback.
|
||||
|
||||
protected:
|
||||
AbstractOptionCallback();
|
||||
AbstractOptionCallback(const AbstractOptionCallback&);
|
||||
};
|
||||
|
||||
|
||||
template <class C>
|
||||
class OptionCallback: public AbstractOptionCallback
|
||||
/// This class is used as an argument to Option::callback().
|
||||
///
|
||||
/// It stores a pointer to an object and a pointer to a member
|
||||
/// function of the object's class.
|
||||
{
|
||||
public:
|
||||
typedef void (C::*Callback)(const std::string& name, const std::string& value);
|
||||
|
||||
OptionCallback(C* pObject, Callback method):
|
||||
_pObject(pObject),
|
||||
_method(method)
|
||||
/// Creates the OptionCallback for the given object and member function.
|
||||
{
|
||||
poco_check_ptr (pObject);
|
||||
}
|
||||
|
||||
OptionCallback(const OptionCallback& cb):
|
||||
AbstractOptionCallback(cb),
|
||||
_pObject(cb._pObject),
|
||||
_method(cb._method)
|
||||
/// Creates an OptionCallback from another one.
|
||||
{
|
||||
}
|
||||
|
||||
~OptionCallback()
|
||||
/// Destroys the OptionCallback.
|
||||
{
|
||||
}
|
||||
|
||||
OptionCallback& operator = (const OptionCallback& cb)
|
||||
{
|
||||
if (&cb != this)
|
||||
{
|
||||
this->_pObject = cb._pObject;
|
||||
this->_method = cb._method;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void invoke(const std::string& name, const std::string& value) const
|
||||
{
|
||||
(_pObject->*_method)(name, value);
|
||||
}
|
||||
|
||||
AbstractOptionCallback* clone() const
|
||||
{
|
||||
return new OptionCallback(_pObject, _method);
|
||||
}
|
||||
|
||||
private:
|
||||
OptionCallback();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_OptionCallback_INCLUDED
|
44
vendor/POCO/Util/include/Poco/Util/OptionException.h
vendored
Normal file
44
vendor/POCO/Util/include/Poco/Util/OptionException.h
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// OptionException.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: OptionException
|
||||
//
|
||||
// Definition of the OptionException class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_OptionException_INCLUDED
|
||||
#define Util_OptionException_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Exception.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
POCO_DECLARE_EXCEPTION(Util_API, OptionException, Poco::DataException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, UnknownOptionException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, AmbiguousOptionException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, MissingOptionException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, MissingArgumentException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, InvalidArgumentException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, UnexpectedArgumentException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, IncompatibleOptionsException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, DuplicateOptionException, OptionException)
|
||||
POCO_DECLARE_EXCEPTION(Util_API, EmptyOptionException, OptionException)
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_OptionException_INCLUDED
|
137
vendor/POCO/Util/include/Poco/Util/OptionProcessor.h
vendored
Normal file
137
vendor/POCO/Util/include/Poco/Util/OptionProcessor.h
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// OptionProcessor.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: OptionProcessor
|
||||
//
|
||||
// Definition of the OptionProcessor class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_OptionProcessor_INCLUDED
|
||||
#define Util_OptionProcessor_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class OptionSet;
|
||||
|
||||
|
||||
class Util_API OptionProcessor
|
||||
/// An OptionProcessor is used to process the command line
|
||||
/// arguments of an application.
|
||||
///
|
||||
/// The process() method takes an argument from the command line.
|
||||
/// If that argument starts with an option prefix, the argument
|
||||
/// is further processed. Otherwise, the argument is ignored and
|
||||
/// false is returned. The argument must match one of the options
|
||||
/// given in the OptionSet that is passed to the OptionProcessor
|
||||
/// with the constructor. If an option is part of a group, at most
|
||||
/// one option of the group can be passed to the OptionProcessor.
|
||||
/// Otherwise an IncompatibleOptionsException is thrown.
|
||||
/// If the same option is given multiple times, but the option
|
||||
/// is not repeatable, a DuplicateOptionException is thrown.
|
||||
/// If the option is not recognized, a UnexpectedArgumentException
|
||||
/// is thrown.
|
||||
/// If the option requires an argument, but none is given, an
|
||||
/// MissingArgumentException is thrown.
|
||||
/// If no argument is expected, but one is present, a
|
||||
/// UnexpectedArgumentException is thrown.
|
||||
/// If a partial option name is ambiguous, an AmbiguousOptionException
|
||||
/// is thrown.
|
||||
///
|
||||
/// The OptionProcessor supports two modes: Unix mode and default mode.
|
||||
/// In Unix mode, the option prefix is a dash '-'. A dash must be followed
|
||||
/// by a short option name, or another dash, followed by a (partial)
|
||||
/// long option name.
|
||||
/// In default mode, the option prefix is a slash '/', followed by
|
||||
/// a (partial) long option name.
|
||||
/// If the special option '--' is encountered in Unix mode, all following
|
||||
/// options are ignored.
|
||||
///
|
||||
/// Option arguments can be specified in three ways. If a Unix short option
|
||||
/// ("-o") is given, the argument directly follows the option name, without
|
||||
/// any delimiting character or space ("-ovalue"). In default option mode, or if a
|
||||
/// Unix long option ("--option") is given, the option argument is
|
||||
/// delimited from the option name with either an equal sign ('=') or
|
||||
/// a colon (':'), as in "--option=value" or "/option:value". Finally,
|
||||
/// a required option argument can be specified on the command line after the
|
||||
/// option, delimited with a space, as in "--option value" or "-o value".
|
||||
/// The latter only works for required option arguments, not optional ones.
|
||||
{
|
||||
public:
|
||||
OptionProcessor(const OptionSet& options);
|
||||
/// Creates the OptionProcessor, using the given OptionSet.
|
||||
|
||||
~OptionProcessor();
|
||||
/// Destroys the OptionProcessor.
|
||||
|
||||
void setUnixStyle(bool flag);
|
||||
/// Enables (flag == true) or disables (flag == false) Unix-style
|
||||
/// option processing.
|
||||
///
|
||||
/// If Unix-style processing is enabled, options are expected to
|
||||
/// begin with a single or a double dash ('-' or '--', respectively).
|
||||
/// A single dash must be followed by a short option name. A double
|
||||
/// dash must be followed by a (partial) full option name.
|
||||
///
|
||||
/// If Unix-style processing is disabled, options are expected to
|
||||
/// begin with a slash ('/'), followed by a (partial) full option name.
|
||||
|
||||
bool isUnixStyle() const;
|
||||
/// Returns true iff Unix-style option processing is enabled.
|
||||
|
||||
bool process(const std::string& argument, std::string& optionName, std::string& optionArg);
|
||||
/// Examines and processes the given command line argument.
|
||||
///
|
||||
/// If the argument begins with an option prefix, the option is processed
|
||||
/// and true is returned. The full option name is stored in optionName and the
|
||||
/// option argument, if present, is stored in optionArg.
|
||||
///
|
||||
/// If the option does not begin with an option prefix, false is returned.
|
||||
|
||||
void checkRequired() const;
|
||||
/// Checks if all required options have been processed.
|
||||
///
|
||||
/// Does nothing if all required options have been processed.
|
||||
/// Throws a MissingOptionException otherwise.
|
||||
|
||||
private:
|
||||
bool processUnix(const std::string& argument, std::string& optionName, std::string& optionArg);
|
||||
bool processDefault(const std::string& argument, std::string& optionName, std::string& optionArg);
|
||||
bool processCommon(const std::string& option, bool isShort, std::string& optionName, std::string& optionArg);
|
||||
|
||||
const OptionSet& _options;
|
||||
bool _unixStyle;
|
||||
bool _ignore;
|
||||
std::set<std::string> _groups;
|
||||
std::set<std::string> _specifiedOptions;
|
||||
std::string _deferredOption;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline bool OptionProcessor::isUnixStyle() const
|
||||
{
|
||||
return _unixStyle;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_OptionProcessor_INCLUDED
|
88
vendor/POCO/Util/include/Poco/Util/OptionSet.h
vendored
Normal file
88
vendor/POCO/Util/include/Poco/Util/OptionSet.h
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// OptionSet.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: OptionSet
|
||||
//
|
||||
// Definition of the OptionSet class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_OptionSet_INCLUDED
|
||||
#define Util_OptionSet_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Option.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API OptionSet
|
||||
/// A collection of Option objects.
|
||||
{
|
||||
public:
|
||||
using OptionVec = std::vector<Option>;
|
||||
using Iterator = OptionVec::const_iterator;
|
||||
|
||||
OptionSet();
|
||||
/// Creates the OptionSet.
|
||||
|
||||
OptionSet(const OptionSet& options);
|
||||
/// Creates an option set from another one.
|
||||
|
||||
~OptionSet();
|
||||
/// Destroys the OptionSet.
|
||||
|
||||
OptionSet& operator = (const OptionSet& options);
|
||||
/// Assignment operator.
|
||||
|
||||
void addOption(const Option& option);
|
||||
/// Adds an option to the collection.
|
||||
|
||||
bool hasOption(const std::string& name, bool matchShort = false) const;
|
||||
/// Returns a true iff an option with the given name exists.
|
||||
///
|
||||
/// The given name can either be a fully specified short name,
|
||||
/// or a partially specified full name. If a partial name
|
||||
/// matches more than one full name, false is returned.
|
||||
/// The name must either match the short or full name of an
|
||||
/// option. Comparison case sensitive for the short name and
|
||||
/// not case sensitive for the full name.
|
||||
|
||||
const Option& getOption(const std::string& name, bool matchShort = false) const;
|
||||
/// Returns a reference to the option with the given name.
|
||||
///
|
||||
/// The given name can either be a fully specified short name,
|
||||
/// or a partially specified full name.
|
||||
/// The name must either match the short or full name of an
|
||||
/// option. Comparison case sensitive for the short name and
|
||||
/// not case sensitive for the full name.
|
||||
/// Throws a NotFoundException if no matching option has been found.
|
||||
/// Throws an UnknownOptionException if a partial full name matches
|
||||
/// more than one option.
|
||||
|
||||
Iterator begin() const;
|
||||
/// Supports iterating over all options.
|
||||
|
||||
Iterator end() const;
|
||||
/// Supports iterating over all options.
|
||||
|
||||
private:
|
||||
OptionVec _options;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_OptionSet_INCLUDED
|
99
vendor/POCO/Util/include/Poco/Util/PropertyFileConfiguration.h
vendored
Normal file
99
vendor/POCO/Util/include/Poco/Util/PropertyFileConfiguration.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// PropertyFileConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: PropertyFileConfiguration
|
||||
//
|
||||
// Definition of the PropertyFileConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_PropertyFileConfiguration_INCLUDED
|
||||
#define Util_PropertyFileConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/MapConfiguration.h"
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API PropertyFileConfiguration: public MapConfiguration
|
||||
/// This implementation of a Configuration reads properties
|
||||
/// from a Java-style properties file.
|
||||
///
|
||||
/// The file syntax is implemented as follows.
|
||||
/// - a line starting with a hash '#' or exclamation mark '!' is treated as a comment and ignored
|
||||
/// - every other line denotes a property assignment in the form
|
||||
/// <key> = <value> or
|
||||
/// <key> : <value>
|
||||
///
|
||||
/// Keys and values may contain special characters represented by the following escape sequences:
|
||||
/// - \t: tab (0x09)
|
||||
/// - \n: line feed (0x0a)
|
||||
/// - \r: carriage return (0x0d)
|
||||
/// - \f: form feed (0x0c)
|
||||
///
|
||||
/// For every other sequence that starts with a backslash, the backslash is removed.
|
||||
/// Therefore, the sequence \a would just yield an 'a'.
|
||||
///
|
||||
/// A value can spread across multiple lines if the last character in a line (the character
|
||||
/// immediately before the carriage return or line feed character) is a single backslash.
|
||||
///
|
||||
/// Property names are case sensitive. Leading and trailing whitespace is
|
||||
/// removed from both keys and values. A property name can neither contain
|
||||
/// a colon ':' nor an equal sign '=' character.
|
||||
{
|
||||
public:
|
||||
PropertyFileConfiguration();
|
||||
/// Creates an empty PropertyFileConfiguration.
|
||||
|
||||
PropertyFileConfiguration(std::istream& istr);
|
||||
/// Creates an PropertyFileConfiguration and loads the configuration data
|
||||
/// from the given stream, which must be in properties file format.
|
||||
|
||||
PropertyFileConfiguration(const std::string& path);
|
||||
/// Creates an PropertyFileConfiguration and loads the configuration data
|
||||
/// from the given file, which must be in properties file format.
|
||||
|
||||
void load(std::istream& istr);
|
||||
/// Loads the configuration data from the given stream, which
|
||||
/// must be in properties file format.
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the configuration data from the given file, which
|
||||
/// must be in properties file format.
|
||||
|
||||
void save(std::ostream& ostr) const;
|
||||
/// Writes the configuration data to the given stream.
|
||||
///
|
||||
/// The data is written as a sequence of statements in the form
|
||||
/// <key>: <value>
|
||||
/// separated by a newline character.
|
||||
|
||||
void save(const std::string& path) const;
|
||||
/// Writes the configuration data to the given file.
|
||||
|
||||
protected:
|
||||
~PropertyFileConfiguration();
|
||||
|
||||
private:
|
||||
void parseLine(std::istream& istr);
|
||||
static int readChar(std::istream& istr);
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_PropertyFileConfiguration_INCLUDED
|
54
vendor/POCO/Util/include/Poco/Util/RegExpValidator.h
vendored
Normal file
54
vendor/POCO/Util/include/Poco/Util/RegExpValidator.h
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
//
|
||||
// RegExpValidator.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: RegExpValidator
|
||||
//
|
||||
// Definition of the RegExpValidator class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_RegExpValidator_INCLUDED
|
||||
#define Util_RegExpValidator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Validator.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API RegExpValidator: public Validator
|
||||
/// This validator matches the option value against
|
||||
/// a regular expression.
|
||||
{
|
||||
public:
|
||||
RegExpValidator(const std::string& regexp);
|
||||
/// Creates the RegExpValidator, using the given regular expression.
|
||||
|
||||
~RegExpValidator();
|
||||
/// Destroys the RegExpValidator.
|
||||
|
||||
void validate(const Option& option, const std::string& value);
|
||||
/// Validates the value for the given option by
|
||||
/// matching it with the regular expression.
|
||||
|
||||
private:
|
||||
RegExpValidator();
|
||||
|
||||
std::string _regexp;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_RegExpValidator_INCLUDED
|
282
vendor/POCO/Util/include/Poco/Util/ServerApplication.h
vendored
Normal file
282
vendor/POCO/Util/include/Poco/Util/ServerApplication.h
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
//
|
||||
// ServerApplication.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
// Module: ServerApplication
|
||||
//
|
||||
// Definition of the ServerApplication class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_ServerApplication_INCLUDED
|
||||
#define Util_ServerApplication_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Poco/Event.h"
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#include "Poco/NamedEvent.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API ServerApplication: public Application
|
||||
/// A subclass of the Application class that is used
|
||||
/// for implementing server applications.
|
||||
///
|
||||
/// A ServerApplication allows for the application
|
||||
/// to run as a Windows service or as a Unix daemon
|
||||
/// without the need to add extra code.
|
||||
///
|
||||
/// For a ServerApplication to work both from the command line
|
||||
/// and as a daemon or service, a few rules must be met:
|
||||
/// - Subsystems must be registered in the constructor.
|
||||
/// - All non-trivial initializations must be made in the
|
||||
/// initialize() method.
|
||||
/// - At the end of the main() method, waitForTerminationRequest()
|
||||
/// should be called.
|
||||
/// - New threads must only be created in initialize() or main() or
|
||||
/// methods called from there, but not in the application class'
|
||||
/// constructor or in the constructor of instance variables.
|
||||
/// The reason for this is that fork() will be called in order to
|
||||
/// create the daemon process, and threads created prior to calling
|
||||
/// fork() won't be taken over to the daemon process.
|
||||
/// - The main(argc, argv) function must look as follows:
|
||||
///
|
||||
/// int main(int argc, char** argv)
|
||||
/// {
|
||||
/// MyServerApplication app;
|
||||
/// return app.run(argc, argv);
|
||||
/// }
|
||||
///
|
||||
/// The POCO_SERVER_MAIN macro can be used to implement main(argc, argv).
|
||||
/// POCO_SERVER_MAIN supports Unicode command line arguments.
|
||||
///
|
||||
/// On Windows platforms, an application built on top of the
|
||||
/// ServerApplication class can be run both from the command line
|
||||
/// or as a service.
|
||||
///
|
||||
/// To run an application as a Windows service, it must be registered
|
||||
/// with the Windows Service Control Manager (SCM). To do this, the application
|
||||
/// can be started from the command line, with the /registerService option
|
||||
/// specified. This causes the application to register itself with the
|
||||
/// SCM, and then exit. Similarly, an application registered as a service can
|
||||
/// be unregistered, by specifying the /unregisterService option.
|
||||
/// The file name of the application executable (excluding the .exe suffix)
|
||||
/// is used as the service name. Additionally, a more user-friendly name can be
|
||||
/// specified, using the /displayName option (e.g., /displayName="Demo Service")
|
||||
/// and a service description can be added with the /description option.
|
||||
/// The startup mode (automatic or manual) for the service can be specified
|
||||
/// with the /startup option.
|
||||
///
|
||||
/// An application can determine whether it is running as a service by checking
|
||||
/// for the "application.runAsService" configuration property.
|
||||
///
|
||||
/// if (config().getBool("application.runAsService", false))
|
||||
/// {
|
||||
/// // do service specific things
|
||||
/// }
|
||||
///
|
||||
/// Note that the working directory for an application running as a service
|
||||
/// is the Windows system directory (e.g., C:\Windows\system32). Take this
|
||||
/// into account when working with relative filesystem paths. Also, services
|
||||
/// run under a different user account, so an application that works when
|
||||
/// started from the command line may fail to run as a service if it depends
|
||||
/// on a certain environment (e.g., the PATH environment variable).
|
||||
///
|
||||
/// An application registered as a Windows service can be started
|
||||
/// with the NET START <name> command and stopped with the NET STOP <name>
|
||||
/// command. Alternatively, the Services MMC applet can be used.
|
||||
///
|
||||
/// On Unix platforms, an application built on top of the ServerApplication
|
||||
/// class can be optionally run as a daemon by giving the --daemon
|
||||
/// command line option. A daemon, when launched, immediately
|
||||
/// forks off a background process that does the actual work. After launching
|
||||
/// the background process, the foreground process exits.
|
||||
///
|
||||
/// After the initialization is complete, but before entering the main() method,
|
||||
/// the current working directory for the daemon process is changed to the root
|
||||
/// directory ("/"), as it is common practice for daemon processes. Therefore, be
|
||||
/// careful when working with files, as relative paths may not point to where
|
||||
/// you expect them point to.
|
||||
///
|
||||
/// An application can determine whether it is running as a daemon by checking
|
||||
/// for the "application.runAsDaemon" configuration property.
|
||||
///
|
||||
/// if (config().getBool("application.runAsDaemon", false))
|
||||
/// {
|
||||
/// // do daemon specific things
|
||||
/// }
|
||||
///
|
||||
/// When running as a daemon, specifying the --pidfile option (e.g.,
|
||||
/// --pidfile=/var/run/sample.pid) may be useful to record the process ID of
|
||||
/// the daemon in a file. The PID file will be removed when the daemon process
|
||||
/// terminates (but not, if it crashes).
|
||||
{
|
||||
public:
|
||||
ServerApplication();
|
||||
/// Creates the ServerApplication.
|
||||
|
||||
~ServerApplication();
|
||||
/// Destroys the ServerApplication.
|
||||
|
||||
bool isInteractive() const;
|
||||
/// Returns true if the application runs from the command line.
|
||||
/// Returns false if the application runs as a Unix daemon
|
||||
/// or Windows service.
|
||||
|
||||
int run(int argc, char** argv);
|
||||
/// Runs the application by performing additional initializations
|
||||
/// and calling the main() method.
|
||||
|
||||
int run(const std::vector<std::string>& args);
|
||||
/// Runs the application by performing additional initializations
|
||||
/// and calling the main() method.
|
||||
|
||||
#if defined(_WIN32)
|
||||
int run(int argc, wchar_t** argv);
|
||||
/// Runs the application by performing additional initializations
|
||||
/// and calling the main() method.
|
||||
///
|
||||
/// This Windows-specific version of init is used for passing
|
||||
/// Unicode command line arguments from wmain().
|
||||
#endif
|
||||
|
||||
static void terminate();
|
||||
/// Sends a friendly termination request to the application.
|
||||
/// If the application's main thread is waiting in
|
||||
/// waitForTerminationRequest(), this method will return
|
||||
/// and the application can shut down.
|
||||
|
||||
protected:
|
||||
int run();
|
||||
void waitForTerminationRequest();
|
||||
#if !defined(_WIN32_WCE)
|
||||
void defineOptions(OptionSet& options);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if defined(POCO_VXWORKS)
|
||||
static Poco::Event _terminate;
|
||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||
void handleDaemon(const std::string& name, const std::string& value);
|
||||
void handleUMask(const std::string& name, const std::string& value);
|
||||
void handlePidFile(const std::string& name, const std::string& value);
|
||||
bool isDaemon(int argc, char** argv);
|
||||
void beDaemon();
|
||||
#if POCO_OS == POCO_OS_ANDROID
|
||||
static Poco::Event _terminate;
|
||||
#endif
|
||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||
#if !defined(_WIN32_WCE)
|
||||
enum Action
|
||||
{
|
||||
SRV_RUN,
|
||||
SRV_REGISTER,
|
||||
SRV_UNREGISTER
|
||||
};
|
||||
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
|
||||
static void __stdcall ServiceControlHandler(DWORD control);
|
||||
static void __stdcall ServiceMain(DWORD argc, LPWSTR* argv);
|
||||
|
||||
bool hasConsole();
|
||||
bool isService();
|
||||
void beService();
|
||||
void registerService();
|
||||
void unregisterService();
|
||||
void handleRegisterService(const std::string& name, const std::string& value);
|
||||
void handleUnregisterService(const std::string& name, const std::string& value);
|
||||
void handleDisplayName(const std::string& name, const std::string& value);
|
||||
void handleDescription(const std::string& name, const std::string& value);
|
||||
void handleStartup(const std::string& name, const std::string& value);
|
||||
|
||||
Action _action;
|
||||
std::string _displayName;
|
||||
std::string _description;
|
||||
std::string _startup;
|
||||
|
||||
static Poco::Event _terminated;
|
||||
static SERVICE_STATUS _serviceStatus;
|
||||
static SERVICE_STATUS_HANDLE _serviceStatusHandle;
|
||||
#endif // _WIN32_WCE
|
||||
static Poco::NamedEvent _terminate;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
//
|
||||
// Macro to implement main()
|
||||
//
|
||||
#if defined(_WIN32)
|
||||
#define POCO_SERVER_MAIN(App) \
|
||||
int wmain(int argc, wchar_t** argv) \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
App app; \
|
||||
return app.run(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
std::cerr << exc.displayText() << std::endl; \
|
||||
return Poco::Util::Application::EXIT_SOFTWARE; \
|
||||
} \
|
||||
}
|
||||
#elif defined(POCO_VXWORKS)
|
||||
#define POCO_SERVER_MAIN(App) \
|
||||
int pocoSrvMain(const char* appName, ...) \
|
||||
{ \
|
||||
std::vector<std::string> args; \
|
||||
args.push_back(std::string(appName)); \
|
||||
va_list vargs; \
|
||||
va_start(vargs, appName); \
|
||||
const char* arg = va_arg(vargs, const char*); \
|
||||
while (arg) \
|
||||
{ \
|
||||
args.push_back(std::string(arg)); \
|
||||
arg = va_arg(vargs, const char*); \
|
||||
} \
|
||||
va_end(vargs); \
|
||||
try \
|
||||
{ \
|
||||
App app; \
|
||||
return app.run(args); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
std::cerr << exc.displayText() << std::endl; \
|
||||
return Poco::Util::Application::EXIT_SOFTWARE; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define POCO_SERVER_MAIN(App) \
|
||||
int main(int argc, char** argv) \
|
||||
{ \
|
||||
try \
|
||||
{ \
|
||||
App app; \
|
||||
return app.run(argc, argv); \
|
||||
} \
|
||||
catch (Poco::Exception& exc) \
|
||||
{ \
|
||||
std::cerr << exc.displayText() << std::endl; \
|
||||
return Poco::Util::Application::EXIT_SOFTWARE; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Util_ServerApplication_INCLUDED
|
98
vendor/POCO/Util/include/Poco/Util/Subsystem.h
vendored
Normal file
98
vendor/POCO/Util/include/Poco/Util/Subsystem.h
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// Subsystem.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Application
|
||||
// Module: Subsystem
|
||||
//
|
||||
// Definition of the Subsystem class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Subsystem_INCLUDED
|
||||
#define Util_Subsystem_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Application;
|
||||
class OptionSet;
|
||||
|
||||
|
||||
class Util_API Subsystem: public Poco::RefCountedObject
|
||||
/// Subsystems extend an application in a modular way.
|
||||
///
|
||||
/// The Subsystem class provides a common interface
|
||||
/// for subsystems so that subsystems can be automatically
|
||||
/// initialized at startup and uninitialized at shutdown.
|
||||
///
|
||||
/// Subsystems should also support dynamic reconfiguration,
|
||||
/// so that they can be reconfigured anytime during the
|
||||
/// life of a running application.
|
||||
///
|
||||
/// The degree to which dynamic reconfiguration is supported
|
||||
/// is up to the actual subsystem implementation. It can
|
||||
/// range from ignoring the reconfiguration request (not
|
||||
/// recommended), to changing certain settings that affect
|
||||
/// the performance, to a complete reinitialization.
|
||||
{
|
||||
public:
|
||||
Subsystem();
|
||||
/// Creates the Subsystem.
|
||||
|
||||
virtual const char* name() const = 0;
|
||||
/// Returns the name of the subsystem.
|
||||
/// Must be implemented by subclasses.
|
||||
|
||||
protected:
|
||||
virtual void initialize(Application& app) = 0;
|
||||
/// Initializes the subsystem.
|
||||
|
||||
virtual void uninitialize() = 0;
|
||||
/// Uninitializes the subsystem.
|
||||
|
||||
virtual void reinitialize(Application& app);
|
||||
/// Re-initializes the subsystem.
|
||||
///
|
||||
/// The default implementation just calls
|
||||
/// uninitialize() followed by initialize().
|
||||
/// Actual implementations might want to use a
|
||||
/// less radical and possibly more performant
|
||||
/// approach.
|
||||
|
||||
virtual void defineOptions(OptionSet& options);
|
||||
/// Called before the Application's command line processing begins.
|
||||
/// If a subsystem wants to support command line arguments,
|
||||
/// it must override this method.
|
||||
/// The default implementation does not define any options.
|
||||
///
|
||||
/// To effectively handle options, a subsystem should either bind
|
||||
/// the option to a configuration property or specify a callback
|
||||
/// to handle the option.
|
||||
|
||||
virtual ~Subsystem();
|
||||
/// Destroys the Subsystem.
|
||||
|
||||
friend class Application;
|
||||
|
||||
private:
|
||||
Subsystem(const Subsystem&);
|
||||
Subsystem& operator = (const Subsystem&);
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_Subsystem_INCLUDED
|
99
vendor/POCO/Util/include/Poco/Util/SystemConfiguration.h
vendored
Normal file
99
vendor/POCO/Util/include/Poco/Util/SystemConfiguration.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// SystemConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: SystemConfiguration
|
||||
//
|
||||
// Definition of the SystemConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_SystemConfiguration_INCLUDED
|
||||
#define Util_SystemConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API SystemConfiguration: public AbstractConfiguration
|
||||
/// This class implements a Configuration interface to
|
||||
/// various system properties and environment variables.
|
||||
///
|
||||
/// The following properties are supported:
|
||||
/// - system.osName: the operating system name
|
||||
/// - system.osVersion: the operating system version
|
||||
/// - system.osArchitecture: the operating system architecture
|
||||
/// - system.nodeName: the node (or host) name
|
||||
/// - system.nodeId: system ID, based on the Ethernet address (format "xxxxxxxxxxxx")
|
||||
/// of the first Ethernet adapter found on the system.
|
||||
/// - system.currentDir: the current working directory
|
||||
/// - system.homeDir: the user's home directory
|
||||
/// - system.configHomeDir: the base directory relative to which user specific configuration files should be stored
|
||||
/// - system.cacheHomeDir: the base directory relative to which user specific non-essential data files should be stored
|
||||
/// - system.dataHomeDir: the base directory relative to which user specific data files should be stored
|
||||
/// - system.tempHomeDir: the base directory relative to which user-specific temporary files and other file objects should be placed
|
||||
/// - system.tempDir: the system's temporary directory
|
||||
/// - system.configDir: the system's configuration directory
|
||||
/// - system.dateTime: the current UTC date and time, formatted in ISO 8601 format.
|
||||
/// - system.pid: the current process ID.
|
||||
/// - system.env.<NAME>: the environment variable with the given <NAME>.
|
||||
///
|
||||
/// An attempt to set a system variable will result in an
|
||||
/// InvalidAccessException being thrown.
|
||||
///
|
||||
/// Enumerating environment variables is not supported.
|
||||
/// An attempt to call keys("system.env") will return an empty range.
|
||||
///
|
||||
/// Removing key is not supported. An attempt to remove a key results
|
||||
/// in a NotImplementedException being thrown.
|
||||
{
|
||||
public:
|
||||
SystemConfiguration();
|
||||
/// Creates the SystemConfiguration.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
~SystemConfiguration();
|
||||
|
||||
private:
|
||||
static bool getEnv(const std::string& name, std::string& value);
|
||||
|
||||
static const std::string OSNAME;
|
||||
static const std::string OSVERSION;
|
||||
static const std::string OSARCHITECTURE;
|
||||
static const std::string NODENAME;
|
||||
static const std::string NODEID;
|
||||
static const std::string CURRENTDIR;
|
||||
static const std::string HOMEDIR;
|
||||
static const std::string CONFIGHOMEDIR;
|
||||
static const std::string CACHEHOMEDIR;
|
||||
static const std::string DATAHOMEDIR;
|
||||
static const std::string TEMPHOMEDIR;
|
||||
static const std::string TEMPDIR;
|
||||
static const std::string CONFIGDIR;
|
||||
static const std::string DATETIME;
|
||||
#if !defined(POCO_VXWORKS)
|
||||
static const std::string PID;
|
||||
#endif
|
||||
static const std::string ENV;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_SystemConfiguration_INCLUDED
|
194
vendor/POCO/Util/include/Poco/Util/Timer.h
vendored
Normal file
194
vendor/POCO/Util/include/Poco/Util/Timer.h
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
//
|
||||
// Timer.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Timer
|
||||
// Module: Timer
|
||||
//
|
||||
// Definition of the Timer class.
|
||||
//
|
||||
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Timer_INCLUDED
|
||||
#define Util_Timer_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/TimerTask.h"
|
||||
#include "Poco/TimedNotificationQueue.h"
|
||||
#include "Poco/Thread.h"
|
||||
#include "Poco/Runnable.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API Timer: protected Poco::Runnable
|
||||
/// A Timer allows to schedule tasks (TimerTask objects) for future execution
|
||||
/// in a background thread. Tasks may be scheduled for one-time execution,
|
||||
/// or for repeated execution at regular intervals.
|
||||
///
|
||||
/// The Timer object creates a thread that executes all scheduled tasks
|
||||
/// sequentially. Therefore, tasks should complete their work as quickly
|
||||
/// as possible, otherwise subsequent tasks may be delayed.
|
||||
///
|
||||
/// Timer is safe for multithreaded use - multiple threads can schedule
|
||||
/// new tasks simultaneously.
|
||||
///
|
||||
/// Via the func() helper function template, a functor or
|
||||
/// lambda can be used as timer task:
|
||||
///
|
||||
/// timer.schedule(Timer::func([]()
|
||||
/// {
|
||||
/// std::cout << "Timer!\n";
|
||||
/// }),
|
||||
/// Poco::Clock());
|
||||
///
|
||||
/// Acknowledgement: The interface of this class has been inspired by
|
||||
/// the java.util.Timer class from Java 1.3.
|
||||
{
|
||||
public:
|
||||
Timer();
|
||||
/// Creates the Timer.
|
||||
|
||||
explicit Timer(Poco::Thread::Priority priority);
|
||||
/// Creates the Timer, using a timer thread with
|
||||
/// the given priority.
|
||||
|
||||
~Timer();
|
||||
/// Destroys the Timer, cancelling all pending tasks.
|
||||
|
||||
void cancel(bool wait = false);
|
||||
/// Cancels all pending tasks.
|
||||
///
|
||||
/// If a task is currently running, it is allowed to finish.
|
||||
///
|
||||
/// Task cancellation is done asynchronously. If wait
|
||||
/// is false, cancel() returns immediately and the
|
||||
/// task queue will be purged as soon as the currently
|
||||
/// running task finishes. If wait is true, waits
|
||||
/// until the queue has been purged.
|
||||
|
||||
void schedule(TimerTask::Ptr pTask, Poco::Timestamp time);
|
||||
/// Schedules a task for execution at the specified time.
|
||||
///
|
||||
/// If the time lies in the past, the task is executed
|
||||
/// immediately.
|
||||
///
|
||||
/// Note: the relative time the task will be executed
|
||||
/// won't change if the system's time changes. If the
|
||||
/// given time is 10 seconds in the future at the point
|
||||
/// schedule() is called, the task will be executed 10
|
||||
/// seconds later, even if the system time changes in
|
||||
/// between.
|
||||
|
||||
void schedule(TimerTask::Ptr pTask, Poco::Clock clock);
|
||||
/// Schedules a task for execution at the specified time.
|
||||
///
|
||||
/// If the time lies in the past, the task is executed
|
||||
/// immediately.
|
||||
|
||||
void schedule(TimerTask::Ptr pTask, long delay, long interval);
|
||||
/// Schedules a task for periodic execution.
|
||||
///
|
||||
/// The task is first executed after the given delay.
|
||||
/// Subsequently, the task is executed periodically with
|
||||
/// the given interval in milliseconds between invocations.
|
||||
|
||||
void schedule(TimerTask::Ptr pTask, Poco::Timestamp time, long interval);
|
||||
/// Schedules a task for periodic execution.
|
||||
///
|
||||
/// The task is first executed at the given time.
|
||||
/// Subsequently, the task is executed periodically with
|
||||
/// the given interval in milliseconds between invocations.
|
||||
///
|
||||
/// Note: the relative time the task will be executed
|
||||
/// won't change if the system's time changes. If the
|
||||
/// given time is 10 seconds in the future at the point
|
||||
/// schedule() is called, the task will be executed 10
|
||||
/// seconds later, even if the system time changes in
|
||||
/// between.
|
||||
|
||||
void schedule(TimerTask::Ptr pTask, Poco::Clock clock, long interval);
|
||||
/// Schedules a task for periodic execution.
|
||||
///
|
||||
/// The task is first executed at the given time.
|
||||
/// Subsequently, the task is executed periodically with
|
||||
/// the given interval in milliseconds between invocations.
|
||||
|
||||
void scheduleAtFixedRate(TimerTask::Ptr pTask, long delay, long interval);
|
||||
/// Schedules a task for periodic execution at a fixed rate.
|
||||
///
|
||||
/// The task is first executed after the given delay.
|
||||
/// Subsequently, the task is executed periodically
|
||||
/// every number of milliseconds specified by interval.
|
||||
///
|
||||
/// If task execution takes longer than the given interval,
|
||||
/// further executions are delayed.
|
||||
|
||||
void scheduleAtFixedRate(TimerTask::Ptr pTask, Poco::Timestamp time, long interval);
|
||||
/// Schedules a task for periodic execution at a fixed rate.
|
||||
///
|
||||
/// The task is first executed at the given time.
|
||||
/// Subsequently, the task is executed periodically
|
||||
/// every number of milliseconds specified by interval.
|
||||
///
|
||||
/// If task execution takes longer than the given interval,
|
||||
/// further executions are delayed.
|
||||
///
|
||||
/// Note: the relative time the task will be executed
|
||||
/// won't change if the system's time changes. If the
|
||||
/// given time is 10 seconds in the future at the point
|
||||
/// scheduleAtFixedRate() is called, the task will be executed 10
|
||||
/// seconds later, even if the system time changes in
|
||||
/// between.
|
||||
|
||||
void scheduleAtFixedRate(TimerTask::Ptr pTask, Poco::Clock clock, long interval);
|
||||
/// Schedules a task for periodic execution at a fixed rate.
|
||||
///
|
||||
/// The task is first executed at the given time.
|
||||
/// Subsequently, the task is executed periodically
|
||||
/// every number of milliseconds specified by interval.
|
||||
///
|
||||
/// If task execution takes longer than the given interval,
|
||||
/// further executions are delayed.
|
||||
|
||||
template <typename Fn>
|
||||
static TimerTask::Ptr func(const Fn& fn)
|
||||
/// Helper function template to use a functor or lambda
|
||||
/// with Timer::schedule() and Timer::scheduleAtFixedRate().
|
||||
{
|
||||
return new TimerFunc<Fn>(fn);
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
static TimerTask::Ptr func(Fn&& fn)
|
||||
/// Helper function template to use a functor or lambda
|
||||
/// with Timer::schedule() and Timer::scheduleAtFixedRate().
|
||||
{
|
||||
return new TimerFunc<Fn>(std::move(fn));
|
||||
}
|
||||
|
||||
protected:
|
||||
void run();
|
||||
static void validateTask(const TimerTask::Ptr& pTask);
|
||||
|
||||
private:
|
||||
Timer(const Timer&);
|
||||
Timer& operator = (const Timer&);
|
||||
|
||||
Poco::TimedNotificationQueue _queue;
|
||||
Poco::Thread _thread;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_Timer_INCLUDED
|
124
vendor/POCO/Util/include/Poco/Util/TimerTask.h
vendored
Normal file
124
vendor/POCO/Util/include/Poco/Util/TimerTask.h
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// TimerTask.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Timer
|
||||
// Module: TimerTask
|
||||
//
|
||||
// Definition of the TimerTask class.
|
||||
//
|
||||
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_TimerTask_INCLUDED
|
||||
#define Util_TimerTask_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Runnable.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include "Poco/Timestamp.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API TimerTask: public Poco::RefCountedObject, public Poco::Runnable
|
||||
/// A task that can be scheduled for one-time or
|
||||
/// repeated execution by a Timer.
|
||||
///
|
||||
/// This is an abstract class. Subclasses must override the run() member
|
||||
/// function to implement the actual task logic.
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::AutoPtr<TimerTask>;
|
||||
|
||||
TimerTask();
|
||||
/// Creates the TimerTask.
|
||||
|
||||
void cancel();
|
||||
/// Cancels the execution of the timer.
|
||||
/// If the task has been scheduled for one-time execution and has
|
||||
/// not yet run, or has not yet been scheduled, it will never run.
|
||||
/// If the task has been scheduled for repeated execution, it will never
|
||||
/// run again. If the task is running when this call occurs, the task
|
||||
/// will run to completion, but will never run again.
|
||||
///
|
||||
/// Warning: A TimerTask that has been cancelled must not be scheduled again.
|
||||
/// An attempt to do so results in a Poco::Util::IllegalStateException being thrown.
|
||||
|
||||
bool isCancelled() const;
|
||||
/// Returns true iff the TimerTask has been cancelled by a call
|
||||
/// to cancel().
|
||||
|
||||
Poco::Timestamp lastExecution() const;
|
||||
/// Returns the time of the last execution of the timer task.
|
||||
///
|
||||
/// Returns 0 if the timer has never been executed.
|
||||
|
||||
protected:
|
||||
~TimerTask();
|
||||
/// Destroys the TimerTask.
|
||||
|
||||
private:
|
||||
TimerTask(const TimerTask&);
|
||||
TimerTask& operator = (const TimerTask&);
|
||||
|
||||
Poco::Timestamp _lastExecution;
|
||||
bool _isCancelled;
|
||||
|
||||
friend class TaskNotification;
|
||||
};
|
||||
|
||||
|
||||
template <typename Fn>
|
||||
class TimerFunc: public TimerTask
|
||||
/// A simple adapter that allows using a functor or lambda
|
||||
/// with Poco::Util::Timer, used by timerFunc().
|
||||
{
|
||||
public:
|
||||
explicit TimerFunc(const Fn& fn):
|
||||
_fn(fn)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TimerFunc(Fn&& fn):
|
||||
_fn(std::move(fn))
|
||||
{
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
_fn();
|
||||
}
|
||||
|
||||
private:
|
||||
Fn _fn;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline bool TimerTask::isCancelled() const
|
||||
{
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::Timestamp TimerTask::lastExecution() const
|
||||
{
|
||||
return _lastExecution;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_TimerTask_INCLUDED
|
69
vendor/POCO/Util/include/Poco/Util/TimerTaskAdapter.h
vendored
Normal file
69
vendor/POCO/Util/include/Poco/Util/TimerTaskAdapter.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// TimerTaskAdapter.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Timer
|
||||
// Module: TimerTaskAdapter
|
||||
//
|
||||
// Definition of the TimerTaskAdapter class template.
|
||||
//
|
||||
// Copyright (c) 2009, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_TimerTaskAdapter_INCLUDED
|
||||
#define Util_TimerTaskAdapter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/TimerTask.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
template <class C>
|
||||
class TimerTaskAdapter: public TimerTask
|
||||
/// This class template simplifies the implementation
|
||||
/// of TimerTask objects by allowing a member function
|
||||
/// of an object to be called as task.
|
||||
{
|
||||
public:
|
||||
typedef void (C::*Callback)(TimerTask&);
|
||||
|
||||
TimerTaskAdapter(C& object, Callback method): _pObject(&object), _method(method)
|
||||
/// Creates the TimerTaskAdapter, using the given
|
||||
/// object and its member function as task target.
|
||||
///
|
||||
/// The member function must accept one argument,
|
||||
/// a reference to a TimerTask object.
|
||||
{
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
(_pObject->*_method)(*this);
|
||||
}
|
||||
|
||||
protected:
|
||||
~TimerTaskAdapter()
|
||||
/// Destroys the TimerTaskAdapter.
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
TimerTaskAdapter();
|
||||
|
||||
C* _pObject;
|
||||
Callback _method;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_TimerTaskAdapter_INCLUDED
|
1298
vendor/POCO/Util/include/Poco/Util/Units.h
vendored
Normal file
1298
vendor/POCO/Util/include/Poco/Util/Units.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
62
vendor/POCO/Util/include/Poco/Util/Util.h
vendored
Normal file
62
vendor/POCO/Util/include/Poco/Util/Util.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// Util.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Util
|
||||
// Module: Util
|
||||
//
|
||||
// Basic definitions for the Poco Util library.
|
||||
// This file must be the first file included by every other Util
|
||||
// header file.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Util_INCLUDED
|
||||
#define Util_Util_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
//
|
||||
// The following block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the Util_EXPORTS
|
||||
// symbol defined on the command line. this symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// Util_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
//
|
||||
#if defined(_WIN32) && defined(POCO_DLL)
|
||||
#if defined(Util_EXPORTS)
|
||||
#define Util_API __declspec(dllexport)
|
||||
#else
|
||||
#define Util_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Util_API)
|
||||
#if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4)
|
||||
#define Util_API __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define Util_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Automatically link Util library.
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Util_EXPORTS)
|
||||
#pragma comment(lib, "PocoUtil" POCO_LIB_SUFFIX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Util_Util_INCLUDED
|
57
vendor/POCO/Util/include/Poco/Util/Validator.h
vendored
Normal file
57
vendor/POCO/Util/include/Poco/Util/Validator.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Validator.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
// Module: Validator
|
||||
//
|
||||
// Definition of the Validator class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_Validator_INCLUDED
|
||||
#define Util_Validator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Option;
|
||||
|
||||
|
||||
class Util_API Validator: public Poco::RefCountedObject
|
||||
/// Validator specifies the interface for option validators.
|
||||
///
|
||||
/// Option validators provide a simple way for the automatic
|
||||
/// validation of command line argument values.
|
||||
{
|
||||
public:
|
||||
virtual void validate(const Option& option, const std::string& value) = 0;
|
||||
/// Validates the value for the given option.
|
||||
/// Does nothing if the value is valid.
|
||||
///
|
||||
/// Throws an OptionException otherwise.
|
||||
|
||||
protected:
|
||||
Validator();
|
||||
/// Creates the Validator.
|
||||
|
||||
virtual ~Validator();
|
||||
/// Destroys the Validator.
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_Validator_INCLUDED
|
71
vendor/POCO/Util/include/Poco/Util/WinRegistryConfiguration.h
vendored
Normal file
71
vendor/POCO/Util/include/Poco/Util/WinRegistryConfiguration.h
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// WinRegistryConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Windows
|
||||
// Module: WinRegistryConfiguration
|
||||
//
|
||||
// Definition of the WinRegistryConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_WinRegistryConfiguration_INCLUDED
|
||||
#define Util_WinRegistryConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/String.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API WinRegistryConfiguration: public AbstractConfiguration
|
||||
/// An implementation of AbstractConfiguration that stores configuration data
|
||||
/// in the Windows registry.
|
||||
///
|
||||
/// Removing key is not supported. An attempt to remove a key results
|
||||
/// in a NotImplementedException being thrown.
|
||||
{
|
||||
public:
|
||||
WinRegistryConfiguration(const std::string& rootPath, REGSAM extraSam = 0);
|
||||
/// Creates the WinRegistryConfiguration.
|
||||
/// The rootPath must start with one of the root key names
|
||||
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
|
||||
/// All further keys are relative to the root path and can be
|
||||
/// dot separated, e.g. the path MyService.ServiceName will be converted to
|
||||
/// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName.
|
||||
/// The extraSam parameter will be passed along to WinRegistryKey, to control
|
||||
/// registry virtualization for example.
|
||||
|
||||
protected:
|
||||
~WinRegistryConfiguration();
|
||||
/// Destroys the WinRegistryConfiguration.
|
||||
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
|
||||
std::string convertToRegFormat(const std::string& key, std::string& keyName) const;
|
||||
/// Takes a key in the format of A.B.C and converts it to
|
||||
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path
|
||||
|
||||
friend class WinConfigurationTest;
|
||||
private:
|
||||
std::string _rootPath;
|
||||
REGSAM _extraSam;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_WinRegistryConfiguration_INCLUDED
|
198
vendor/POCO/Util/include/Poco/Util/WinRegistryKey.h
vendored
Normal file
198
vendor/POCO/Util/include/Poco/Util/WinRegistryKey.h
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
//
|
||||
// WinRegistryKey.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Windows
|
||||
// Module: WinRegistryKey
|
||||
//
|
||||
// Definition of the WinRegistryKey class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_WinRegistryKey_INCLUDED
|
||||
#define Util_WinRegistryKey_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API WinRegistryKey
|
||||
/// This class implements a convenient interface to the
|
||||
/// Windows Registry.
|
||||
///
|
||||
/// This class is only available on Windows platforms.
|
||||
{
|
||||
public:
|
||||
using Keys = std::vector<std::string>;
|
||||
using Values = std::vector<std::string>;
|
||||
|
||||
enum Type
|
||||
{
|
||||
REGT_NONE = 0,
|
||||
REGT_STRING = 1,
|
||||
REGT_STRING_EXPAND = 2,
|
||||
REGT_BINARY = 3,
|
||||
REGT_DWORD = 4,
|
||||
REGT_DWORD_BIG_ENDIAN = 5,
|
||||
REGT_LINK = 6,
|
||||
REGT_MULTI_STRING = 7,
|
||||
REGT_RESOURCE_LIST = 8,
|
||||
REGT_FULL_RESOURCE_DESCRIPTOR = 9,
|
||||
REGT_RESOURCE_REQUIREMENTS_LIST = 10,
|
||||
REGT_QWORD = 11
|
||||
};
|
||||
|
||||
WinRegistryKey(const std::string& key, bool readOnly = false, REGSAM extraSam = 0);
|
||||
/// Creates the WinRegistryKey.
|
||||
///
|
||||
/// The key must start with one of the root key names
|
||||
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
|
||||
///
|
||||
/// If readOnly is true, then only read access to the registry
|
||||
/// is available and any attempt to write to the registry will
|
||||
/// result in an exception.
|
||||
///
|
||||
/// extraSam is used to pass extra flags (in addition to KEY_READ and KEY_WRITE)
|
||||
/// to the samDesired argument of RegOpenKeyEx() or RegCreateKeyEx().
|
||||
|
||||
WinRegistryKey(HKEY hRootKey, const std::string& subKey, bool readOnly = false, REGSAM extraSam = 0);
|
||||
/// Creates the WinRegistryKey.
|
||||
///
|
||||
/// If readOnly is true, then only read access to the registry
|
||||
/// is available and any attempt to write to the registry will
|
||||
/// result in an exception.
|
||||
///
|
||||
/// extraSam is used to pass extra flags (in addition to KEY_READ and KEY_WRITE)
|
||||
/// to the samDesired argument of RegOpenKeyEx() or RegCreateKeyEx().
|
||||
|
||||
~WinRegistryKey();
|
||||
/// Destroys the WinRegistryKey.
|
||||
|
||||
void setString(const std::string& name, const std::string& value);
|
||||
/// Sets the string value (REG_SZ) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
|
||||
std::string getString(const std::string& name);
|
||||
/// Returns the string value (REG_SZ) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
void setStringExpand(const std::string& name, const std::string& value);
|
||||
/// Sets the expandable string value (REG_EXPAND_SZ) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
|
||||
std::string getStringExpand(const std::string& name);
|
||||
/// Returns the string value (REG_EXPAND_SZ) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
/// All references to environment variables (%VAR%) in the string
|
||||
/// are expanded.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
void setBinary(const std::string& name, const std::vector<char>& value);
|
||||
/// Sets the string value (REG_BINARY) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
|
||||
std::vector<char> getBinary(const std::string& name);
|
||||
/// Returns the string value (REG_BINARY) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
void setInt(const std::string& name, int value);
|
||||
/// Sets the numeric (REG_DWORD) value with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
|
||||
int getInt(const std::string& name);
|
||||
/// Returns the numeric value (REG_DWORD) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
void setInt64(const std::string& name, Poco::Int64 value);
|
||||
/// Sets the numeric (REG_QWORD) value with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
|
||||
Poco::Int64 getInt64(const std::string& name);
|
||||
/// Returns the numeric value (REG_QWORD) with the given name.
|
||||
/// An empty name denotes the default value.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
#endif // POCO_HAVE_INT64
|
||||
|
||||
void deleteValue(const std::string& name);
|
||||
/// Deletes the value with the given name.
|
||||
///
|
||||
/// Throws a NotFoundException if the value does not exist.
|
||||
|
||||
void deleteKey();
|
||||
/// Recursively deletes the key and all subkeys.
|
||||
|
||||
bool exists();
|
||||
/// Returns true iff the key exists.
|
||||
|
||||
Type type(const std::string& name);
|
||||
/// Returns the type of the key value.
|
||||
|
||||
bool exists(const std::string& name);
|
||||
/// Returns true iff the given value exists under that key.
|
||||
|
||||
void subKeys(Keys& keys);
|
||||
/// Appends all subKey names to keys.
|
||||
|
||||
void values(Values& vals);
|
||||
/// Appends all value names to vals;
|
||||
|
||||
bool isReadOnly() const;
|
||||
/// Returns true iff the key has been opened for read-only access only.
|
||||
|
||||
protected:
|
||||
void open();
|
||||
void close();
|
||||
std::string key() const;
|
||||
std::string key(const std::string& valueName) const;
|
||||
HKEY handle();
|
||||
void handleSetError(const std::string& name);
|
||||
static HKEY handleFor(const std::string& rootKey);
|
||||
|
||||
private:
|
||||
WinRegistryKey();
|
||||
WinRegistryKey(const WinRegistryKey&);
|
||||
WinRegistryKey& operator = (const WinRegistryKey&);
|
||||
|
||||
HKEY _hRootKey;
|
||||
std::string _subKey;
|
||||
HKEY _hKey;
|
||||
bool _readOnly;
|
||||
REGSAM _extraSam;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline bool WinRegistryKey::isReadOnly() const
|
||||
{
|
||||
return _readOnly;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_WinRegistryKey_INCLUDED
|
173
vendor/POCO/Util/include/Poco/Util/WinService.h
vendored
Normal file
173
vendor/POCO/Util/include/Poco/Util/WinService.h
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// WinService.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Windows
|
||||
// Module: WinService
|
||||
//
|
||||
// Definition of the WinService class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_WinService_INCLUDED
|
||||
#define Util_WinService_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
#include "Poco/UnWindows.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
#define POCO_LPQUERY_SERVICE_CONFIG LPQUERY_SERVICE_CONFIGW
|
||||
#define POCO_LPSERVICE_FAILURE_ACTION LPSERVICE_FAILURE_ACTIONSW
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API WinService
|
||||
/// This class provides an object-oriented interface to
|
||||
/// the Windows Service Control Manager for registering,
|
||||
/// unregistering, configuring, starting and stopping
|
||||
/// services.
|
||||
///
|
||||
/// This class is only available on Windows platforms.
|
||||
{
|
||||
public:
|
||||
enum Startup
|
||||
{
|
||||
SVC_AUTO_START,
|
||||
SVC_MANUAL_START,
|
||||
SVC_DISABLED
|
||||
};
|
||||
|
||||
enum FailureActionType
|
||||
{
|
||||
SVC_NONE,
|
||||
SVC_REBOOT,
|
||||
SVC_RESTART,
|
||||
SVC_RUN_COMMAND
|
||||
};
|
||||
|
||||
struct FailureAction
|
||||
{
|
||||
FailureActionType type;
|
||||
int delay;
|
||||
};
|
||||
|
||||
using FailureActionVector = std::vector<FailureAction>;
|
||||
using FailureActionTypeVector = std::vector<FailureActionType>;
|
||||
|
||||
WinService(const std::string& name);
|
||||
/// Creates the WinService, using the given service name.
|
||||
|
||||
WinService(SC_HANDLE scmHandle, const std::string& name);
|
||||
/// Creates the WinService, using the given connection to
|
||||
/// a Windows Service Manager and the given service name.
|
||||
///
|
||||
/// The class will close the given scmHandle on destruction
|
||||
|
||||
~WinService();
|
||||
/// Destroys the WinService.
|
||||
|
||||
const std::string& name() const;
|
||||
/// Returns the service name.
|
||||
|
||||
std::string displayName() const;
|
||||
/// Returns the service's display name.
|
||||
|
||||
std::string path() const;
|
||||
/// Returns the path to the service executable.
|
||||
///
|
||||
/// Throws a NotFoundException if the service has not been registered.
|
||||
|
||||
void registerService(const std::string& path, const std::string& displayName);
|
||||
/// Creates a Windows service with the executable specified by path
|
||||
/// and the given displayName.
|
||||
///
|
||||
/// Throws a ExistsException if the service has already been registered.
|
||||
|
||||
void registerService(const std::string& path);
|
||||
/// Creates a Windows service with the executable specified by path
|
||||
/// and the given displayName. The service name is used as display name.
|
||||
///
|
||||
/// Throws a ExistsException if the service has already been registered.
|
||||
|
||||
void unregisterService();
|
||||
/// Deletes the Windows service.
|
||||
///
|
||||
/// Throws a NotFoundException if the service has not been registered.
|
||||
|
||||
bool isRegistered() const;
|
||||
/// Returns true if the service has been registered with the Service Control Manager.
|
||||
|
||||
bool isRunning() const;
|
||||
/// Returns true if the service is currently running.
|
||||
|
||||
bool isStopped() const;
|
||||
/// Returns true if the service is currently stopped.
|
||||
|
||||
void start();
|
||||
/// Starts the service.
|
||||
/// Does nothing if the service is already running.
|
||||
///
|
||||
/// Throws a NotFoundException if the service has not been registered.
|
||||
|
||||
void stop();
|
||||
/// Stops the service.
|
||||
/// Does nothing if the service is not running.
|
||||
///
|
||||
/// Throws a NotFoundException if the service has not been registered.
|
||||
|
||||
void setStartup(Startup startup);
|
||||
/// Sets the startup mode for the service.
|
||||
|
||||
Startup getStartup() const;
|
||||
/// Returns the startup mode for the service.
|
||||
|
||||
void setFailureActions(FailureActionVector failureActions, const std::string& command = "", const std::string& rebootMessage = "");
|
||||
/// Sets the Failure Actions for the service.
|
||||
/// If one of the Actions is SVC_RUN_COMMAND the command Parameter is added.
|
||||
/// If one of the Actions is SVC_REBOOT the Reboot Message is set.
|
||||
|
||||
FailureActionTypeVector getFailureActions() const;
|
||||
/// Returns the Failure Actions for the service.
|
||||
|
||||
void setDescription(const std::string& description);
|
||||
/// Sets the service description in the registry.
|
||||
|
||||
std::string getDescription() const;
|
||||
/// Returns the service description from the registry.
|
||||
|
||||
static const int STARTUP_TIMEOUT;
|
||||
|
||||
protected:
|
||||
static const std::string REGISTRY_KEY;
|
||||
static const std::string REGISTRY_DESCRIPTION;
|
||||
|
||||
private:
|
||||
void open() const;
|
||||
bool tryOpen() const;
|
||||
void close() const;
|
||||
POCO_LPQUERY_SERVICE_CONFIG config() const;
|
||||
|
||||
WinService();
|
||||
WinService(const WinService&);
|
||||
WinService& operator = (const WinService&);
|
||||
|
||||
std::string _name;
|
||||
SC_HANDLE _scmHandle;
|
||||
mutable SC_HANDLE _svcHandle;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // Util_WinService_INCLUDED
|
209
vendor/POCO/Util/include/Poco/Util/XMLConfiguration.h
vendored
Normal file
209
vendor/POCO/Util/include/Poco/Util/XMLConfiguration.h
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
//
|
||||
// XMLConfiguration.h
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: XMLConfiguration
|
||||
//
|
||||
// Definition of the XMLConfiguration class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef Util_XMLConfiguration_INCLUDED
|
||||
#define Util_XMLConfiguration_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Util/Util.h"
|
||||
|
||||
|
||||
#ifndef POCO_UTIL_NO_XMLCONFIGURATION
|
||||
|
||||
|
||||
#include "Poco/Util/MapConfiguration.h"
|
||||
#include "Poco/DOM/Document.h"
|
||||
#include "Poco/DOM/AutoPtr.h"
|
||||
#include "Poco/DOM/DOMWriter.h"
|
||||
#include "Poco/SAX/InputSource.h"
|
||||
#include <istream>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
class Util_API XMLConfiguration: public AbstractConfiguration
|
||||
/// This configuration class extracts configuration properties
|
||||
/// from an XML document. An XPath-like syntax for property
|
||||
/// names is supported to allow full access to the XML document.
|
||||
/// XML namespaces are not supported. The name of the root element
|
||||
/// of the XML document is not significant and ignored.
|
||||
/// Periods in tag names are not supported.
|
||||
///
|
||||
/// Given the following XML document as an example:
|
||||
///
|
||||
/// <config>
|
||||
/// <prop1>value1</prop1>
|
||||
/// <prop2>value2</prop2>
|
||||
/// <prop3>
|
||||
/// <prop4 attr="value3"/>
|
||||
/// <prop4 attr="value4"/>
|
||||
/// </prop3>
|
||||
/// <prop5 id="first">value5</prop5>
|
||||
/// <prop5 id="second">value6</prop5>
|
||||
/// </config>
|
||||
///
|
||||
/// The following property names would be valid and would
|
||||
/// yield the shown values:
|
||||
///
|
||||
/// prop1 -> value1
|
||||
/// prop2 -> value2
|
||||
/// prop3.prop4 -> (empty string)
|
||||
/// prop3.prop4[@attr] -> value3
|
||||
/// prop3.prop4[1][@attr] -> value4
|
||||
/// prop5[0] -> value5
|
||||
/// prop5[1] -> value6
|
||||
/// prop5[@id=first] -> value5
|
||||
/// prop5[@id='second'] -> value6
|
||||
///
|
||||
/// Enumerating attributes is not supported.
|
||||
/// Calling keys("prop3.prop4") will return an empty range.
|
||||
///
|
||||
/// As a special feature, the delimiter character used to delimit
|
||||
/// property names can be changed to something other than period ('.') by
|
||||
/// passing the desired character to the constructor. This allows
|
||||
/// working with XML documents having element names with periods
|
||||
/// in them.
|
||||
{
|
||||
public:
|
||||
XMLConfiguration();
|
||||
/// Creates an empty XMLConfiguration with a "config" root element.
|
||||
|
||||
XMLConfiguration(char delim);
|
||||
/// Creates an empty XMLConfiguration with a "config" root element,
|
||||
/// using the given delimiter char instead of the default '.'.
|
||||
|
||||
XMLConfiguration(Poco::XML::InputSource* pInputSource);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given InputSource.
|
||||
|
||||
XMLConfiguration(Poco::XML::InputSource* pInputSource, char delim);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given InputSource. Uses the given delimiter char instead
|
||||
/// of the default '.'.
|
||||
|
||||
XMLConfiguration(std::istream& istr);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given stream.
|
||||
|
||||
XMLConfiguration(std::istream& istr, char delim);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given stream. Uses the given delimiter char instead
|
||||
/// of the default '.'.
|
||||
|
||||
XMLConfiguration(const std::string& path);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given path.
|
||||
|
||||
XMLConfiguration(const std::string& path, char delim);
|
||||
/// Creates an XMLConfiguration and loads the XML document from
|
||||
/// the given path. Uses the given delimiter char instead
|
||||
/// of the default '.'.
|
||||
|
||||
XMLConfiguration(const Poco::XML::Document* pDocument);
|
||||
/// Creates the XMLConfiguration using the given XML document.
|
||||
|
||||
XMLConfiguration(const Poco::XML::Document* pDocument, char delim);
|
||||
/// Creates the XMLConfiguration using the given XML document.
|
||||
/// Uses the given delimiter char instead of the default '.'.
|
||||
|
||||
XMLConfiguration(const Poco::XML::Node* pNode);
|
||||
/// Creates the XMLConfiguration using the given XML node.
|
||||
|
||||
XMLConfiguration(const Poco::XML::Node* pNode, char delim);
|
||||
/// Creates the XMLConfiguration using the given XML node.
|
||||
/// Uses the given delimiter char instead of the default '.'.
|
||||
|
||||
void load(Poco::XML::InputSource* pInputSource);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given InputSource.
|
||||
|
||||
void load(Poco::XML::InputSource* pInputSource, unsigned long namePoolSize);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given InputSource. Uses the give namePoolSize (which
|
||||
/// should be a suitable prime like 251, 509, 1021, 4093) for the
|
||||
/// internal DOM Document's name pool.
|
||||
|
||||
void load(std::istream& istr);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given stream.
|
||||
|
||||
void load(const std::string& path);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given file.
|
||||
|
||||
void load(const Poco::XML::Document* pDocument);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given XML document.
|
||||
|
||||
void load(const Poco::XML::Node* pNode);
|
||||
/// Loads the XML document containing the configuration data
|
||||
/// from the given XML node.
|
||||
|
||||
void loadEmpty(const std::string& rootElementName);
|
||||
/// Loads an empty XML document containing only the
|
||||
/// root element with the given name.
|
||||
|
||||
void save(const std::string& path) const;
|
||||
/// Writes the XML document containing the configuration data
|
||||
/// to the file given by path.
|
||||
|
||||
void save(std::ostream& str) const;
|
||||
/// Writes the XML document containing the configuration data
|
||||
/// to the given stream.
|
||||
|
||||
void save(Poco::XML::DOMWriter& writer, const std::string& path) const;
|
||||
/// Writes the XML document containing the configuration data
|
||||
/// to the file given by path, using the given DOMWriter.
|
||||
///
|
||||
/// This can be used to use a DOMWriter with custom options.
|
||||
|
||||
void save(Poco::XML::DOMWriter& writer, std::ostream& str) const;
|
||||
/// Writes the XML document containing the configuration data
|
||||
/// to the given stream.
|
||||
///
|
||||
/// This can be used to use a DOMWriter with custom options.
|
||||
|
||||
protected:
|
||||
bool getRaw(const std::string& key, std::string& value) const;
|
||||
void setRaw(const std::string& key, const std::string& value);
|
||||
void enumerate(const std::string& key, Keys& range) const;
|
||||
void removeRaw(const std::string& key);
|
||||
~XMLConfiguration();
|
||||
|
||||
private:
|
||||
const Poco::XML::Node* findNode(const std::string& key) const;
|
||||
Poco::XML::Node* findNode(const std::string& key);
|
||||
Poco::XML::Node* findNode(std::string::const_iterator& it, const std::string::const_iterator& end, Poco::XML::Node* pNode, bool create = false) const;
|
||||
static Poco::XML::Node* findElement(const std::string& name, Poco::XML::Node* pNode, bool create);
|
||||
static Poco::XML::Node* findElement(int index, Poco::XML::Node* pNode, bool create);
|
||||
static Poco::XML::Node* findElement(const std::string& attr, const std::string& value, Poco::XML::Node* pNode);
|
||||
static Poco::XML::Node* findAttribute(const std::string& name, Poco::XML::Node* pNode, bool create);
|
||||
|
||||
Poco::XML::AutoPtr<Poco::XML::Node> _pRoot;
|
||||
Poco::XML::AutoPtr<Poco::XML::Document> _pDocument;
|
||||
char _delim;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
|
||||
|
||||
#endif // POCO_UTIL_NO_XMLCONFIGURATION
|
||||
|
||||
|
||||
#endif // Util_XMLConfiguration_INCLUDED
|
Reference in New Issue
Block a user