Chris@16: /* Chris@16: * Chris@16: * Copyright (c) 1998-2002 Chris@16: * John Maddock Chris@16: * Chris@16: * Use, modification and distribution are subject to the Chris@16: * Boost Software License, Version 1.0. (See accompanying file Chris@16: * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Chris@16: */ Chris@16: Chris@16: /* Chris@16: * LOCATION: see http://www.boost.org for most recent version. Chris@16: * FILE regex_search.hpp Chris@16: * VERSION see Chris@16: * DESCRIPTION: Provides regex_search implementation. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP Chris@16: #define BOOST_REGEX_V4_REGEX_SEARCH_HPP Chris@16: Chris@16: Chris@16: namespace boost{ Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable: 4103) Chris@16: #endif Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_PREFIX Chris@16: #endif Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: template Chris@16: bool regex_search(BidiIterator first, BidiIterator last, Chris@16: match_results& m, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(first, last, m, e, flags, first); Chris@16: } Chris@16: Chris@16: template Chris@16: bool regex_search(BidiIterator first, BidiIterator last, Chris@16: match_results& m, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags, Chris@16: BidiIterator base) Chris@16: { Chris@16: if(e.flags() & regex_constants::failbit) Chris@16: return false; Chris@16: Chris@16: re_detail::perl_matcher matcher(first, last, m, e, flags, base); Chris@16: return matcher.find(); Chris@16: } Chris@16: Chris@16: // Chris@16: // regex_search convenience interfaces: Chris@16: #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING Chris@16: // Chris@16: // this isn't really a partial specialisation, but template function Chris@16: // overloading - if the compiler doesn't support partial specialisation Chris@16: // then it really won't support this either: Chris@16: template Chris@16: inline bool regex_search(const charT* str, Chris@16: match_results& m, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(str, str + traits::length(str), m, e, flags); Chris@16: } Chris@16: Chris@16: template Chris@16: inline bool regex_search(const std::basic_string& s, Chris@16: match_results::const_iterator, Allocator>& m, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(s.begin(), s.end(), m, e, flags); Chris@16: } Chris@16: #else // partial overloads: Chris@16: inline bool regex_search(const char* str, Chris@16: cmatch& m, Chris@16: const regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(str, str + regex::traits_type::length(str), m, e, flags); Chris@16: } Chris@16: inline bool regex_search(const char* first, const char* last, Chris@16: const regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: cmatch m; Chris@16: return regex_search(first, last, m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_WREGEX Chris@16: inline bool regex_search(const wchar_t* str, Chris@16: wcmatch& m, Chris@16: const wregex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(str, str + wregex::traits_type::length(str), m, e, flags); Chris@16: } Chris@16: inline bool regex_search(const wchar_t* first, const wchar_t* last, Chris@16: const wregex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: wcmatch m; Chris@16: return regex_search(first, last, m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: #endif Chris@16: inline bool regex_search(const std::string& s, Chris@16: smatch& m, Chris@16: const regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(s.begin(), s.end(), m, e, flags); Chris@16: } Chris@16: #if !defined(BOOST_NO_WREGEX) Chris@16: inline bool regex_search(const std::basic_string& s, Chris@16: wsmatch& m, Chris@16: const wregex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(s.begin(), s.end(), m, e, flags); Chris@16: } Chris@16: #endif Chris@16: Chris@16: #endif Chris@16: Chris@16: template Chris@16: bool regex_search(BidiIterator first, BidiIterator last, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: if(e.flags() & regex_constants::failbit) Chris@16: return false; Chris@16: Chris@16: match_results m; Chris@16: typedef typename match_results::allocator_type match_alloc_type; Chris@16: re_detail::perl_matcher matcher(first, last, m, e, flags | regex_constants::match_any, first); Chris@16: return matcher.find(); Chris@16: } Chris@16: Chris@16: #ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING Chris@16: Chris@16: template Chris@16: inline bool regex_search(const charT* str, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(str, str + traits::length(str), e, flags); Chris@16: } Chris@16: Chris@16: template Chris@16: inline bool regex_search(const std::basic_string& s, Chris@16: const basic_regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: return regex_search(s.begin(), s.end(), e, flags); Chris@16: } Chris@16: #else // non-template function overloads Chris@16: inline bool regex_search(const char* str, Chris@16: const regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: cmatch m; Chris@16: return regex_search(str, str + regex::traits_type::length(str), m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: #ifndef BOOST_NO_WREGEX Chris@16: inline bool regex_search(const wchar_t* str, Chris@16: const wregex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: wcmatch m; Chris@16: return regex_search(str, str + wregex::traits_type::length(str), m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: #endif Chris@16: inline bool regex_search(const std::string& s, Chris@16: const regex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: smatch m; Chris@16: return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: #if !defined(BOOST_NO_WREGEX) Chris@16: inline bool regex_search(const std::basic_string& s, Chris@16: const wregex& e, Chris@16: match_flag_type flags = match_default) Chris@16: { Chris@16: wsmatch m; Chris@16: return regex_search(s.begin(), s.end(), m, e, flags | regex_constants::match_any); Chris@16: } Chris@16: Chris@16: #endif // BOOST_NO_WREGEX Chris@16: Chris@16: #endif // partial overload Chris@16: Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(push) Chris@16: #pragma warning(disable: 4103) Chris@16: #endif Chris@16: #ifdef BOOST_HAS_ABI_HEADERS Chris@16: # include BOOST_ABI_SUFFIX Chris@16: #endif Chris@16: #ifdef BOOST_MSVC Chris@16: #pragma warning(pop) Chris@16: #endif Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #endif // BOOST_REGEX_V4_REGEX_SEARCH_HPP Chris@16: Chris@16: