cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::Options Class Reference

#include <cpp-terminal/options.hpp>

Public Member Functions

 Options ()=default
 
 Options (const std::initializer_list< Term::Option > &option)
 
template<typename... Args>
 Options (const Args &&... args)
 
bool operator== (const Options &options)
 
bool operator!= (const Options &options)
 
bool has (const Option &option) const noexcept
 

Private Member Functions

void clean ()
 

Private Attributes

std::vector< Term::Optionm_Options
 

Detailed Description

Definition at line 34 of file options.hpp.

Constructor & Destructor Documentation

◆ Options() [1/3]

Term::Options::Options ( )
default

◆ Options() [2/3]

Term::Options::Options ( const std::initializer_list< Term::Option > & option)

Definition at line 14 of file options.cpp.

14: m_Options(option) { clean(); }
void clean()
Definition options.cpp:19
std::vector< Term::Option > m_Options
Definition options.hpp:47

◆ Options() [3/3]

template<typename... Args>
Term::Options::Options ( const Args &&... args)
inlineexplicit

Definition at line 39 of file options.hpp.

39: m_Options(std::initializer_list<Term::Option>{args...}) { clean(); }

Member Function Documentation

◆ clean()

void Term::Options::clean ( )
private

Definition at line 19 of file options.cpp.

20{
21 std::vector<Term::Option> cleaned;
22 std::sort(m_Options.begin(), m_Options.end());
23 while(!m_Options.empty())
24 {
25 const std::size_t count = std::count(m_Options.begin(), m_Options.end(), m_Options[0]);
26 const std::size_t anti_count = std::count(m_Options.begin(), m_Options.end(), static_cast<Term::Option>(-1 * static_cast<std::int16_t>(m_Options[0])));
27 if(count > anti_count) { cleaned.emplace_back(m_Options[0]); }
28 else if(count < anti_count) { cleaned.emplace_back(static_cast<Term::Option>(-1 * static_cast<std::int16_t>(m_Options[0]))); }
29 m_Options.erase(std::remove(m_Options.begin(), m_Options.end(), static_cast<Term::Option>(-1 * static_cast<std::int16_t>(m_Options[0]))), m_Options.end());
30 m_Options.erase(std::remove(m_Options.begin(), m_Options.end(), m_Options[0]), m_Options.end());
31 }
32 m_Options = cleaned;
33}
Option
Option to set-up the terminal.
Definition options.hpp:23

◆ has()

bool Term::Options::has ( const Option & option) const
noexcept

Definition at line 35 of file options.cpp.

35{ return std::find(m_Options.begin(), m_Options.end(), option) != m_Options.end(); }

◆ operator!=()

bool Term::Options::operator!= ( const Options & options)

Definition at line 17 of file options.cpp.

17{ return !(m_Options == options.m_Options); }

◆ operator==()

bool Term::Options::operator== ( const Options & options)

Definition at line 16 of file options.cpp.

16{ return m_Options == options.m_Options; }

Member Data Documentation

◆ m_Options

std::vector<Term::Option> Term::Options::m_Options
private

Definition at line 47 of file options.hpp.


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