MIP_SDK  latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
Public Member Functions | List of all members
microstrain::Index Class Reference

Represents an index ranging from 0..N excluding N. More...

#include <index.hpp>

Public Member Functions

constexpr Index (unsigned int index)
 
constexpr Index ()
 
constexpr IndexsetFromIndex (unsigned int index)
 
constexpr IndexsetFromId (unsigned int id)
 
constexpr unsigned int index () const
 
constexpr unsigned int id () const
 
constexpr bool operator== (const Index &other) const
 
constexpr bool operator!= (const Index &other) const
 
constexpr bool isAssigned () const
 
constexpr bool isValid (size_t max_count) const
 
constexpr void clear ()
 
Indexoperator++ ()
 
Indexoperator-- ()
 
Index operator++ (int)
 
Index operator-- (int)
 
constexpr Index (const Id &other)
 
constexpr Indexoperator= (const Id &other)
 
bool operator< (Index other) const
 
bool operator> (Index other) const
 
bool operator<= (Index other) const
 
bool operator>= (Index other) const
 
bool operator== (Index other) const
 
bool operator!= (Index other) const
 

Detailed Description

Represents an index ranging from 0..N excluding N.

Use this to help avoid off-by-one errors when using indices into arrays at the same time as referring to MIP values which typically start at 1.

Use the index() or id() methods to get the actual value, depending on what you need. The index() method returns an unsigned int in the range [0,N-1] while the id() method returns an unsigned int in the range [1,N]

isAssigned() can be used to see if the value is valid, i.e. initialized. isValid() can be used to check if the value is within a maximum count.

The default value with no initialization is INVALID.

This is interchangeable with the Id class below.

Constructor & Destructor Documentation

◆ Index() [1/3]

constexpr microstrain::Index::Index ( unsigned int  index)
inlineexplicitconstexpr

◆ Index() [2/3]

constexpr microstrain::Index::Index ( )
inlineconstexpr

◆ Index() [3/3]

constexpr microstrain::Index::Index ( const Id other)
inlineconstexpr

Member Function Documentation

◆ clear()

constexpr void microstrain::Index::clear ( )
inlineconstexpr

◆ id()

constexpr unsigned int microstrain::Index::id ( ) const
inlineconstexpr

◆ index()

constexpr unsigned int microstrain::Index::index ( ) const
inlineconstexpr

◆ isAssigned()

constexpr bool microstrain::Index::isAssigned ( ) const
inlineconstexpr

◆ isValid()

constexpr bool microstrain::Index::isValid ( size_t  max_count) const
inlineconstexpr

◆ operator!=() [1/2]

constexpr bool microstrain::Index::operator!= ( const Index other) const
inlineconstexpr

◆ operator!=() [2/2]

bool microstrain::Index::operator!= ( Index  other) const
inline

◆ operator++() [1/2]

Index& microstrain::Index::operator++ ( )
inline

◆ operator++() [2/2]

Index microstrain::Index::operator++ ( int  )
inline

◆ operator--() [1/2]

Index& microstrain::Index::operator-- ( )
inline

◆ operator--() [2/2]

Index microstrain::Index::operator-- ( int  )
inline

◆ operator<()

bool microstrain::Index::operator< ( Index  other) const
inline

◆ operator<=()

bool microstrain::Index::operator<= ( Index  other) const
inline

◆ operator=()

constexpr Index & microstrain::Index::operator= ( const Id other)
inlineconstexpr

◆ operator==() [1/2]

constexpr bool microstrain::Index::operator== ( const Index other) const
inlineconstexpr

◆ operator==() [2/2]

bool microstrain::Index::operator== ( Index  other) const
inline

◆ operator>()

bool microstrain::Index::operator> ( Index  other) const
inline

◆ operator>=()

bool microstrain::Index::operator>= ( Index  other) const
inline

◆ setFromId()

constexpr Index& microstrain::Index::setFromId ( unsigned int  id)
inlineconstexpr

◆ setFromIndex()

constexpr Index& microstrain::Index::setFromIndex ( unsigned int  index)
inlineconstexpr

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