InspIRCd  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ConfigTag Class Reference

#include <configreader.h>

Inheritance diagram for ConfigTag:
refcountbase

Public Member Functions

std::string getString (const std::string &key, const std::string &def="", size_t minlen=0, size_t maxlen=UINT32_MAX)
 
long getInt (const std::string &key, long def=0, long min=LONG_MIN, long max=LONG_MAX)
 
double getFloat (const std::string &key, double def=0)
 
bool getBool (const std::string &key, bool def=false)
 
long getDuration (const std::string &key, long def=0, long min=LONG_MIN, long max=LONG_MAX)
 
bool readString (const std::string &key, std::string &value, bool allow_newline=false)
 
void CheckRange (const std::string &key, long &res, long def, long min, long max)
 
std::string getTagLocation ()
 
const ConfigItemsgetItems () const
 
- Public Member Functions inherited from refcountbase
unsigned int GetReferenceCount () const
 
void refcount_inc () const
 
bool refcount_dec () const
 

Static Public Member Functions

static ConfigTagcreate (const std::string &Tag, const std::string &file, int line, ConfigItems *&Items)
 
- Static Public Member Functions inherited from refcountbase
static void * operator new (size_t, void *m)
 
static void * operator new (size_t)
 
static void operator delete (void *)
 

Public Attributes

const std::string tag
 
const std::string src_name
 
const int src_line
 

Detailed Description

Structure representing a single <tag> in config

Member Function Documentation

◆ CheckRange()

void ConfigTag::CheckRange ( const std::string &  key,
long &  res,
long  def,
long  min,
long  max 
)

Check for an out of range value. If the value falls outside the boundaries a warning is logged and the value is corrected (set to def).

Parameters
keyThe key name, used in the warning message
resThe value to verify and modify if needed
defThe default value, res will be set to this if (min <= res <= max) doesn't hold true
minMinimum accepted value for res
maxMaximum accepted value for res

◆ create()

ConfigTag * ConfigTag::create ( const std::string &  Tag,
const std::string &  file,
int  line,
ConfigItems *&  Items 
)
static

Create a new ConfigTag, giving access to the private ConfigItems item list

◆ getBool()

bool ConfigTag::getBool ( const std::string &  key,
bool  def = false 
)

Get the value of an option, using def if it does not exist

◆ getDuration()

long ConfigTag::getDuration ( const std::string &  key,
long  def = 0,
long  min = LONG_MIN,
long  max = LONG_MAX 
)

Get the value in seconds of a duration that is in the user-friendly "1h2m3s" format, using a default value if it does not exist or is out of bounds.

Parameters
keyThe config key name
defDefault value (optional)
minMinimum acceptable value (optional)
maxMaximum acceptable value (optional)
Returns
The duration in seconds

◆ getFloat()

double ConfigTag::getFloat ( const std::string &  key,
double  def = 0 
)

Get the value of an option, using def if it does not exist

◆ getInt()

long ConfigTag::getInt ( const std::string &  key,
long  def = 0,
long  min = LONG_MIN,
long  max = LONG_MAX 
)

Get the value of an option, using def if it does not exist

◆ getString()

std::string ConfigTag::getString ( const std::string &  key,
const std::string &  def = "",
size_t  minlen = 0,
size_t  maxlen = UINT32_MAX 
)

Get the value of an option, using def if it does not exist

◆ readString()

bool ConfigTag::readString ( const std::string &  key,
std::string &  value,
bool  allow_newline = false 
)

Get the value of an option

Parameters
keyThe option to get
valueThe location to store the value (unmodified if does not exist)
allow_newlineAllow newlines in the option (normally replaced with spaces)
Returns
true if the option exists

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