Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
regex6651 linesDownload Raw Back to include
1// -*- C++ -*-2//===--------------------------- regex ------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_REGEX11#define _LIBCUDACXX_REGEX12 13/*14    regex synopsis15 16#include <initializer_list>17 18namespace std19{20 21namespace regex_constants22{23 24emum syntax_option_type25{26    icase      = unspecified,27    nosubs     = unspecified,28    optimize   = unspecified,29    collate    = unspecified,30    ECMAScript = unspecified,31    basic      = unspecified,32    extended   = unspecified,33    awk        = unspecified,34    grep       = unspecified,35    egrep      = unspecified36};37 38constexpr syntax_option_type operator~(syntax_option_type f);39constexpr syntax_option_type operator&(syntax_option_type lhs, syntax_option_type rhs);40constexpr syntax_option_type operator|(syntax_option_type lhs, syntax_option_type rhs);41 42enum match_flag_type43{44    match_default     = 0,45    match_not_bol     = unspecified,46    match_not_eol     = unspecified,47    match_not_bow     = unspecified,48    match_not_eow     = unspecified,49    match_any         = unspecified,50    match_not_null    = unspecified,51    match_continuous  = unspecified,52    match_prev_avail  = unspecified,53    format_default    = 0,54    format_sed        = unspecified,55    format_no_copy    = unspecified,56    format_first_only = unspecified57};58 59constexpr match_flag_type operator~(match_flag_type f);60constexpr match_flag_type operator&(match_flag_type lhs, match_flag_type rhs);61constexpr match_flag_type operator|(match_flag_type lhs, match_flag_type rhs);62 63enum error_type64{65    error_collate    = unspecified,66    error_ctype      = unspecified,67    error_escape     = unspecified,68    error_backref    = unspecified,69    error_brack      = unspecified,70    error_paren      = unspecified,71    error_brace      = unspecified,72    error_badbrace   = unspecified,73    error_range      = unspecified,74    error_space      = unspecified,75    error_badrepeat  = unspecified,76    error_complexity = unspecified,77    error_stack      = unspecified78};79 80}  // regex_constants81 82class regex_error83    : public runtime_error84{85public:86    explicit regex_error(regex_constants::error_type ecode);87    regex_constants::error_type code() const;88};89 90template <class charT>91struct regex_traits92{93public:94    typedef charT                   char_type;95    typedef basic_string<char_type> string_type;96    typedef locale                  locale_type;97    typedef /bitmask_type/          char_class_type;98 99    regex_traits();100 101    static size_t length(const char_type* p);102    charT translate(charT c) const;103    charT translate_nocase(charT c) const;104    template <class ForwardIterator>105        string_type106        transform(ForwardIterator first, ForwardIterator last) const;107    template <class ForwardIterator>108        string_type109        transform_primary( ForwardIterator first, ForwardIterator last) const;110    template <class ForwardIterator>111        string_type112        lookup_collatename(ForwardIterator first, ForwardIterator last) const;113    template <class ForwardIterator>114        char_class_type115        lookup_classname(ForwardIterator first, ForwardIterator last,116                         bool icase = false) const;117    bool isctype(charT c, char_class_type f) const;118    int value(charT ch, int radix) const;119    locale_type imbue(locale_type l);120    locale_type getloc()const;121};122 123template <class charT, class traits = regex_traits<charT>>124class basic_regex125{126public:127    // types:128    typedef charT                               value_type;129    typedef traits                              traits_type;130    typedef typename traits::string_type        string_type;131    typedef regex_constants::syntax_option_type flag_type;132    typedef typename traits::locale_type        locale_type;133 134    // constants:135    static constexpr regex_constants::syntax_option_type icase = regex_constants::icase;136    static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs;137    static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize;138    static constexpr regex_constants::syntax_option_type collate = regex_constants::collate;139    static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript;140    static constexpr regex_constants::syntax_option_type basic = regex_constants::basic;141    static constexpr regex_constants::syntax_option_type extended = regex_constants::extended;142    static constexpr regex_constants::syntax_option_type awk = regex_constants::awk;143    static constexpr regex_constants::syntax_option_type grep = regex_constants::grep;144    static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep;145 146    // construct/copy/destroy:147    basic_regex();148    explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);149    basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);150    basic_regex(const basic_regex&);151    basic_regex(basic_regex&&) noexcept;152    template <class ST, class SA>153        explicit basic_regex(const basic_string<charT, ST, SA>& p,154                             flag_type f = regex_constants::ECMAScript);155    template <class ForwardIterator>156        basic_regex(ForwardIterator first, ForwardIterator last,157                    flag_type f = regex_constants::ECMAScript);158    basic_regex(initializer_list<charT>, flag_type = regex_constants::ECMAScript);159 160    ~basic_regex();161 162    basic_regex& operator=(const basic_regex&);163    basic_regex& operator=(basic_regex&&) noexcept;164    basic_regex& operator=(const charT* ptr);165    basic_regex& operator=(initializer_list<charT> il);166    template <class ST, class SA>167        basic_regex& operator=(const basic_string<charT, ST, SA>& p);168 169    // assign:170    basic_regex& assign(const basic_regex& that);171    basic_regex& assign(basic_regex&& that) noexcept;172    basic_regex& assign(const charT* ptr,           flag_type f = regex_constants::ECMAScript);173    basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);174    template <class string_traits, class A>175        basic_regex& assign(const basic_string<charT, string_traits, A>& s,176                                                    flag_type f = regex_constants::ECMAScript);177    template <class InputIterator>178        basic_regex& assign(InputIterator first, InputIterator last,179                                                    flag_type f = regex_constants::ECMAScript);180    basic_regex& assign(initializer_list<charT>,    flag_type f = regex_constants::ECMAScript);181 182    // const operations:183    unsigned mark_count() const;184    flag_type flags() const;185 186    // locale:187    locale_type imbue(locale_type loc);188    locale_type getloc() const;189 190    // swap:191    void swap(basic_regex&);192};193 194template<class ForwardIterator>195basic_regex(ForwardIterator, ForwardIterator,196            regex_constants::syntax_option_type = regex_constants::ECMAScript)197    -> basic_regex<typename iterator_traits<ForwardIterator>::value_type>; // C++17198 199typedef basic_regex<char>    regex;200typedef basic_regex<wchar_t> wregex;201 202template <class charT, class traits>203    void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2);204 205template <class BidirectionalIterator>206class sub_match207    : public pair<BidirectionalIterator, BidirectionalIterator>208{209public:210    typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;211    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;212    typedef BidirectionalIterator                                      iterator;213    typedef basic_string<value_type>                                string_type;214 215    bool matched;216 217    constexpr sub_match();218 219    difference_type length() const;220    operator string_type() const;221    string_type str() const;222 223    int compare(const sub_match& s) const;224    int compare(const string_type& s) const;225    int compare(const value_type* s) const;226};227 228typedef sub_match<const char*>             csub_match;229typedef sub_match<const wchar_t*>          wcsub_match;230typedef sub_match<string::const_iterator>  ssub_match;231typedef sub_match<wstring::const_iterator> wssub_match;232 233template <class BiIter>234    bool235    operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);236 237template <class BiIter>238    bool239    operator!=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);240 241template <class BiIter>242    bool243    operator<(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);244 245template <class BiIter>246    bool247    operator<=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);248 249template <class BiIter>250    bool251    operator>=(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);252 253template <class BiIter>254    bool255    operator>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);256 257template <class BiIter, class ST, class SA>258    bool259    operator==(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,260               const sub_match<BiIter>& rhs);261 262template <class BiIter, class ST, class SA>263    bool264    operator!=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,265               const sub_match<BiIter>& rhs);266 267template <class BiIter, class ST, class SA>268    bool269    operator<(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,270              const sub_match<BiIter>& rhs);271 272template <class BiIter, class ST, class SA>273    bool274    operator>(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,275              const sub_match<BiIter>& rhs);276 277template <class BiIter, class ST, class SA>278    bool operator>=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,279                    const sub_match<BiIter>& rhs);280 281template <class BiIter, class ST, class SA>282    bool283    operator<=(const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& lhs,284               const sub_match<BiIter>& rhs);285 286template <class BiIter, class ST, class SA>287    bool288    operator==(const sub_match<BiIter>& lhs,289               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);290 291template <class BiIter, class ST, class SA>292    bool293    operator!=(const sub_match<BiIter>& lhs,294               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);295 296template <class BiIter, class ST, class SA>297    bool298    operator<(const sub_match<BiIter>& lhs,299              const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);300 301template <class BiIter, class ST, class SA>302    bool operator>(const sub_match<BiIter>& lhs,303                   const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);304 305template <class BiIter, class ST, class SA>306    bool307    operator>=(const sub_match<BiIter>& lhs,308               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);309 310template <class BiIter, class ST, class SA>311    bool312    operator<=(const sub_match<BiIter>& lhs,313               const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);314 315template <class BiIter>316    bool317    operator==(typename iterator_traits<BiIter>::value_type const* lhs,318               const sub_match<BiIter>& rhs);319 320template <class BiIter>321    bool322    operator!=(typename iterator_traits<BiIter>::value_type const* lhs,323               const sub_match<BiIter>& rhs);324 325template <class BiIter>326    bool327    operator<(typename iterator_traits<BiIter>::value_type const* lhs,328              const sub_match<BiIter>& rhs);329 330template <class BiIter>331    bool332    operator>(typename iterator_traits<BiIter>::value_type const* lhs,333              const sub_match<BiIter>& rhs);334 335template <class BiIter>336    bool337    operator>=(typename iterator_traits<BiIter>::value_type const* lhs,338               const sub_match<BiIter>& rhs);339 340template <class BiIter>341    bool342    operator<=(typename iterator_traits<BiIter>::value_type const* lhs,343               const sub_match<BiIter>& rhs);344 345template <class BiIter>346    bool347    operator==(const sub_match<BiIter>& lhs,348               typename iterator_traits<BiIter>::value_type const* rhs);349 350template <class BiIter>351    bool352    operator!=(const sub_match<BiIter>& lhs,353               typename iterator_traits<BiIter>::value_type const* rhs);354 355template <class BiIter>356    bool357    operator<(const sub_match<BiIter>& lhs,358              typename iterator_traits<BiIter>::value_type const* rhs);359 360template <class BiIter>361    bool362    operator>(const sub_match<BiIter>& lhs,363              typename iterator_traits<BiIter>::value_type const* rhs);364 365template <class BiIter>366    bool367    operator>=(const sub_match<BiIter>& lhs,368               typename iterator_traits<BiIter>::value_type const* rhs);369 370template <class BiIter>371    bool372    operator<=(const sub_match<BiIter>& lhs,373               typename iterator_traits<BiIter>::value_type const* rhs);374 375template <class BiIter>376    bool377    operator==(typename iterator_traits<BiIter>::value_type const& lhs,378               const sub_match<BiIter>& rhs);379 380template <class BiIter>381    bool382    operator!=(typename iterator_traits<BiIter>::value_type const& lhs,383               const sub_match<BiIter>& rhs);384 385template <class BiIter>386    bool387    operator<(typename iterator_traits<BiIter>::value_type const& lhs,388              const sub_match<BiIter>& rhs);389 390template <class BiIter>391    bool392    operator>(typename iterator_traits<BiIter>::value_type const& lhs,393              const sub_match<BiIter>& rhs);394 395template <class BiIter>396    bool397    operator>=(typename iterator_traits<BiIter>::value_type const& lhs,398               const sub_match<BiIter>& rhs);399 400template <class BiIter>401    bool402    operator<=(typename iterator_traits<BiIter>::value_type const& lhs,403               const sub_match<BiIter>& rhs);404 405template <class BiIter>406    bool407    operator==(const sub_match<BiIter>& lhs,408               typename iterator_traits<BiIter>::value_type const& rhs);409 410template <class BiIter>411    bool412    operator!=(const sub_match<BiIter>& lhs,413               typename iterator_traits<BiIter>::value_type const& rhs);414 415template <class BiIter>416    bool417    operator<(const sub_match<BiIter>& lhs,418              typename iterator_traits<BiIter>::value_type const& rhs);419 420template <class BiIter>421    bool422    operator>(const sub_match<BiIter>& lhs,423              typename iterator_traits<BiIter>::value_type const& rhs);424 425template <class BiIter>426    bool427    operator>=(const sub_match<BiIter>& lhs,428               typename iterator_traits<BiIter>::value_type const& rhs);429 430template <class BiIter>431    bool432    operator<=(const sub_match<BiIter>& lhs,433               typename iterator_traits<BiIter>::value_type const& rhs);434 435template <class charT, class ST, class BiIter>436    basic_ostream<charT, ST>&437    operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);438 439template <class BidirectionalIterator,440          class Allocator = allocator<sub_match<BidirectionalIterator>>>441class match_results442{443public:444    typedef sub_match<BidirectionalIterator>                  value_type;445    typedef const value_type&                                 const_reference;446    typedef value_type&                                       reference;447    typedef /implementation-defined/                          const_iterator;448    typedef const_iterator                                    iterator;449    typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;450    typedef typename allocator_traits<Allocator>::size_type   size_type;451    typedef Allocator                                         allocator_type;452    typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;453    typedef basic_string<char_type>                           string_type;454 455    // construct/copy/destroy:456    explicit match_results(const Allocator& a = Allocator());457    match_results(const match_results& m);458    match_results(match_results&& m) noexcept;459    match_results& operator=(const match_results& m);460    match_results& operator=(match_results&& m);461    ~match_results();462 463    bool ready() const;464 465    // size:466    size_type size() const;467    size_type max_size() const;468    bool empty() const;469 470    // element access:471    difference_type length(size_type sub = 0) const;472    difference_type position(size_type sub = 0) const;473    string_type str(size_type sub = 0) const;474    const_reference operator[](size_type n) const;475 476    const_reference prefix() const;477    const_reference suffix() const;478 479    const_iterator begin() const;480    const_iterator end() const;481    const_iterator cbegin() const;482    const_iterator cend() const;483 484    // format:485    template <class OutputIter>486        OutputIter487        format(OutputIter out, const char_type* fmt_first,488               const char_type* fmt_last,489               regex_constants::match_flag_type flags = regex_constants::format_default) const;490    template <class OutputIter, class ST, class SA>491        OutputIter492        format(OutputIter out, const basic_string<char_type, ST, SA>& fmt,493               regex_constants::match_flag_type flags = regex_constants::format_default) const;494    template <class ST, class SA>495        basic_string<char_type, ST, SA>496        format(const basic_string<char_type, ST, SA>& fmt,497               regex_constants::match_flag_type flags = regex_constants::format_default) const;498    string_type499        format(const char_type* fmt,500               regex_constants::match_flag_type flags = regex_constants::format_default) const;501 502    // allocator:503    allocator_type get_allocator() const;504 505    // swap:506    void swap(match_results& that);507};508 509typedef match_results<const char*>             cmatch;510typedef match_results<const wchar_t*>          wcmatch;511typedef match_results<string::const_iterator>  smatch;512typedef match_results<wstring::const_iterator> wsmatch;513 514template <class BidirectionalIterator, class Allocator>515    bool516    operator==(const match_results<BidirectionalIterator, Allocator>& m1,517               const match_results<BidirectionalIterator, Allocator>& m2);518 519template <class BidirectionalIterator, class Allocator>520    bool521    operator!=(const match_results<BidirectionalIterator, Allocator>& m1,522               const match_results<BidirectionalIterator, Allocator>& m2);523 524template <class BidirectionalIterator, class Allocator>525    void526    swap(match_results<BidirectionalIterator, Allocator>& m1,527         match_results<BidirectionalIterator, Allocator>& m2);528 529template <class BidirectionalIterator, class Allocator, class charT, class traits>530    bool531    regex_match(BidirectionalIterator first, BidirectionalIterator last,532                match_results<BidirectionalIterator, Allocator>& m,533                const basic_regex<charT, traits>& e,534                regex_constants::match_flag_type flags = regex_constants::match_default);535 536template <class BidirectionalIterator, class charT, class traits>537    bool538    regex_match(BidirectionalIterator first, BidirectionalIterator last,539                const basic_regex<charT, traits>& e,540                regex_constants::match_flag_type flags = regex_constants::match_default);541 542template <class charT, class Allocator, class traits>543    bool544    regex_match(const charT* str, match_results<const charT*, Allocator>& m,545                const basic_regex<charT, traits>& e,546                regex_constants::match_flag_type flags = regex_constants::match_default);547 548template <class ST, class SA, class Allocator, class charT, class traits>549    bool550    regex_match(const basic_string<charT, ST, SA>& s,551                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,552                const basic_regex<charT, traits>& e,553                regex_constants::match_flag_type flags = regex_constants::match_default);554 555template <class ST, class SA, class Allocator, class charT, class traits>556    bool557    regex_match(const basic_string<charT, ST, SA>&& s,558                match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,559                const basic_regex<charT, traits>& e,560                regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14561 562template <class charT, class traits>563    bool564    regex_match(const charT* str, const basic_regex<charT, traits>& e,565                regex_constants::match_flag_type flags = regex_constants::match_default);566 567template <class ST, class SA, class charT, class traits>568    bool569    regex_match(const basic_string<charT, ST, SA>& s,570                const basic_regex<charT, traits>& e,571                regex_constants::match_flag_type flags = regex_constants::match_default);572 573template <class BidirectionalIterator, class Allocator, class charT, class traits>574    bool575    regex_search(BidirectionalIterator first, BidirectionalIterator last,576                 match_results<BidirectionalIterator, Allocator>& m,577                 const basic_regex<charT, traits>& e,578                 regex_constants::match_flag_type flags = regex_constants::match_default);579 580template <class BidirectionalIterator, class charT, class traits>581    bool582    regex_search(BidirectionalIterator first, BidirectionalIterator last,583                 const basic_regex<charT, traits>& e,584                 regex_constants::match_flag_type flags = regex_constants::match_default);585 586template <class charT, class Allocator, class traits>587    bool588    regex_search(const charT* str, match_results<const charT*, Allocator>& m,589                 const basic_regex<charT, traits>& e,590                 regex_constants::match_flag_type flags = regex_constants::match_default);591 592template <class charT, class traits>593    bool594    regex_search(const charT* str, const basic_regex<charT, traits>& e,595                 regex_constants::match_flag_type flags = regex_constants::match_default);596 597template <class ST, class SA, class charT, class traits>598    bool599    regex_search(const basic_string<charT, ST, SA>& s,600                 const basic_regex<charT, traits>& e,601                 regex_constants::match_flag_type flags = regex_constants::match_default);602 603template <class ST, class SA, class Allocator, class charT, class traits>604    bool605    regex_search(const basic_string<charT, ST, SA>& s,606                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,607                 const basic_regex<charT, traits>& e,608                 regex_constants::match_flag_type flags = regex_constants::match_default);609 610template <class ST, class SA, class Allocator, class charT, class traits>611    bool612    regex_search(const basic_string<charT, ST, SA>&& s,613                 match_results<typename basic_string<charT, ST, SA>::const_iterator, Allocator>& m,614                 const basic_regex<charT, traits>& e,615                 regex_constants::match_flag_type flags = regex_constants::match_default) = delete; // C++14616 617template <class OutputIterator, class BidirectionalIterator,618          class traits, class charT, class ST, class SA>619    OutputIterator620    regex_replace(OutputIterator out,621                  BidirectionalIterator first, BidirectionalIterator last,622                  const basic_regex<charT, traits>& e,623                  const basic_string<charT, ST, SA>& fmt,624                  regex_constants::match_flag_type flags = regex_constants::match_default);625 626template <class OutputIterator, class BidirectionalIterator,627          class traits, class charT>628    OutputIterator629    regex_replace(OutputIterator out,630                  BidirectionalIterator first, BidirectionalIterator last,631                  const basic_regex<charT, traits>& e, const charT* fmt,632                  regex_constants::match_flag_type flags = regex_constants::match_default);633 634template <class traits, class charT, class ST, class SA, class FST, class FSA>>635    basic_string<charT, ST, SA>636    regex_replace(const basic_string<charT, ST, SA>& s,637                  const basic_regex<charT, traits>& e,638                  const basic_string<charT, FST, FSA>& fmt,639                  regex_constants::match_flag_type flags = regex_constants::match_default);640 641template <class traits, class charT, class ST, class SA>642    basic_string<charT, ST, SA>643    regex_replace(const basic_string<charT, ST, SA>& s,644                  const basic_regex<charT, traits>& e, const charT* fmt,645                  regex_constants::match_flag_type flags = regex_constants::match_default);646 647template <class traits, class charT, class ST, class SA>648    basic_string<charT>649    regex_replace(const charT* s,650                  const basic_regex<charT, traits>& e,651                  const basic_string<charT, ST, SA>& fmt,652                  regex_constants::match_flag_type flags = regex_constants::match_default);653 654template <class traits, class charT>655    basic_string<charT>656    regex_replace(const charT* s,657                  const basic_regex<charT, traits>& e,658                  const charT* fmt,659                  regex_constants::match_flag_type flags = regex_constants::match_default);660 661template <class BidirectionalIterator,662          class charT = typename iterator_traits< BidirectionalIterator>::value_type,663          class traits = regex_traits<charT>>664class regex_iterator665{666public:667    typedef basic_regex<charT, traits>           regex_type;668    typedef match_results<BidirectionalIterator> value_type;669    typedef ptrdiff_t                            difference_type;670    typedef const value_type*                    pointer;671    typedef const value_type&                    reference;672    typedef forward_iterator_tag                 iterator_category;673 674    regex_iterator();675    regex_iterator(BidirectionalIterator a, BidirectionalIterator b,676                   const regex_type& re,677                   regex_constants::match_flag_type m = regex_constants::match_default);678    regex_iterator(_BidirectionalIterator __a, _BidirectionalIterator __b,679                   const regex_type&& __re,680                   regex_constants::match_flag_type __m681                                     = regex_constants::match_default) = delete; // C++14682    regex_iterator(const regex_iterator&);683    regex_iterator& operator=(const regex_iterator&);684 685    bool operator==(const regex_iterator&) const;686    bool operator!=(const regex_iterator&) const;687 688    const value_type& operator*() const;689    const value_type* operator->() const;690 691    regex_iterator& operator++();692    regex_iterator operator++(int);693};694 695typedef regex_iterator<const char*>             cregex_iterator;696typedef regex_iterator<const wchar_t*>          wcregex_iterator;697typedef regex_iterator<string::const_iterator>  sregex_iterator;698typedef regex_iterator<wstring::const_iterator> wsregex_iterator;699 700template <class BidirectionalIterator,701          class charT = typename iterator_traits< BidirectionalIterator>::value_type,702          class traits = regex_traits<charT>>703class regex_token_iterator704{705public:706    typedef basic_regex<charT, traits>       regex_type;707    typedef sub_match<BidirectionalIterator> value_type;708    typedef ptrdiff_t                        difference_type;709    typedef const value_type*                pointer;710    typedef const value_type&                reference;711    typedef forward_iterator_tag             iterator_category;712 713    regex_token_iterator();714    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,715                         const regex_type& re, int submatch = 0,716                         regex_constants::match_flag_type m = regex_constants::match_default);717    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,718                         const regex_type&& re, int submatch = 0,719                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14720    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,721                         const regex_type& re, const vector<int>& submatches,722                         regex_constants::match_flag_type m = regex_constants::match_default);723    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,724                         const regex_type&& re, const vector<int>& submatches,725                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14726    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,727                         const regex_type& re, initializer_list<int> submatches,728                         regex_constants::match_flag_type m = regex_constants::match_default);729    regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,730                         const regex_type&& re, initializer_list<int> submatches,731                         regex_constants::match_flag_type m = regex_constants::match_default) = delete; // C++14732    template <size_t N>733        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,734                             const regex_type& re, const int (&submatches)[N],735                             regex_constants::match_flag_type m = regex_constants::match_default);736    template <size_t N>737        regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,738                             const regex_type& re, const int (&submatches)[N],739                             regex_constants::match_flag_type m = regex_constants::match_default) = delete // C++14;740    regex_token_iterator(const regex_token_iterator&);741    regex_token_iterator& operator=(const regex_token_iterator&);742 743    bool operator==(const regex_token_iterator&) const;744    bool operator!=(const regex_token_iterator&) const;745 746    const value_type& operator*() const;747    const value_type* operator->() const;748 749    regex_token_iterator& operator++();750    regex_token_iterator operator++(int);751};752 753typedef regex_token_iterator<const char*>             cregex_token_iterator;754typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;755typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;756typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;757 758} // std759*/760 761#include <__config>762#include <stdexcept>763#include <__locale>764#include <initializer_list>765#include <utility>766#include <iterator>767#include <string>768#include <memory>769#include <vector>770#include <deque>771#include <version>772 773#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)774#  pragma GCC system_header775#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)776#  pragma clang system_header777#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)778#  pragma system_header779#endif // no system header780 781_LIBCUDACXX_PUSH_MACROS782#include <__undef_macros>783 784 785#define _LIBCUDACXX_REGEX_COMPLEXITY_FACTOR 4096786 787_LIBCUDACXX_BEGIN_NAMESPACE_STD788 789namespace regex_constants790{791 792// syntax_option_type793 794enum syntax_option_type795{796    icase      = 1 << 0,797    nosubs     = 1 << 1,798    optimize   = 1 << 2,799    collate    = 1 << 3,800#ifdef _LIBCUDACXX_ABI_REGEX_CONSTANTS_NONZERO801    ECMAScript = 1 << 9,802#else803    ECMAScript = 0,804#endif805    basic      = 1 << 4,806    extended   = 1 << 5,807    awk        = 1 << 6,808    grep       = 1 << 7,809    egrep      = 1 << 8810};811 812inline constexpr813syntax_option_type __get_grammar(syntax_option_type __g)814{815#ifdef _LIBCUDACXX_ABI_REGEX_CONSTANTS_NONZERO816    return static_cast<syntax_option_type>(__g & 0x3F0);817#else818    return static_cast<syntax_option_type>(__g & 0x1F0);819#endif820}821 822inline _LIBCUDACXX_INLINE_VISIBILITY823constexpr824syntax_option_type825operator~(syntax_option_type __x)826{827    return syntax_option_type(~int(__x) & 0x1FF);828}829 830inline _LIBCUDACXX_INLINE_VISIBILITY831constexpr832syntax_option_type833operator&(syntax_option_type __x, syntax_option_type __y)834{835    return syntax_option_type(int(__x) & int(__y));836}837 838inline _LIBCUDACXX_INLINE_VISIBILITY839constexpr840syntax_option_type841operator|(syntax_option_type __x, syntax_option_type __y)842{843    return syntax_option_type(int(__x) | int(__y));844}845 846inline _LIBCUDACXX_INLINE_VISIBILITY847constexpr848syntax_option_type849operator^(syntax_option_type __x, syntax_option_type __y)850{851    return syntax_option_type(int(__x) ^ int(__y));852}853 854inline _LIBCUDACXX_INLINE_VISIBILITY855syntax_option_type&856operator&=(syntax_option_type& __x, syntax_option_type __y)857{858    __x = __x & __y;859    return __x;860}861 862inline _LIBCUDACXX_INLINE_VISIBILITY863syntax_option_type&864operator|=(syntax_option_type& __x, syntax_option_type __y)865{866    __x = __x | __y;867    return __x;868}869 870inline _LIBCUDACXX_INLINE_VISIBILITY871syntax_option_type&872operator^=(syntax_option_type& __x, syntax_option_type __y)873{874    __x = __x ^ __y;875    return __x;876}877 878// match_flag_type879 880enum match_flag_type881{882    match_default     = 0,883    match_not_bol     = 1 << 0,884    match_not_eol     = 1 << 1,885    match_not_bow     = 1 << 2,886    match_not_eow     = 1 << 3,887    match_any         = 1 << 4,888    match_not_null    = 1 << 5,889    match_continuous  = 1 << 6,890    match_prev_avail  = 1 << 7,891    format_default    = 0,892    format_sed        = 1 << 8,893    format_no_copy    = 1 << 9,894    format_first_only = 1 << 10,895    __no_update_pos   = 1 << 11,896    __full_match      = 1 << 12897};898 899inline _LIBCUDACXX_INLINE_VISIBILITY900constexpr901match_flag_type902operator~(match_flag_type __x)903{904    return match_flag_type(~int(__x) & 0x0FFF);905}906 907inline _LIBCUDACXX_INLINE_VISIBILITY908constexpr909match_flag_type910operator&(match_flag_type __x, match_flag_type __y)911{912    return match_flag_type(int(__x) & int(__y));913}914 915inline _LIBCUDACXX_INLINE_VISIBILITY916constexpr917match_flag_type918operator|(match_flag_type __x, match_flag_type __y)919{920    return match_flag_type(int(__x) | int(__y));921}922 923inline _LIBCUDACXX_INLINE_VISIBILITY924constexpr925match_flag_type926operator^(match_flag_type __x, match_flag_type __y)927{928    return match_flag_type(int(__x) ^ int(__y));929}930 931inline _LIBCUDACXX_INLINE_VISIBILITY932match_flag_type&933operator&=(match_flag_type& __x, match_flag_type __y)934{935    __x = __x & __y;936    return __x;937}938 939inline _LIBCUDACXX_INLINE_VISIBILITY940match_flag_type&941operator|=(match_flag_type& __x, match_flag_type __y)942{943    __x = __x | __y;944    return __x;945}946 947inline _LIBCUDACXX_INLINE_VISIBILITY948match_flag_type&949operator^=(match_flag_type& __x, match_flag_type __y)950{951    __x = __x ^ __y;952    return __x;953}954 955enum error_type956{957    error_collate = 1,958    error_ctype,959    error_escape,960    error_backref,961    error_brack,962    error_paren,963    error_brace,964    error_badbrace,965    error_range,966    error_space,967    error_badrepeat,968    error_complexity,969    error_stack,970    __re_err_grammar,971    __re_err_empty,972    __re_err_unknown973};974 975}  // regex_constants976 977class _LIBCUDACXX_EXCEPTION_ABI regex_error978    : public runtime_error979{980    regex_constants::error_type __code_;981public:982    explicit regex_error(regex_constants::error_type __ecode);983    virtual ~regex_error() throw();984     _LIBCUDACXX_INLINE_VISIBILITY985    regex_constants::error_type code() const {return __code_;}986};987 988template <regex_constants::error_type _Ev>989_LIBCUDACXX_NORETURN inline _LIBCUDACXX_INLINE_VISIBILITY990void __throw_regex_error()991{992#ifndef _LIBCUDACXX_NO_EXCEPTIONS993    throw regex_error(_Ev);994#else995    _CUDA_VSTD::abort();996#endif997}998 999template <class _CharT>1000struct _LIBCUDACXX_TEMPLATE_VIS regex_traits1001{1002public:1003    typedef _CharT                  char_type;1004    typedef basic_string<char_type> string_type;1005    typedef locale                  locale_type;1006    typedef ctype_base::mask        char_class_type;1007 1008    static const char_class_type __regex_word = ctype_base::__regex_word;1009private:1010    locale __loc_;1011    const ctype<char_type>* __ct_;1012    const collate<char_type>* __col_;1013 1014public:1015    regex_traits();1016 1017    _LIBCUDACXX_INLINE_VISIBILITY1018    static size_t length(const char_type* __p)1019        {return char_traits<char_type>::length(__p);}1020    _LIBCUDACXX_INLINE_VISIBILITY1021    char_type translate(char_type __c) const {return __c;}1022    char_type translate_nocase(char_type __c) const;1023    template <class _ForwardIterator>1024        string_type1025        transform(_ForwardIterator __f, _ForwardIterator __l) const;1026    template <class _ForwardIterator>1027        _LIBCUDACXX_INLINE_VISIBILITY1028        string_type1029        transform_primary( _ForwardIterator __f, _ForwardIterator __l) const1030            {return __transform_primary(__f, __l, char_type());}1031    template <class _ForwardIterator>1032        _LIBCUDACXX_INLINE_VISIBILITY1033        string_type1034        lookup_collatename(_ForwardIterator __f, _ForwardIterator __l) const1035            {return __lookup_collatename(__f, __l, char_type());}1036    template <class _ForwardIterator>1037        _LIBCUDACXX_INLINE_VISIBILITY1038        char_class_type1039        lookup_classname(_ForwardIterator __f, _ForwardIterator __l,1040                         bool __icase = false) const1041            {return __lookup_classname(__f, __l, __icase, char_type());}1042    bool isctype(char_type __c, char_class_type __m) const;1043    _LIBCUDACXX_INLINE_VISIBILITY1044    int value(char_type __ch, int __radix) const1045        {return __regex_traits_value(__ch, __radix);}1046    locale_type imbue(locale_type __l);1047    _LIBCUDACXX_INLINE_VISIBILITY1048    locale_type getloc()const {return __loc_;}1049 1050private:1051    void __init();1052 1053    template <class _ForwardIterator>1054        string_type1055        __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;1056    template <class _ForwardIterator>1057        string_type1058        __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1059 1060    template <class _ForwardIterator>1061        string_type1062        __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;1063    template <class _ForwardIterator>1064        string_type1065        __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1066 1067    template <class _ForwardIterator>1068        char_class_type1069        __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,1070                           bool __icase, char) const;1071    template <class _ForwardIterator>1072        char_class_type1073        __lookup_classname(_ForwardIterator __f, _ForwardIterator __l,1074                           bool __icase, wchar_t) const;1075 1076    static int __regex_traits_value(unsigned char __ch, int __radix);1077    _LIBCUDACXX_INLINE_VISIBILITY1078    int __regex_traits_value(char __ch, int __radix) const1079        {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);}1080    _LIBCUDACXX_INLINE_VISIBILITY1081    int __regex_traits_value(wchar_t __ch, int __radix) const;1082};1083 1084template <class _CharT>1085const typename regex_traits<_CharT>::char_class_type1086regex_traits<_CharT>::__regex_word;1087 1088template <class _CharT>1089regex_traits<_CharT>::regex_traits()1090{1091    __init();1092}1093 1094template <class _CharT>1095typename regex_traits<_CharT>::char_type1096regex_traits<_CharT>::translate_nocase(char_type __c) const1097{1098    return __ct_->tolower(__c);1099}1100 1101template <class _CharT>1102template <class _ForwardIterator>1103typename regex_traits<_CharT>::string_type1104regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) const1105{1106    string_type __s(__f, __l);1107    return __col_->transform(__s.data(), __s.data() + __s.size());1108}1109 1110template <class _CharT>1111void1112regex_traits<_CharT>::__init()1113{1114    __ct_ = &use_facet<ctype<char_type> >(__loc_);1115    __col_ = &use_facet<collate<char_type> >(__loc_);1116}1117 1118template <class _CharT>1119typename regex_traits<_CharT>::locale_type1120regex_traits<_CharT>::imbue(locale_type __l)1121{1122    locale __r = __loc_;1123    __loc_ = __l;1124    __init();1125    return __r;1126}1127 1128// transform_primary is very FreeBSD-specific1129 1130template <class _CharT>1131template <class _ForwardIterator>1132typename regex_traits<_CharT>::string_type1133regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,1134                                          _ForwardIterator __l, char) const1135{1136    const string_type __s(__f, __l);1137    string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());1138    switch (__d.size())1139    {1140    case 1:1141        break;1142    case 12:1143        __d[11] = __d[3];1144        break;1145    default:1146        __d.clear();1147        break;1148    }1149    return __d;1150}1151 1152template <class _CharT>1153template <class _ForwardIterator>1154typename regex_traits<_CharT>::string_type1155regex_traits<_CharT>::__transform_primary(_ForwardIterator __f,1156                                          _ForwardIterator __l, wchar_t) const1157{1158    const string_type __s(__f, __l);1159    string_type __d = __col_->transform(__s.data(), __s.data() + __s.size());1160    switch (__d.size())1161    {1162    case 1:1163        break;1164    case 3:1165        __d[2] = __d[0];1166        break;1167    default:1168        __d.clear();1169        break;1170    }1171    return __d;1172}1173 1174// lookup_collatename is very FreeBSD-specific1175 1176_LIBCUDACXX_FUNC_VIS string __get_collation_name(const char* __s);1177 1178template <class _CharT>1179template <class _ForwardIterator>1180typename regex_traits<_CharT>::string_type1181regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f,1182                                           _ForwardIterator __l, char) const1183{1184    string_type __s(__f, __l);1185    string_type __r;1186    if (!__s.empty())1187    {1188        __r = __get_collation_name(__s.c_str());1189        if (__r.empty() && __s.size() <= 2)1190        {1191            __r = __col_->transform(__s.data(), __s.data() + __s.size());1192            if (__r.size() == 1 || __r.size() == 12)1193                __r = __s;1194            else1195                __r.clear();1196        }1197    }1198    return __r;1199}1200 

Showing the first 1,200 of 6651 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai