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

#include <ConfigAddress.h>

Inheritance diagram for net::in::config::ConfigAddress< ConfigAddressTypeT >:
Collaboration diagram for net::in::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)
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<net::in::SocketAddress>

Private Member Functions

SocketAddressinit () final

Private Attributes

CLI::Option * hostOpt = nullptr
CLI::Option * portOpt = nullptr
CLI::Option * numericOpt = nullptr
CLI::Option * numericReverseOpt = 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::in::config::ConfigAddress< ConfigAddressTypeT >

Definition at line 86 of file ConfigAddress.h.

Member Typedef Documentation

◆ Super

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

Definition at line 90 of file ConfigAddress.h.

Constructor & Destructor Documentation

◆ ConfigAddress()

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

Definition at line 108 of file ConfigAddress.cpp.

111 : ConfigSection(instance, this)
113 hostOpt = addOption( //
114 "--host",
115 "Host name or IPv4 address",
116 "hostname|IPv4",
117 "0.0.0.0",
119
120 portOpt = addOption( //
121 "--port",
122 "Port number",
123 "port",
124 0,
126
127 numericOpt = addFlag( //
128 "--numeric{true}",
129 "Suppress host name lookup",
130 "bool",
132 CLI::IsMember({"true", "false"}));
133
135 "--numeric-reverse{true}",
136 "Suppress reverse host name lookup",
137 "bool",
139 CLI::IsMember({"true", "false"}));
140 }
#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::in::config::ConfigAddress< ConfigAddressTypeT >::configurable ( bool configurable = true)
final

Definition at line 244 of file ConfigAddress.cpp.

244 {
247 }
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::in::config::ConfigAddress< ConfigAddressType >::getAiFlags ( ) const
protected

Definition at line 257 of file ConfigAddress.cpp.

257 {
258 return aiFlags;
259 }

References aiFlags.

◆ getAiProtocol()

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

Definition at line 281 of file ConfigAddress.cpp.

281 {
282 return aiProtocol;
283 }

References aiProtocol.

◆ getAiSockType()

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

Definition at line 269 of file ConfigAddress.cpp.

269 {
270 return aiSockType;
271 }

References aiSockType.

◆ getHost()

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

Definition at line 196 of file ConfigAddress.cpp.

196 {
197 return hostOpt->as<std::string>();
198 }

References hostOpt.

◆ getNumeric()

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

Definition at line 225 of file ConfigAddress.cpp.

225 {
226 return numericOpt->as<bool>();
227 }

References numericOpt.

◆ getNumericReverse()

template<template< typename SocketAddress > typename ConfigAddressType>
bool net::in::config::ConfigAddress< ConfigAddressType >::getNumericReverse ( ) const

Definition at line 239 of file ConfigAddress.cpp.

239 {
240 return numericReverseOpt->as<bool>();
241 }

References numericReverseOpt.

◆ getPort()

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

Definition at line 211 of file ConfigAddress.cpp.

211 {
212 return portOpt->as<uint16_t>();
213 }

References portOpt.

◆ getSocketAddress()

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

Definition at line 161 of file ConfigAddress.cpp.

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

Here is the call graph for this function:

◆ init()

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

Definition at line 143 of file ConfigAddress.cpp.

143 {
145
146 try {
147 socketAddress->init({.aiFlags = (aiFlags & ~AI_NUMERICHOST) | (numericOpt->as<bool>() ? AI_NUMERICHOST : 0),
148 .aiSockType = aiSockType,
149 .aiProtocol = aiProtocol});
151 delete socketAddress;
152 socketAddress = nullptr;
153
154 throw;
155 }
156
157 return socketAddress;
158 }
SocketAddress * init() final

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

Here is the call graph for this function:

◆ setAiFlags()

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

Definition at line 250 of file ConfigAddress.cpp.

250 {
251 this->aiFlags = aiFlags;
252
253 return *this;
254 }

References aiFlags.

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

Here is the caller graph for this function:

◆ setAiProtocol()

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

Definition at line 274 of file ConfigAddress.cpp.

274 {
275 this->aiProtocol = aiProtocol;
276
277 return *this;
278 }

References aiProtocol.

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

Here is the caller graph for this function:

◆ setAiSockType()

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

Definition at line 262 of file ConfigAddress.cpp.

262 {
263 this->aiSockType = aiSockType;
264
265 return *this;
266 }

References aiSockType.

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

Here is the caller graph for this function:

◆ setHost()

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

Definition at line 186 of file ConfigAddress.cpp.

186 {
188
190 required(hostOpt, false);
191
192 return *this;
193 }
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::in::config::ConfigAddress< ConfigAddressType >::setHostRequired ( bool required = true)
protected

Definition at line 286 of file ConfigAddress.cpp.

286 {
287 this->required(hostOpt, required);
288
289 return *this;
290 }

References hostOpt.

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

Here is the caller graph for this function:

◆ setNumeric()

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

Definition at line 216 of file ConfigAddress.cpp.

216 {
218
219 setDefaultValue(numericOpt, numeric ? "true" : "false");
220
221 return *this;
222 }

References numericOpt.

◆ setNumericReverse()

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

Definition at line 230 of file ConfigAddress.cpp.

230 {
232
233 setDefaultValue(numericReverseOpt, numeric ? "true" : "false");
234
235 return *this;
236 }

References numericReverseOpt.

◆ setPort()

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

Definition at line 201 of file ConfigAddress.cpp.

201 {
203
205 required(portOpt, false);
206
207 return *this;
208 }

References portOpt.

Referenced by setSocketAddress().

Here is the caller graph for this function:

◆ setPortRequired()

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

Definition at line 293 of file ConfigAddress.cpp.

293 {
294 this->required(portOpt, required);
295
296 return *this;
297 }

References portOpt.

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

Here is the caller graph for this function:

◆ setSocketAddress()

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

Definition at line 178 of file ConfigAddress.cpp.

178 {
181
182 return *this;
183 }
ConfigAddress & setHost(const std::string &ipOrHostname)
ConfigAddress & setPort(uint16_t port)

References net::in::SocketAddress::getHost(), net::in::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::in::config::ConfigAddress< ConfigAddressTypeT >::aiFlags = 0
private

Definition at line 139 of file ConfigAddress.h.

Referenced by getAiFlags(), and setAiFlags().

◆ aiProtocol

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

Definition at line 141 of file ConfigAddress.h.

Referenced by getAiProtocol(), and setAiProtocol().

◆ aiSockType

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

Definition at line 140 of file ConfigAddress.h.

Referenced by getAiSockType(), and setAiSockType().

◆ hostOpt

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

Definition at line 134 of file ConfigAddress.h.

Referenced by configurable(), getHost(), init(), setHost(), and setHostRequired().

◆ numericOpt

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

Definition at line 136 of file ConfigAddress.h.

Referenced by getNumeric(), and setNumeric().

◆ numericReverseOpt

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

Definition at line 137 of file ConfigAddress.h.

Referenced by getNumericReverse(), getSocketAddress(), and setNumericReverse().

◆ portOpt

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

Definition at line 135 of file ConfigAddress.h.

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


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