fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::ebitset< T, B > Class Template Reference

Bitset for enums. More...

#include <f8utils.hpp>

Public Member Functions

 ebitset ()
 Ctor. More...
 
 ebitset (const ebitset< T, B > &from)
 
 ebitset (const integral_type a)
 
 ebitset (const T sbit)
 
ebitset< T, B > & operator= (const ebitset< T, B > &that)
 
integral_type has (const T sbit) const
 
integral_type operator& (const T sbit) const
 
void set (const T sbit, bool on=true)
 
void set (const integral_type bset)
 
int set (const std::vector< std::string > &sset, const std::string &what, bool ignorecase, bool on=true)
 
void clear (const T sbit)
 
void clearall ()
 Clear all bits. More...
 
void setall (const T sbit)
 
integral_type get () const
 
void operator|= (const T sbit)
 
ebitsetoperator<< (const T sbit)
 

Private Types

using integral_type = B
 

Private Attributes

integral_type a_
 

Detailed Description

template<typename T, typename B = unsigned int>
class FIX8::ebitset< T, B >

Bitset for enums.

Template Parameters
Tthe enum type
Bthe integral type of the enumeration

Definition at line 842 of file f8utils.hpp.

Member Typedef Documentation

template<typename T, typename B = unsigned int>
using FIX8::ebitset< T, B >::integral_type = B
private

Definition at line 844 of file f8utils.hpp.

Constructor & Destructor Documentation

template<typename T, typename B = unsigned int>
FIX8::ebitset< T, B >::ebitset ( )
inline

Ctor.

Definition at line 849 of file f8utils.hpp.

849 : a_() {}
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
FIX8::ebitset< T, B >::ebitset ( const ebitset< T, B > &  from)
inline

Ctor.

Parameters
fromebitset_r to copy

Definition at line 853 of file f8utils.hpp.

853 : a_(from.a_) {}
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
FIX8::ebitset< T, B >::ebitset ( const integral_type  a)
inlineexplicit

Ctor.

Parameters
aintegral type to construct from

Definition at line 857 of file f8utils.hpp.

857 : a_(a) {}
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
FIX8::ebitset< T, B >::ebitset ( const T  sbit)
inlineexplicit

Ctor.

Parameters
sbitenum to construct from

Definition at line 861 of file f8utils.hpp.

861 : a_((1 << sbit) - 1) {}
integral_type a_
Definition: f8utils.hpp:845

Member Function Documentation

template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::clear ( const T  sbit)
inline

Clear a bit on or off.

Parameters
sbitenum to set

Definition at line 913 of file f8utils.hpp.

Referenced by FIX8::FieldTraits::clear(), and FIX8::FieldTraits::clear_flag().

913 { a_ &= ~(1 << sbit); }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::clearall ( )
inline

Clear all bits.

Definition at line 916 of file f8utils.hpp.

916 { a_ = 0; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset< T, B >::get ( ) const
inline

Get the enum integral_type.

Returns
integral_type of enum

Definition at line 924 of file f8utils.hpp.

Referenced by FIX8::FieldTraits::getval(), and FIX8::operator<<().

924 { return a_; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset< T, B >::has ( const T  sbit) const
inline

Check if an enum is in the set.

Parameters
sbitenum to check
Returns
integral_type of bits if found

Definition at line 876 of file f8utils.hpp.

Referenced by FIX8::FieldTraits::get(), FIX8::FieldTraits::getPos(), FIX8::Logger::has_flag(), and FIX8::FileLogger::rotate().

876 { return a_ & 1 << sbit; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset< T, B >::operator& ( const T  sbit) const
inline

Check if an enum is in the set.

Parameters
sbitenum to check
Returns
integral_type of bits if found

Definition at line 881 of file f8utils.hpp.

881 { return a_ & 1 << sbit; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
ebitset& FIX8::ebitset< T, B >::operator<< ( const T  sbit)
inline

Or a bit value with the current set.

Parameters
sbitto set
Returns
ebitset

Definition at line 933 of file f8utils.hpp.

933 { a_ |= 1 << sbit; return *this; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
ebitset<T, B>& FIX8::ebitset< T, B >::operator= ( const ebitset< T, B > &  that)
inline

Assignment operator.

Parameters
thatebitset_r to assign from
Returns
this

Definition at line 866 of file f8utils.hpp.

867  {
868  if (this != &that)
869  a_ = that.a_;
870  return *this;
871  }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::operator|= ( const T  sbit)
inline

Or a bit value with the current set.

Parameters
sbitto set

Definition at line 928 of file f8utils.hpp.

928 { a_ |= 1 << sbit; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::set ( const T  sbit,
bool  on = true 
)
inline

Set a bit on or off.

Parameters
sbitenum to set
onset on or off

Definition at line 886 of file f8utils.hpp.

Referenced by FIX8::FieldTraits::set(), and FIX8::ebitset< TraitTypes, unsigned short >::set().

886 { if (on) a_ |= 1 << sbit; else a_ &= ~(1 << sbit); }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::set ( const integral_type  bset)
inline

Set a bit on or off.

Parameters
bsetintegral_type to set

Definition at line 890 of file f8utils.hpp.

890 { a_ = bset; }
integral_type a_
Definition: f8utils.hpp:845
template<typename T, typename B = unsigned int>
int FIX8::ebitset< T, B >::set ( const std::vector< std::string > &  sset,
const std::string &  what,
bool  ignorecase,
bool  on = true 
)
inline

From a set of strings representing the names of each bit in order, set the named bit on.

Parameters
ssetthe set of strings
whatthe string to find and set
ignorecaseif true, ignore case
onset or clear the found bit
Returns
enumeration (as int) if found and -1 if not

Definition at line 898 of file f8utils.hpp.

899  {
900  auto itr(sset.cbegin());
901  for (; itr != sset.cend(); ++itr)
902  if (ignorecase ? trim(*itr) % what : trim(*itr) == what)
903  break;
904  if (itr == sset.cend())
905  return -1;
906  const int dist(std::distance(sset.cbegin(), itr));
907  set(static_cast<T>(dist), on);
908  return dist;
909  }
std::string trim(const std::string &source, const std::string &ws=" \t")
Definition: f8utils.hpp:153
void set(const T sbit, bool on=true)
Definition: f8utils.hpp:886
template<typename T, typename B = unsigned int>
void FIX8::ebitset< T, B >::setall ( const T  sbit)
inline

Set all bits to a value.

Parameters
sbitvalue to set to

Definition at line 920 of file f8utils.hpp.

920 { a_ = (1 << sbit) - 1; }
integral_type a_
Definition: f8utils.hpp:845

Member Data Documentation

template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset< T, B >::a_
private

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