LibreOffice Module tools (master) 1
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
StringRangeEnumerator Class Reference

#include <multisel.hxx>

Classes

class  Iterator
 
struct  Range
 

Public Member Functions

 StringRangeEnumerator (std::u16string_view i_rInput, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset=-1)
 
sal_Int32 size () const
 
Iterator begin (const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
 
Iterator end (const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
 
bool hasValue (sal_Int32 nValue, const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
 

Static Public Member Functions

static bool getRangesFromString (std::u16string_view i_rPageRange, std::vector< sal_Int32 > &o_rPageVector, sal_Int32 i_nMinNumber, sal_Int32 i_nMaxNumber, sal_Int32 i_nLogicalOffset=-1, o3tl::sorted_vector< sal_Int32 > const *i_pPossibleValues=nullptr)
 i_rPageRange: the string to be changed into a sequence of numbers valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well o_rPageVector: the output sequence of numbers i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence example: a user enters page numbers from 1 to n (since that is logical) of course usable page numbers in code would start from 0 and end at n-1 so the logical offset would be -1 i_nMinNumber: the minimum allowed number i_nMaxNumber: the maximum allowed number More...
 

Private Member Functions

bool setRange (std::u16string_view i_rNewRange)
 
bool insertRange (sal_Int32 nFirst, sal_Int32 nLast, bool bSequence)
 
void insertJoinedRanges (const std::vector< sal_Int32 > &rNumbers)
 
bool checkValue (sal_Int32, const o3tl::sorted_vector< sal_Int32 > *i_pPossibleValues=nullptr) const
 

Private Attributes

std::vector< StringRangeEnumerator::RangemaSequence
 
sal_Int32 mnCount
 
sal_Int32 mnMin
 
sal_Int32 mnMax
 
sal_Int32 mnOffset
 
bool mbValidInput
 

Friends

class StringRangeEnumerator::Iterator
 

Detailed Description

Definition at line 77 of file multisel.hxx.

Constructor & Destructor Documentation

◆ StringRangeEnumerator()

StringRangeEnumerator::StringRangeEnumerator ( std::u16string_view  i_rInput,
sal_Int32  i_nMinNumber,
sal_Int32  i_nMaxNumber,
sal_Int32  i_nLogicalOffset = -1 
)

Definition at line 476 of file multisel.cxx.

References mbValidInput, mnCount, mnMax, mnMin, and setRange().

Member Function Documentation

◆ begin()

StringRangeEnumerator::Iterator StringRangeEnumerator::begin ( const o3tl::sorted_vector< sal_Int32 > *  i_pPossibleValues = nullptr) const

Definition at line 704 of file multisel.cxx.

References checkValue(), and maSequence.

Referenced by getRangesFromString().

◆ checkValue()

bool StringRangeEnumerator::checkValue ( sal_Int32  i_nValue,
const o3tl::sorted_vector< sal_Int32 > *  i_pPossibleValues = nullptr 
) const
private

◆ end()

StringRangeEnumerator::Iterator StringRangeEnumerator::end ( const o3tl::sorted_vector< sal_Int32 > *  i_pPossibleValues = nullptr) const

Definition at line 715 of file multisel.cxx.

Referenced by getRangesFromString().

◆ getRangesFromString()

bool StringRangeEnumerator::getRangesFromString ( std::u16string_view  i_rPageRange,
std::vector< sal_Int32 > &  o_rPageVector,
sal_Int32  i_nMinNumber,
sal_Int32  i_nMaxNumber,
sal_Int32  i_nLogicalOffset = -1,
o3tl::sorted_vector< sal_Int32 > const *  i_pPossibleValues = nullptr 
)
static

i_rPageRange: the string to be changed into a sequence of numbers valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well o_rPageVector: the output sequence of numbers i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence example: a user enters page numbers from 1 to n (since that is logical) of course usable page numbers in code would start from 0 and end at n-1 so the logical offset would be -1 i_nMinNumber: the minimum allowed number i_nMaxNumber: the maximum allowed number

Returns
: true if the input string was valid, o_rPageVector will contain the resulting sequence false if the input string was invalid, o_rPageVector will contain the sequence that parser is able to extract

behavior:

  • only non-negative sequence numbers are allowed
  • only non-negative values in the input string are allowed
  • the string "-3" means the sequence i_nMinNumber to 3
  • the string "3-" means the sequence 3 to i_nMaxNumber
  • the string "-" means the sequence i_nMinNumber to i_nMaxNumber
  • single number that doesn't fit in [i_nMinNumber,i_nMaxNumber] will be ignored
  • range that doesn't fit in [i_nMinNumber,i_nMaxNumber] will be adjusted

Definition at line 720 of file multisel.cxx.

References begin(), end(), mbValidInput, and size().

◆ hasValue()

bool StringRangeEnumerator::hasValue ( sal_Int32  nValue,
const o3tl::sorted_vector< sal_Int32 > *  i_pPossibleValues = nullptr 
) const

◆ insertJoinedRanges()

void StringRangeEnumerator::insertJoinedRanges ( const std::vector< sal_Int32 > &  rNumbers)
private

Definition at line 547 of file multisel.cxx.

References i, insertRange(), and nCount.

Referenced by setRange().

◆ insertRange()

bool StringRangeEnumerator::insertRange ( sal_Int32  nFirst,
sal_Int32  nLast,
bool  bSequence 
)
private

Definition at line 501 of file multisel.cxx.

References checkValue(), maSequence, mnCount, mnMax, and mnMin.

Referenced by insertJoinedRanges().

◆ setRange()

bool StringRangeEnumerator::setRange ( std::u16string_view  i_rNewRange)
private

Definition at line 574 of file multisel.cxx.

References insertJoinedRanges(), maSequence, mnCount, mnMax, mnMin, mnOffset, and o3tl::toInt32().

Referenced by StringRangeEnumerator().

◆ size()

sal_Int32 StringRangeEnumerator::size ( ) const
inline

Definition at line 129 of file multisel.hxx.

References mnCount.

Referenced by getRangesFromString().

Friends And Related Function Documentation

◆ StringRangeEnumerator::Iterator

friend class StringRangeEnumerator::Iterator
friend

Definition at line 121 of file multisel.hxx.

Member Data Documentation

◆ maSequence

std::vector< StringRangeEnumerator::Range > StringRangeEnumerator::maSequence
private

◆ mbValidInput

bool StringRangeEnumerator::mbValidInput
private

Definition at line 91 of file multisel.hxx.

Referenced by getRangesFromString(), and StringRangeEnumerator().

◆ mnCount

sal_Int32 StringRangeEnumerator::mnCount
private

Definition at line 87 of file multisel.hxx.

Referenced by insertRange(), setRange(), and size().

◆ mnMax

sal_Int32 StringRangeEnumerator::mnMax
private

Definition at line 89 of file multisel.hxx.

Referenced by checkValue(), insertRange(), setRange(), and StringRangeEnumerator().

◆ mnMin

sal_Int32 StringRangeEnumerator::mnMin
private

Definition at line 88 of file multisel.hxx.

Referenced by insertRange(), setRange(), and StringRangeEnumerator().

◆ mnOffset

sal_Int32 StringRangeEnumerator::mnOffset
private

Definition at line 90 of file multisel.hxx.

Referenced by setRange().


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