eisgenerator 1.0.x
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eis::Range Class Reference

A range. More...

#include <eistype.h>

Public Member Functions

fvalue stepSize () const
 Calculates the distance between elements in the range.
 
fvalue stepValue () const
 Calculates the value of the current step.
 
fvalue center () const
 Calculates the mean of the start and the end values.
 
fvalue at (size_t index) const
 Calculates the value at the given index.
 
fvalue operator[] (size_t index) const
 
Range operator* (fvalue in) const
 
Range operator/ (fvalue in) const
 
Range operator* (int in) const
 
Range operator/ (int in) const
 
 Range (fvalue startI, fvalue endI, size_t countI, bool logI=false)
 
void print (int level) const
 Prints the range to stdout via eis::Log.
 
std::string getString () const
 Gets a machine parseable string encoding this range.
 
bool isSane () const
 Checks if the values of this range are sane/.
 
std::vector< fvalue > getRangeVector () const
 This function constructs a vector that contains all elements of this range.
 

Static Public Member Functions

static Range fromString (std::string str, size_t count)
 This function creates a range from the parseable string.
 
static std::vector< RangerangesFromParamString (const std::string &paramStr, size_t count)
 This function creates a vector ranges from the parseable parameter array string.
 

Public Attributes

fvalue start
 Start of the range.
 
fvalue end
 End of the range.
 
size_t count = 0
 Number of elements in the range.
 
size_t step = 0
 Currently active step.
 
bool log = false
 True if the elements in the range are to be spaced in log10 increments.
 

Detailed Description

A range.

Examples
compileing.cpp, and simple.cpp.

Member Function Documentation

◆ at()

fvalue eis::Range::at ( size_t index) const
inline

Calculates the value at the given index.

Returns
The value at the given index.

References count, log, start, and stepSize().

Referenced by stepValue().

◆ center()

fvalue eis::Range::center ( ) const
inline

Calculates the mean of the start and the end values.

Returns
The mean of the start and the end values.

References end, and start.

◆ fromString()

static Range eis::Range::fromString ( std::string str,
size_t count )
static

This function creates a range from the parseable string.

Exceptions
std::invalid_argumentwhen the string syntax is incorrect.
Returns
The range that was parsed from the string.

◆ getRangeVector()

std::vector< fvalue > eis::Range::getRangeVector ( ) const

This function constructs a vector that contains all elements of this range.

Returns
The vector with the elements of this range.
Examples
simple.cpp.

◆ getString()

std::string eis::Range::getString ( ) const

Gets a machine parseable string encoding this range.

Returns
The string.

◆ isSane()

bool eis::Range::isSane ( ) const

Checks if the values of this range are sane/.

This checks for some common errors like having a end < being.

Returns
true if sane, false if not.

◆ print()

void eis::Range::print ( int level) const

Prints the range to stdout via eis::Log.

Parameters
levelThe eis::Log::Level to print at.

◆ rangesFromParamString()

static std::vector< Range > eis::Range::rangesFromParamString ( const std::string & paramStr,
size_t count )
static

This function creates a vector ranges from the parseable parameter array string.

Exceptions
std::invalid_argumentwhen the string syntax is incorrect
Returns
The vector of ranges that was parsed from the string.

◆ stepSize()

fvalue eis::Range::stepSize ( ) const
inline

Calculates the distance between elements in the range.

Will calculate the log10 of the distance if the range is logarithmic.

Returns
The linear or log distance between steps of this range.

References count, end, log, and start.

Referenced by at().

◆ stepValue()

fvalue eis::Range::stepValue ( ) const
inline

Calculates the value of the current step.

Returns
The value of the current step.

References at(), and step.