algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
Loading...
Searching...
No Matches
algotradelib::StatedDate Class Reference

A date a broker stated, did not state, or stated in a form that could not be read. More...

#include <algotradelib/src/core/instrument.hpp>

Public Types

enum class  State { NOT_STATED , STATED , UNREADABLE }
 What the broker's field said. More...

Public Member Functions

 StatedDate ()=default
 Constructs a date the broker did not state.
State state () const noexcept
 Returns what the broker's field said.
const Date & date () const
 Returns the date.

Static Public Member Functions

static StatedDate stated (Date date)
 Makes a stated date.
static StatedDate unreadable ()
 Makes an unreadable date.

Friends

bool operator== (const StatedDate &lhs, const StatedDate &rhs)
 Compares two values: the same state, and the same date when stated.
bool operator!= (const StatedDate &lhs, const StatedDate &rhs)
 Compares two values for inequality.

Detailed Description

A date a broker stated, did not state, or stated in a form that could not be read.

Name the state before reading the date:

switch (instrument.delisted_on_.state()) {
case StatedDate::State::STATED: use(instrument.delisted_on_.date()); break;
case StatedDate::State::NOT_STATED: ...; break; // the broker said nothing
case StatedDate::State::UNREADABLE: ...; break; // the broker sent something unreadable
}
@ STATED
A date that was read.
@ UNREADABLE
Something that is not a readable calendar date.
@ NOT_STATED
No date: absent, null, or the broker's empty spelling.

It does not convert to bool or to std::optional<Date>, so "no date" and "unreadable date" cannot be confused.

Definition at line 380 of file instrument.hpp.

Member Enumeration Documentation

◆ State

What the broker's field said.

Enumerator
NOT_STATED 

No date: absent, null, or the broker's empty spelling.

STATED 

A date that was read.

UNREADABLE 

Something that is not a readable calendar date.

Definition at line 383 of file instrument.hpp.

Constructor & Destructor Documentation

◆ StatedDate()

algotradelib::StatedDate::StatedDate ( )
default

Constructs a date the broker did not state.

Referenced by operator!=, operator==, stated(), and unreadable().

Member Function Documentation

◆ date()

const Date & algotradelib::StatedDate::date ( ) const
inline

Returns the date.

Returns
The date.
Exceptions
std::logic_errorunless state() is STATED.

Definition at line 428 of file instrument.hpp.

Referenced by algotradelib::Instrument::dates_exclude(), and stated().

◆ state()

State algotradelib::StatedDate::state ( ) const
inlinenoexcept

Returns what the broker's field said.

Returns
The state.

Definition at line 421 of file instrument.hpp.

Referenced by algotradelib::Instrument::dates_exclude().

◆ stated()

StatedDate algotradelib::StatedDate::stated ( Date date)
inlinestatic

Makes a stated date.

Parameters
dateThe date.
Returns
A value in state STATED.

Definition at line 400 of file instrument.hpp.

◆ unreadable()

StatedDate algotradelib::StatedDate::unreadable ( )
inlinestatic

Makes an unreadable date.

Returns
A value in state UNREADABLE.

Definition at line 411 of file instrument.hpp.

◆ operator!=

bool operator!= ( const StatedDate & lhs,
const StatedDate & rhs )
friend

Compares two values for inequality.

Parameters
lhsThe first value.
rhsThe second value.
Returns
true if they differ.

Definition at line 451 of file instrument.hpp.

◆ operator==

bool operator== ( const StatedDate & lhs,
const StatedDate & rhs )
friend

Compares two values: the same state, and the same date when stated.

Parameters
lhsThe first value.
rhsThe second value.
Returns
true if they say the same thing.

Definition at line 441 of file instrument.hpp.


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