SNode.C
Loading...
Searching...
No Matches
net::in6::config::ConfigAddress< ConfigAddressTypeT > Class Template Reference

#include <ConfigAddress.h>

Inheritance diagram for net::in6::config::ConfigAddress< ConfigAddressTypeT >:
Collaboration diagram for net::in6::config::ConfigAddress< ConfigAddressTypeT >:

Public Member Functions

SocketAddress getSocketAddress (const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddresssetSocketAddress (const SocketAddress &socketAddress)
ConfigAddresssetHost (const std::string &ipOrHostname)
std::string getHost () const
ConfigAddresssetPort (uint16_t port)
uint16_t getPort () const
ConfigAddresssetNumeric (bool numeric=true)
bool getNumeric () const
ConfigAddresssetNumericReverse (bool numeric=true)
bool getNumericReverse () const
void configurable (bool configurable=true) final
Public Member Functions inherited from net::config::ConfigSection
template<typename T>
 ConfigSection (ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
 ~ConfigSection () override
 ConfigSection (const ConfigSection &)=delete
 ConfigSection (ConfigSection &&)=delete
ConfigSectionoperator= (const ConfigSection &)=delete
Public Member Functions inherited from utils::SubCommand
 SubCommand (const SubCommand &)=delete
 SubCommand (SubCommand &&)=delete
SubCommandoperator= (const SubCommand &)=delete
SubCommandoperator= (SubCommand &&)=delete
virtual ~SubCommand ()
std::string getName () const
std::string version () const
CLI::Option * setConfig (const std::string &defaultConfigFile) const
CLI::Option * setLogFile (const std::string &defaultLogFile) const
CLI::Option * setVersionFlag (const std::string &version) const
bool hasParent () const
SubCommandgetParent () const
SubCommandallowExtras (bool allow=true)
SubCommandrequired (bool required=true, bool force=true)
SubCommandrequired (SubCommand *subCommand, bool required=true)
SubCommandrequired (CLI::Option *option, bool required=true)
bool getRequired () const
SubCommandneeds (SubCommand *subCommand, bool needs=true)
SubCommanddisabled (SubCommand *subCommand, bool disabled=true)
SubCommandsetRequireCallback (const std::function< void(void)> &callback)
SubCommandfinalCallback (const std::function< void()> &finalCallback)
std::string configToStr () const
std::string help (const CLI::App *helpApp, const CLI::AppFormatMode &mode) const
template<typename NewSubCommand, typename... Args>
NewSubCommand * newSubCommand (Args &&... args)
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand ()
template<typename RequestedSubCommand>
RequestedSubCommand * getSubCommand () const
CLI::Option * getOption (const std::string &name) const
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOption (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, const CLI::Validator &additionalValidator) const
template<typename ValueTypeT>
CLI::Option * addOptionVariable (const std::string &name, ValueTypeT &variable, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &additionalValidator) const
CLI::Option * addOptionFunction (const std::string &name, const std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addOptionFunction (const std::string &name, const std::function< void(const std::string &)> &callback, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
template<typename ValueTypeT>
CLI::Option * addFlag (const std::string &name, const std::string &description, const std::string &typeName, ValueTypeT defaultValue, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
CLI::Option * addFlagFunction (const std::string &name, const std::function< void()> &callback, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator) const

Protected Member Functions

 ConfigAddress (net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddresssetIpv4Mapped (bool ipv4Mapped=true)
bool getIpv4Mapped () const
ConfigAddresssetAiFlags (int aiFlags)
int getAiFlags () const
ConfigAddresssetAiSockType (int aiSocktype)
int getAiSockType () const
ConfigAddresssetAiProtocol (int aiProtocol)
int getAiProtocol () const
ConfigAddresssetHostRequired (bool required=true)
ConfigAddresssetPortRequired (bool required=true)
Protected Member Functions inherited from utils::SubCommand
 SubCommand (SubCommand *parent, std::shared_ptr< utils::AppWithPtr > appWithPtr, const std::string &group, bool final)
template<typename ConcretSubCommand>
 SubCommand (SubCommand *parent, ConcretSubCommand *concretSubCommand, const std::string &group, bool final=true)
void parse (int argc, char *argv[]) const
SubCommanddescription (const std::string &description)
SubCommandfooter (const std::string &footer)
void removeSubCommand ()
template<typename ValueTypeT>
CLI::Option * setDefaultValue (CLI::Option *option, const ValueTypeT &value, bool clear=true) const
CLI::Option * setConfigurable (CLI::Option *option, bool configurable) const

Private Types

using Super = ConfigAddressTypeT<SocketAddress>

Private Member Functions

SocketAddressinit () final

Private Attributes

CLI::Option * hostOpt = nullptr
CLI::Option * portOpt = nullptr
CLI::Option * numericOpt = nullptr
CLI::Option * numericReverseOpt = nullptr
CLI::Option * ipv4MappedOpt = nullptr
int aiFlags = 0
int aiSockType = 0
int aiProtocol = 0

Additional Inherited Members

Static Protected Member Functions inherited from utils::SubCommand
static CLI::App * getHelpTriggerApp ()
static CLI::App * getShowConfigTriggerApp ()
static CLI::App * getCommandlineTriggerApp ()
Static Protected Attributes inherited from utils::SubCommand
static std::shared_ptr< CLI::Formatter > sectionFormatter = makeSectionFormatter()
static std::map< std::string, std::string > aliases
static CLI::App * helpTriggerApp = nullptr
static CLI::App * showConfigTriggerApp = nullptr
static CLI::App * commandlineTriggerApp = nullptr

Detailed Description

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
class net::in6::config::ConfigAddress< ConfigAddressTypeT >

Definition at line 88 of file ConfigAddress.h.

Member Typedef Documentation

◆ Super

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
using net::in6::config::ConfigAddress< ConfigAddressTypeT >::Super = ConfigAddressTypeT<SocketAddress>
private

Definition at line 92 of file ConfigAddress.h.

Constructor & Destructor Documentation

◆ ConfigAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
net::in6::config::ConfigAddress< ConfigAddressType >::ConfigAddress ( net::config::ConfigInstance * instance,
const std::string & addressOptionName,
const std::string & addressOptionDescription )
protected

Definition at line 108 of file ConfigAddress.cpp.

111 : ConfigSection(instance, this)
113 hostOpt = addOption( //
114 "--host",
115 "Host name or IPv6 address",
116 "hostname|IPv6",
117 "::",
119
120 portOpt = addOption( //
121 "--port",
122 "Port number",
123 "port",
124 0,
126
127 numericOpt = addFlag( //
128 "--numeric",
129 "Suppress host name lookup",
130 "bool",
132 CLI::IsMember({"true", "false"}));
133
135 "--numeric-reverse",
136 "Suppress reverse host name lookup",
137 "bool",
139 CLI::IsMember({"true", "false"}));
140
142 "--ipv4-mapped",
143 "Resolve IPv4-mapped IPv6 addresses also",
144 "bool",
146 CLI::IsMember({"true", "false"}));
147 }
#define XSTR(s)
ConfigSection(ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
CLI::Option * addOption(const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const
CLI::Option * addFlag(const std::string &name, const std::string &description, const std::string &typeName, const CLI::Validator &validator) const

Member Function Documentation

◆ configurable()

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
void net::in6::config::ConfigAddress< ConfigAddressTypeT >::configurable ( bool configurable = true)
final

Definition at line 237 of file ConfigAddress.cpp.

237 {
240 }
void configurable(bool configurable=true) final
CLI::Option * setConfigurable(CLI::Option *option, bool configurable) const

References hostOpt, and portOpt.

◆ getAiFlags()

template<template< typename SocketAddress > typename ConfigAddressType>
int net::in6::config::ConfigAddress< ConfigAddressType >::getAiFlags ( ) const
protected

Definition at line 273 of file ConfigAddress.cpp.

273 {
274 return aiFlags;
275 }

References aiFlags.

◆ getAiProtocol()

template<template< typename SocketAddress > typename ConfigAddressType>
int net::in6::config::ConfigAddress< ConfigAddressType >::getAiProtocol ( ) const
protected

Definition at line 297 of file ConfigAddress.cpp.

297 {
298 return aiProtocol;
299 }

References aiProtocol.

◆ getAiSockType()

template<template< typename SocketAddress > typename ConfigAddressType>
int net::in6::config::ConfigAddress< ConfigAddressType >::getAiSockType ( ) const
protected

Definition at line 285 of file ConfigAddress.cpp.

285 {
286 return aiSockType;
287 }

References aiSockType.

◆ getHost()

template<template< typename SocketAddress > typename ConfigAddressType>
std::string net::in6::config::ConfigAddress< ConfigAddressType >::getHost ( ) const

Definition at line 203 of file ConfigAddress.cpp.

203 {
204 return hostOpt->as<std::string>();
205 }

References hostOpt.

◆ getIpv4Mapped()

template<template< typename SocketAddress > typename ConfigAddressType>
bool net::in6::config::ConfigAddress< ConfigAddressType >::getIpv4Mapped ( ) const
protected

Definition at line 261 of file ConfigAddress.cpp.

261 {
262 return ipv4MappedOpt->as<bool>();
263 }

References ipv4MappedOpt.

◆ getNumeric()

template<template< typename SocketAddress > typename ConfigAddressType>
bool net::in6::config::ConfigAddress< ConfigAddressType >::getNumeric ( ) const

Definition at line 232 of file ConfigAddress.cpp.

232 {
233 return numericOpt->as<bool>();
234 }

References numericOpt.

◆ getNumericReverse()

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
bool net::in6::config::ConfigAddress< ConfigAddressTypeT >::getNumericReverse ( ) const

◆ getPort()

template<template< typename SocketAddress > typename ConfigAddressType>
uint16_t net::in6::config::ConfigAddress< ConfigAddressType >::getPort ( ) const

Definition at line 218 of file ConfigAddress.cpp.

218 {
219 return portOpt->as<uint16_t>();
220 }

References portOpt.

◆ getSocketAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
SocketAddress net::in6::config::ConfigAddress< ConfigAddressType >::getSocketAddress ( const SocketAddress::SockAddr & sockAddr,
SocketAddress::SockLen sockAddrLen )

Definition at line 168 of file ConfigAddress.cpp.

References numericReverseOpt, and net::in6::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ init()

template<template< typename SocketAddress > typename ConfigAddressType>
SocketAddress * net::in6::config::ConfigAddress< ConfigAddressType >::init ( )
finalprivate

Definition at line 150 of file ConfigAddress.cpp.

150 {
152
153 try {
154 socketAddress->init({.aiFlags = (aiFlags & ~AI_NUMERICHOST) | (numericOpt->as<bool>() ? AI_NUMERICHOST : 0),
155 .aiSockType = aiSockType,
156 .aiProtocol = aiProtocol});
158 delete socketAddress;
159 socketAddress = nullptr;
160
161 throw;
162 }
163
164 return socketAddress;
165 }
SocketAddress * init() final

References hostOpt, net::in6::SocketAddress::init(), portOpt, and net::in6::SocketAddress::SocketAddress().

Here is the call graph for this function:

◆ setAiFlags()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setAiFlags ( int aiFlags)
protected

Definition at line 266 of file ConfigAddress.cpp.

266 {
267 this->aiFlags = aiFlags;
268
269 return *this;
270 }

References aiFlags.

Referenced by net::in6::stream::config::ConfigSocketServer::ConfigSocketServer().

Here is the caller graph for this function:

◆ setAiProtocol()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setAiProtocol ( int aiProtocol)
protected

Definition at line 290 of file ConfigAddress.cpp.

290 {
291 this->aiProtocol = aiProtocol;
292
293 return *this;
294 }

References aiProtocol.

Referenced by net::in6::stream::config::ConfigSocketClient::ConfigSocketClient(), and net::in6::stream::config::ConfigSocketServer::ConfigSocketServer().

Here is the caller graph for this function:

◆ setAiSockType()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setAiSockType ( int aiSocktype)
protected

Definition at line 278 of file ConfigAddress.cpp.

278 {
279 this->aiSockType = aiSockType;
280
281 return *this;
282 }

References aiSockType.

Referenced by net::in6::stream::config::ConfigSocketClient::ConfigSocketClient(), and net::in6::stream::config::ConfigSocketServer::ConfigSocketServer().

Here is the caller graph for this function:

◆ setHost()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setHost ( const std::string & ipOrHostname)

Definition at line 193 of file ConfigAddress.cpp.

193 {
195
197 required(hostOpt, false);
198
199 return *this;
200 }
SubCommand * required(bool required=true, bool force=true)
CLI::Option * setDefaultValue(CLI::Option *option, const ValueTypeT &value, bool clear=true) const
Definition SubCommand.h:347

References hostOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setHostRequired()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setHostRequired ( bool required = true)
protected

Definition at line 302 of file ConfigAddress.cpp.

302 {
303 this->required(hostOpt, required);
304
305 return *this;
306 }

References hostOpt.

Referenced by net::in6::stream::config::ConfigSocketClient::ConfigSocketClient().

Here is the caller graph for this function:

◆ setIpv4Mapped()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setIpv4Mapped ( bool ipv4Mapped = true)
protected

Definition at line 252 of file ConfigAddress.cpp.

252 {
254
255 setDefaultValue(ipv4MappedOpt, ipv4Mapped ? "true" : "false");
256
257 return *this;
258 }

References ipv4MappedOpt.

◆ setNumeric()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setNumeric ( bool numeric = true)

Definition at line 223 of file ConfigAddress.cpp.

223 {
225
226 setDefaultValue(numericOpt, numeric ? "true" : "false");
227
228 return *this;
229 }

References numericOpt.

◆ setNumericReverse()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setNumericReverse ( bool numeric = true)

Definition at line 243 of file ConfigAddress.cpp.

243 {
245
246 setDefaultValue(numericReverseOpt, numeric ? "true" : "false");
247
248 return *this;
249 }

References numericReverseOpt.

◆ setPort()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setPort ( uint16_t port)

Definition at line 208 of file ConfigAddress.cpp.

208 {
210
212 required(portOpt, false);
213
214 return *this;
215 }

References portOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setPortRequired()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setPortRequired ( bool required = true)
protected

Definition at line 309 of file ConfigAddress.cpp.

309 {
310 this->required(portOpt, required);
311
312 return *this;
313 }

References portOpt.

Referenced by net::in6::stream::config::ConfigSocketClient::ConfigSocketClient(), and net::in6::stream::config::ConfigSocketServer::ConfigSocketServer().

Here is the caller graph for this function:

◆ setSocketAddress()

template<template< typename SocketAddress > typename ConfigAddressType>
ConfigAddress< ConfigAddressType > & net::in6::config::ConfigAddress< ConfigAddressType >::setSocketAddress ( const SocketAddress & socketAddress)

Definition at line 185 of file ConfigAddress.cpp.

185 {
188
189 return *this;
190 }
ConfigAddress & setPort(uint16_t port)
ConfigAddress & setHost(const std::string &ipOrHostname)

References net::in6::SocketAddress::getHost(), net::in6::SocketAddress::getPort(), setHost(), and setPort().

Here is the call graph for this function:

Member Data Documentation

◆ aiFlags

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
int net::in6::config::ConfigAddress< ConfigAddressTypeT >::aiFlags = 0
private

Definition at line 145 of file ConfigAddress.h.

Referenced by getAiFlags(), and setAiFlags().

◆ aiProtocol

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
int net::in6::config::ConfigAddress< ConfigAddressTypeT >::aiProtocol = 0
private

Definition at line 147 of file ConfigAddress.h.

Referenced by getAiProtocol(), and setAiProtocol().

◆ aiSockType

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
int net::in6::config::ConfigAddress< ConfigAddressTypeT >::aiSockType = 0
private

Definition at line 146 of file ConfigAddress.h.

Referenced by getAiSockType(), and setAiSockType().

◆ hostOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::in6::config::ConfigAddress< ConfigAddressTypeT >::hostOpt = nullptr
private

◆ ipv4MappedOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::in6::config::ConfigAddress< ConfigAddressTypeT >::ipv4MappedOpt = nullptr
private

Definition at line 143 of file ConfigAddress.h.

Referenced by getIpv4Mapped(), and setIpv4Mapped().

◆ numericOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::in6::config::ConfigAddress< ConfigAddressTypeT >::numericOpt = nullptr
private

Definition at line 141 of file ConfigAddress.h.

Referenced by getNumeric(), and setNumeric().

◆ numericReverseOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::in6::config::ConfigAddress< ConfigAddressTypeT >::numericReverseOpt = nullptr
private

Definition at line 142 of file ConfigAddress.h.

Referenced by getSocketAddress(), and setNumericReverse().

◆ portOpt

template<template< typename SocketAddressT > typename ConfigAddressTypeT>
CLI::Option* net::in6::config::ConfigAddress< ConfigAddressTypeT >::portOpt = nullptr
private

Definition at line 140 of file ConfigAddress.h.

Referenced by configurable(), getPort(), init(), setPort(), and setPortRequired().


The documentation for this class was generated from the following files: