]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <HTML> | |
3 | <HEAD> | |
4 | <TITLE>Class Template basic_grep_filter</TITLE> | |
5 | <LINK REL="stylesheet" HREF="../../../../boost.css"> | |
6 | <LINK REL="stylesheet" HREF="../theme/iostreams.css"> | |
7 | </HEAD> | |
8 | <BODY> | |
9 | ||
10 | <!-- Begin Banner --> | |
11 | ||
12 | <H1 CLASS="title">Class Template <CODE>basic_grep_filter</CODE></H1> | |
13 | <HR CLASS="banner"> | |
14 | ||
15 | <!-- End Banner --> | |
16 | ||
17 | <DL class="page-index"> | |
18 | <DT><A href="#description">Description</A></DT> | |
19 | <DT><A href="#headers">Headers</A></DT> | |
20 | <DT><A href="#installation">Installation</A></DT> | |
21 | <DT><A href="#reference">Reference</A></DT> | |
22 | </DL> | |
23 | ||
24 | <HR> | |
25 | ||
26 | <A NAME="description"></A> | |
27 | <H2>Description</H2> | |
28 | ||
29 | <P> | |
30 | The class template <CODE>basic_grep_filter</CODE> filters a character sequence line by line using a regular expression provided at construction, in a manner similar to the command-line utility <i>grep</i> (<A CLASS="bib_ref" HREF="../bibliography.html#grep">[IEEE]</A>). The filter uses regular expressions from the <A HREF="http://www.boost.org/libs/regex" TARGET="_top">Boost Regular Expression Library</A> (<A CLASS="bib_ref" HREF="../bibliography.html#maddock">[Maddock]</A>). | |
31 | </P> | |
32 | <P> | |
33 | By default, the filtered character sequence consists of those lines of the unfiltered sequence that contain a subsequence matching the regular expression. By specifying appropriate options at construction, <CODE>basic_grep_filter</CODE> can be made to pass through only those lines which exactly match the regular expression (as if the option <i>-x</i> had been passed to the command-line utility) or only those lines that <i>do not</i> contain a match (as if the option <i>-v</i> had been passed to the command-line utility). | |
34 | </P> | |
35 | <P> | |
36 | A running count of the lines in the filtered character sequence is available via the member function <code><a href="#count">count</a></code>. | |
37 | </P> | |
38 | ||
39 | <A NAME="headers"></A> | |
40 | <H2>Headers</H2> | |
41 | ||
42 | <DL class="page-index"> | |
43 | <DT><A CLASS="header" HREF="../../../../boost/iostreams/filter/grep.hpp"><CODE><boost/iostreams/filter/grep.hpp></CODE></A></DT> | |
44 | </DL> | |
45 | ||
46 | <A NAME="installation"></A> | |
47 | <H2>Installation</H2> | |
48 | ||
49 | <P> | |
50 | The template <CODE>basic_grep_filter</CODE> uses the <A HREF="http://www.boost.org/libs/regex" TARGET="_top">Boost Regular Expression Library</A>, which must be built separately. See <A HREF="http://www.boost.org/libs/regex/doc/html/boost_regex/install.html" TARGET="_top">here</A> for details. | |
51 | </P> | |
52 | ||
53 | <A NAME="reference"></A> | |
54 | <H2>Reference</H2> | |
55 | ||
56 | <H4>Synopsis</H4> | |
57 | ||
58 | <PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams { | |
59 | ||
60 | <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/function.hpp" TARGET="_top"><SPAN CLASS="literal"><boost/function.hpp></SPAN></A> | |
61 | <SPAN CLASS="preprocessor">#include</SPAN> <A CLASS="header" HREF="../../../../boost/regex.hpp" TARGET="_top"><SPAN CLASS="literal"><boost/regex.hpp></SPAN></A> | |
62 | ||
63 | <SPAN CLASS="keyword">namespace</SPAN> grep { | |
64 | ||
65 | <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> invert; | |
66 | <SPAN CLASS="keyword">const</SPAN> <SPAN CLASS="keyword">int</SPAN> whole_line; | |
67 | ||
68 | } | |
69 | ||
70 | <SPAN CLASS="keyword">template</SPAN>< <SPAN CLASS="keyword">typename</SPAN> <A HREF="#template_params" CLASS="documented">Ch</A>, | |
71 | <SPAN CLASS="keyword">typename</SPAN> <A HREF="#template_params" CLASS="documented">Tr</A> = regex_traits<Ch>, | |
72 | <SPAN CLASS="keyword">typename</SPAN> <A HREF="#template_params" CLASS="documented">Alloc</A> = std::allocator<Ch> > | |
73 | <SPAN CLASS="keyword">class</SPAN> <A HREF="#template_params" CLASS="documented">basic_grep_filter</A> { | |
74 | <SPAN CLASS="keyword">public:</SPAN> | |
75 | <A CLASS="documented" HREF="#constructor">basic_grep_filter</A>( <SPAN CLASS="keyword">const</SPAN> basic_regex<Ch, Tr, Alloc>& pattern, | |
76 | regex_constants::match_flag_type flags = | |
77 | regex_constants::match_default, | |
78 | <SPAN CLASS="keyword">int</SPAN> options = <SPAN CLASS="numeric_literal">0</SPAN> ); | |
79 | <SPAN CLASS="keyword">int</SPAN> <A CLASS="documented" HREF="#count">count</A>() <SPAN CLASS="keyword">const</SPAN>; | |
80 | }; | |
81 | ||
82 | <SPAN CLASS="keyword">typedef</SPAN> basic_grep_filter<<SPAN CLASS="keyword">char</SPAN>> <SPAN CLASS="defined">grep_filter</SPAN>; | |
83 | <SPAN CLASS="keyword">typedef</SPAN> basic_grep_filter<<SPAN CLASS="keyword">wchar_t</SPAN>> <SPAN CLASS="defined">wgrep_filter</SPAN>; | |
84 | ||
85 | } } // End namespace boost::io</PRE> | |
86 | ||
87 | <A NAME="template_params"></A> | |
88 | <H4>Template parameters</H4> | |
89 | ||
90 | <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> | |
91 | <TR> | |
92 | <TR> | |
93 | <TD VALIGN="top"><I>Ch</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
94 | <TD>The character type</TD> | |
95 | </TR> | |
96 | <TR> | |
97 | <TD VALIGN="top"><I>Tr</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
98 | <TD>The <A HREF="http://www.boost.org/libs/regex/doc/html/boost_regex/ref/regex_traits.html" TARGET="_top">regular expression traits</A> type</TD> | |
99 | </TR> | |
100 | <TR> | |
101 | <TD VALIGN="top"><I>Alloc</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
102 | <TD>A standard library allocator type (<A CLASS="bib_ref" HREF="../bibliography.html#iso">[ISO]</A>, 20.1.5), used to allocate character buffers</TD> | |
103 | </TR> | |
104 | </TABLE> | |
105 | ||
106 | <A NAME="constructor"></A> | |
107 | <H4><CODE>basic_grep_filter::basic_grep_filter</CODE></H4> | |
108 | ||
109 | <PRE CLASS="broken_ie"> <B>basic_grep_filter</B>( <SPAN CLASS="keyword">const</SPAN> basic_regex<Ch, Tr, Alloc>& pattern, | |
110 | regex_constants::match_flag_type flags = | |
111 | regex_constants::match_default, | |
112 | <SPAN CLASS="keyword">int</SPAN> options = <SPAN CLASS="numeric_literal">0</SPAN> );</PRE> | |
113 | ||
114 | <P>Constructs a <CODE>basic_grep_filter</CODE> from the given regular expression, match flags, and grep options. The parameters have the following interpretations:</P> | |
115 | ||
116 | <TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2> | |
117 | <TR> | |
118 | <TR> | |
119 | <TD VALIGN="top"><I>pattern</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
120 | <TD>The regular expression to be matched against the stream of unfiltered data</TD> | |
121 | </TR> | |
122 | <TR> | |
123 | <TD VALIGN="top"><I>flags</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
124 | <TD>The flags passed to <A HREF="http://www.boost.org/libs/regex/doc/html/boost_regex/ref/regex_search.html" TARGET="_top">regex_search</A> or <A HREF="http://www.boost.org/libs/regex/doc/html/boost_regex/ref/regex_match.html" TARGET="_top">regex_match</A> to specify regular expression matching behavior</TD> | |
125 | </TR> | |
126 | <TR> | |
127 | <TD VALIGN="top"><I>options</I></TD><TD WIDTH="2em" VALIGN="top">-</TD> | |
128 | <TD>A bitwise OR of zero or more constants from the namespace <CODE>boost::iostreams::grep</CODE>. Currently two constants are recongnized: <CODE>grep::whole_line</CODE> causes the filter to pass through only those lines which exactly match the regular expression, and <CODE>grep::invert</CODE> causes the filter to pass through only those lines that <i>do not</i> contain a match.</TD> | |
129 | </TR> | |
130 | </TABLE> | |
131 | ||
132 | </P> | |
133 | ||
134 | <A NAME="count"></A> | |
135 | <H4><CODE>basic_grep_filter::count</CODE></H4> | |
136 | ||
137 | <A NAME="second_constructor"></A> | |
138 | ||
139 | <PRE CLASS="broken_ie"> <SPAN CLASS="keyword">int</SPAN> count() <SPAN CLASS="keyword">const</SPAN>;</PRE> | |
140 | ||
141 | <P>Returns a running count of the lines passed through from the unfiltered character sequence to the filtered character sequence. The count is reset to zero automatically when the filter begins processing a new character sequence.</P> | |
142 | ||
143 | <!-- Begin Footer --> | |
144 | ||
145 | <HR> | |
146 | ||
147 | <P CLASS="copyright">© Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a></P> | |
148 | <P CLASS="copyright"> | |
149 | Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>) | |
150 | </P> | |
151 | ||
152 | <!-- End Footer --> | |
153 | ||
154 | </BODY> |