mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 04:17:55 +01:00
sources from main repository
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Option.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Util/src/Option.cpp#1 $
|
||||
// $Id: //poco/1.3/Util/src/Option.cpp#2 $
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Options
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Poco/Util/Option.h"
|
||||
#include "Poco/Util/OptionException.h"
|
||||
#include "Poco/Util/Validator.h"
|
||||
#include "Poco/Util/AbstractConfiguration.h"
|
||||
#include "Poco/String.h"
|
||||
#include <algorithm>
|
||||
|
||||
@@ -53,7 +54,8 @@ Option::Option():
|
||||
_repeatable(false),
|
||||
_argRequired(false),
|
||||
_pValidator(0),
|
||||
_pCallback(0)
|
||||
_pCallback(0),
|
||||
_pConfig(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,10 +71,12 @@ Option::Option(const Option& option):
|
||||
_group(option._group),
|
||||
_binding(option._binding),
|
||||
_pValidator(option._pValidator),
|
||||
_pCallback(option._pCallback)
|
||||
_pCallback(option._pCallback),
|
||||
_pConfig(option._pConfig)
|
||||
{
|
||||
if (_pValidator) _pValidator->duplicate();
|
||||
if (_pCallback) _pCallback = _pCallback->clone();
|
||||
if (_pConfig) _pConfig->duplicate();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +87,8 @@ Option::Option(const std::string& fullName, const std::string& shortName):
|
||||
_repeatable(false),
|
||||
_argRequired(false),
|
||||
_pValidator(0),
|
||||
_pCallback(0)
|
||||
_pCallback(0),
|
||||
_pConfig(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -96,7 +101,8 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
|
||||
_repeatable(false),
|
||||
_argRequired(false),
|
||||
_pValidator(0),
|
||||
_pCallback(0)
|
||||
_pCallback(0),
|
||||
_pConfig(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -110,7 +116,8 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
|
||||
_argName(argName),
|
||||
_argRequired(argOptional),
|
||||
_pValidator(0),
|
||||
_pCallback(0)
|
||||
_pCallback(0),
|
||||
_pConfig(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -118,6 +125,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
|
||||
Option::~Option()
|
||||
{
|
||||
if (_pValidator) _pValidator->release();
|
||||
if (_pConfig) _pConfig->release();
|
||||
delete _pCallback;
|
||||
}
|
||||
|
||||
@@ -146,6 +154,7 @@ void Option::swap(Option& option)
|
||||
std::swap(_binding, option._binding);
|
||||
std::swap(_pValidator, option._pValidator);
|
||||
std::swap(_pCallback, option._pCallback);
|
||||
std::swap(_pConfig, option._pConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +217,17 @@ Option& Option::group(const std::string& group)
|
||||
|
||||
|
||||
Option& Option::binding(const std::string& propertyName)
|
||||
{
|
||||
return binding(propertyName, 0);
|
||||
}
|
||||
|
||||
|
||||
Option& Option::binding(const std::string& propertyName, AbstractConfiguration* pConfig)
|
||||
{
|
||||
_binding = propertyName;
|
||||
if (_pConfig) _pConfig->release();
|
||||
_pConfig = pConfig;
|
||||
if (_pConfig) _pConfig->duplicate();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user