17 #include <tr1/cstdint>
166 unsigned lengthField);
199 template <
typename T>
201 const std::string &rawValue, T minValue, T maxValue) {
208 throw InvalidValueError(std::string(
"TCP/IP configuration parsing error: invalid ") +
209 optionName +
" (" + rawValue +
")");
213 if (value < minValue || value > maxValue) {
214 throw InvalidValueError(std::string(
"TCP/IP configuration parsing error: invalid ") +
215 optionName +
" (" + rawValue +
") - " + optionName +
" must be between " +
241 #endif // #ifndef CONFIG_H
size_t BufferSize
Buffer size type.
Definition: config.h:43
static LengthField parseLengthField(const std::string &rawLengthField)
static const LengthField DEFAULT_LENGTH_FIELD
Default length field (in bytes).
Definition: config.h:238
std::map< std::string, std::string > RawConfigValues
Raw configuration option -> values mapping.
Definition: config.h:40
Config & operator=(const Config &other)
Assignment operator.
static Config fromRawConfigValues(RawConfigValues rawConfigValues)
Creates a Config object from raw configuration values.
void swap(Config &other)
Swap the contents of this object with the other object.
bool operator!=(const Config &other) const
Non-equality comparison.
bool operator==(const Config &other) const
Equality comparison.
static LengthFieldMessageLength computeMaximalMessageLength(unsigned lengthField)
Returns the maximal message size that can be stored in lengthField bytes.
BaseException class - declarations.
Base class for all configuration classes.
Definition: config.h:28
LengthField getLengthField() const
Returns the size of a field containing the length of a message (in bytes).
Definition: config.h:125
InvalidValueError(const std::string &errorMessage)
Definition: config.h:35
Base exception class for all project exceptions.
Definition: base_exception.h:23
std::string toString(const T &value)
Converts the selected value into a string.
Definition: conversions.h:26
Various conversion functions for common usage - declarations.
static LengthFieldMessageLength binaryFieldLengthToNumber(const std::string &binaryNumber)
Transforms the selected binary string into a number.
size_t getBufferSize() const
Returns the buffer size (in bytes).
Definition: config.h:122
bool strToNum(const std::string &str, N &number, std::ios_base &(*format)(std::ios_base &)=std::dec)
Converts the selected string into a number.
Definition: conversions.h:95
BufferSize _bufferSize
Buffer size (in bytes).
Definition: config.h:231
static BufferSize parseBufferSize(const std::string &rawBufferSize)
This exception should be thrown if some configuration value is invalid.
Definition: config.h:33
static std::string messageLengthToBinaryLengthField(LengthFieldMessageLength messageLength, unsigned lengthField)
Transforms the selected message length into a binary length field string.
unsigned LengthField
Length field type.
Definition: config.h:46
static const BufferSize DEFAULT_BUFFER_SIZE
Default buffer size (in bytes).
Definition: config.h:236
std::tr1::uint32_t LengthFieldMessageLength
Message length type when using length field.
Definition: config.h:49
static T parseNumber(const std::string &optionName, const std::string &rawValue, T minValue, T maxValue)
Parses the selected number from the selected string.
Definition: config.h:200
LengthField _lengthField
Size of a field containing the length of a message (in bytes).
Definition: config.h:233
Config()
Default constructor.