Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

Struct template regex_compiler

boost::xpressive::regex_compiler — Class template regex_compiler is a factory for building basic_regex objects from a string.

Synopsis

// In header: <boost/xpressive/regex_compiler.hpp>

template<typename BidiIter, typename RegexTraits, typename CompilerTraits> 
struct regex_compiler {
  // types
  typedef BidiIter                            iterator_type;  
  typedef iterator_value< BidiIter >::type    char_type;      
  typedef regex_constants::syntax_option_type flag_type;      
  typedef RegexTraits                         traits_type;    
  typedef traits_type::string_type            string_type;    
  typedef traits_type::locale_type            locale_type;    
  typedef traits_type::char_class_type        char_class_type;

  // construct/copy/destruct
  regex_compiler(RegexTraits const & = RegexTraits());

  // public member functions
  locale_type imbue(locale_type) ;
  locale_type getloc() const;
  template<typename InputIter> 
    basic_regex< BidiIter > 
    compile(InputIter, InputIter, flag_type = regex_constants::ECMAScript) ;
  template<typename InputRange> 
    disable_if< is_pointer< InputRange >, basic_regex< BidiIter > >::type 
    compile(InputRange const &, flag_type = regex_constants::ECMAScript) ;
  basic_regex< BidiIter > 
  compile(char_type const *, flag_type = regex_constants::ECMAScript) ;
  basic_regex< BidiIter > compile(char_type const *, std::size_t, flag_type) ;
  basic_regex< BidiIter > & operator[](string_type const &) ;
  basic_regex< BidiIter > const & operator[](string_type const &) const;

  // private member functions
  bool is_upper_(char_type) const;
};

Description

Class template regex_compiler is used to construct a basic_regex object from a string. The string should contain a valid regular expression. You can imbue a regex_compiler object with a locale, after which all basic_regex objects created with that regex_compiler object will use that locale. After creating a regex_compiler object, and optionally imbueing it with a locale, you can call the compile() method to construct a basic_regex object, passing it the string representing the regular expression. You can call compile() multiple times on the same regex_compiler object. Two basic_regex objects compiled from the same string will have different regex_id's.

regex_compiler public construct/copy/destruct

  1. regex_compiler(RegexTraits const & traits = RegexTraits());

regex_compiler public member functions

  1. locale_type imbue(locale_type loc) ;

    Specify the locale to be used by a regex_compiler.

    Parameters:

    loc

    The locale that this regex_compiler should use.

    Returns:

    The previous locale.

  2. locale_type getloc() const;

    Get the locale used by a regex_compiler.

    Returns:

    The locale used by this regex_compiler.

  3. template<typename InputIter> 
      basic_regex< BidiIter > 
      compile(InputIter begin, InputIter end, 
              flag_type flags = regex_constants::ECMAScript) ;

    Builds a basic_regex object from a range of characters.

    Parameters:

    begin

    The beginning of a range of characters representing the regular expression to compile.

    end

    The end of a range of characters representing the regular expression to compile.

    flags

    Optional bitmask that determines how the pat string is interpreted. (See syntax_option_type.)

    Requires:

    InputIter is a model of the InputIterator concept.

    [begin,end) is a valid range.

    The range of characters specified by [begin,end) contains a valid string-based representation of a regular expression.

    Returns:

    A basic_regex object corresponding to the regular expression represented by the character range.

    Throws:

  4. template<typename InputRange> 
      disable_if< is_pointer< InputRange >, basic_regex< BidiIter > >::type 
      compile(InputRange const & pat, 
              flag_type flags = regex_constants::ECMAScript) ;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

  5. basic_regex< BidiIter > 
    compile(char_type const * begin, 
            flag_type flags = regex_constants::ECMAScript) ;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

  6. basic_regex< BidiIter > 
    compile(char_type const * begin, std::size_t size, flag_type flags) ;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

  7. basic_regex< BidiIter > & operator[](string_type const & name) ;

    Return a reference to the named regular expression. If no such named regular expression exists, create a new regular expression and return a reference to it.

    Parameters:

    name

    A std::string containing the name of the regular expression.

    Requires:

    The string is not empty.

    Throws:

    bad_alloc
  8. basic_regex< BidiIter > const & operator[](string_type const & name) const;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

regex_compiler private member functions

  1. bool is_upper_(char_type ch) const;

PrevUpHomeNext