MySQL 9.6.0
Source Code Documentation
mysql::strconv::Repeat_optional Class Reference

Represents a range of integers for which the lower bound is 0, representing the number of repetitions of a token when parsing a string. More...

#include <repeat.h>

Inheritance diagram for mysql::strconv::Repeat_optional:
[legend]

Public Member Functions

 Repeat_optional ()
 Default-construct a Repeat_optional object representing a range of 0..1 repetitions, inclusive. More...
 
 Repeat_optional (std::integral auto max)
 Construct an object representing a range of 0 up to the given number of repetitions. More...
 
constexpr std::size_t min () const
 Return the mimimum number of repetitions, inclusive; the return value is always 0. More...
 
- Public Member Functions inherited from mysql::strconv::detail::Repeat_base< Repeat_optional >
 Repeat_base (std::integral auto max)
 Construct a new object with the given maximum. More...
 
std::size_t max () const
 Return the maximum number of repetitions, inclusive. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from mysql::strconv::detail::Repeat_base< Repeat_optional >
static Repeat_optional optional ()
 Return a Repeat_optional object representing zero or one instances. More...
 
static Repeat_optional at_most (std::integral auto max_arg)
 Return a Repeat object representing between 0 and min_arg repetitions. More...
 
static Repeat_optional any ()
 Return a Repeat_optional object representing any number of repetitions from 0 and up (bounded only by std::numeric_limits). More...
 

Detailed Description

Represents a range of integers for which the lower bound is 0, representing the number of repetitions of a token when parsing a string.

This class is similar to Repeat, but limited to ranges that begin at zero. Examples:

  • Repeat_optional(3): up to 3 repetitions (0 to 3)
  • Repeat_optional::optional(): 0 or 1 repetitions (analogous to the regex syntax "?")
  • Repeat_optional::any(): 0 or more repetitions (analogous to the regex syntax "*")

The reason we define a distinct class for this case, rather than use Repeat with a specified lower bound of 0, is that some functions taking a number of repetitions as argument cannot fail when 0 is an allowed number of repetitions. Such functions can therefore return void and/or omit the [[nodiscard]] attribute when the argument is of type Repeat_optional.

Constructor & Destructor Documentation

◆ Repeat_optional() [1/2]

mysql::strconv::Repeat_optional::Repeat_optional ( )
inline

Default-construct a Repeat_optional object representing a range of 0..1 repetitions, inclusive.

◆ Repeat_optional() [2/2]

mysql::strconv::Repeat_optional::Repeat_optional ( std::integral auto  max)
inlineexplicit

Construct an object representing a range of 0 up to the given number of repetitions.

Member Function Documentation

◆ min()

constexpr std::size_t mysql::strconv::Repeat_optional::min ( ) const
inlineconstexpr

Return the mimimum number of repetitions, inclusive; the return value is always 0.


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