ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | List of all members
anna::MultiRangeExpression Class Reference

#include <MultiRangeExpression.hpp>

Public Member Functions

 MultiRangeExpression ()
 
 ~MultiRangeExpression ()
 
const char * getLiteral (void) const
 
std::string getExpandedLiteral (void) const
 
const char * simplifyLiteral (void)
 
bool contain (const unsigned int &value) const
 
void setLiteral (const char *l)
 
void addLiteral (const char *l)
 

Detailed Description

Class helper to manage multi-range expression like '1-4,23,45-46' (1,2,3,4,23,45,46)

Constructor & Destructor Documentation

◆ MultiRangeExpression()

anna::MultiRangeExpression::MultiRangeExpression ( )
inline
34 {};

◆ ~MultiRangeExpression()

anna::MultiRangeExpression::~MultiRangeExpression ( )
inline
35 {};

Member Function Documentation

◆ addLiteral()

void anna::MultiRangeExpression::addLiteral ( const char *  l)
inline

Accumulates the provided literal over the stored literal You could simplify with simplifyLiteral, because perhaps there is overlapping between current literal and provided one.

Parameters
lLiteral to be added
87  {
88  if(!l) return;
89 
90  if(std::string(l) != "") {
91  a_literal += ",";
92  a_literal += l;
93  }
94 
95  refresh();
96  }

◆ contain()

bool anna::MultiRangeExpression::contain ( const unsigned int &  value) const
inline

Returns true if the value provided is contained in the multirange expression literal

Parameters
valueValue to be tested
Returns
True or false
67 { return (a_data.find(value) != a_data.end()); }

◆ getExpandedLiteral()

std::string anna::MultiRangeExpression::getExpandedLiteral ( void  ) const

Gets expanded representation for stored literal. E.g.: '1-3,8,10' => '1,2,3,7,8,10'

Returns
Expanded literal

◆ getLiteral()

const char* anna::MultiRangeExpression::getLiteral ( void  ) const
inline

Gets the configured literal by mean setLiteral or addLiteral

Returns
Literal
43 { return a_literal.c_str(); }
Here is the call graph for this function:

◆ setLiteral()

void anna::MultiRangeExpression::setLiteral ( const char *  l)
inline

Configures a new literal

Parameters
lLiteral to be stored
76  {
77  a_literal = l ? l : "";
78  refresh();
79  }

◆ simplifyLiteral()

const char* anna::MultiRangeExpression::simplifyLiteral ( void  )

Simplify stored literal. E.g.: '1,1,1,2,3,7,8,10' => '1-3,8,10' and returns it.

Returns
Simplified literal

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