3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=US-ASCII">
4 <title>POSIX Compatible C API's
</title>
5 <link rel=
"stylesheet" href=
"../../../../../../doc/src/boostbook.css" type=
"text/css">
6 <meta name=
"generator" content=
"DocBook XSL Stylesheets V1.77.1">
7 <link rel=
"home" href=
"../../index.html" title=
"Boost.Regex 5.1.2">
8 <link rel=
"up" href=
"../ref.html" title=
"Reference">
9 <link rel=
"prev" href=
"non_std_strings/mfc_strings/mfc_iter.html" title=
"Iterating Over the Matches Within An MFC String">
10 <link rel=
"next" href=
"concepts.html" title=
"Concepts">
12 <body bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF">
13 <table cellpadding=
"2" width=
"100%"><tr>
14 <td valign=
"top"><img alt=
"Boost C++ Libraries" width=
"277" height=
"86" src=
"../../../../../../boost.png"></td>
15 <td align=
"center"><a href=
"../../../../../../index.html">Home
</a></td>
16 <td align=
"center"><a href=
"../../../../../../libs/libraries.htm">Libraries
</a></td>
17 <td align=
"center"><a href=
"http://www.boost.org/users/people.html">People
</a></td>
18 <td align=
"center"><a href=
"http://www.boost.org/users/faq.html">FAQ
</a></td>
19 <td align=
"center"><a href=
"../../../../../../more/index.htm">More
</a></td>
22 <div class=
"spirit-nav">
23 <a accesskey=
"p" href=
"non_std_strings/mfc_strings/mfc_iter.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../ref.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"concepts.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>
26 <div class=
"titlepage"><div><div><h3 class=
"title">
27 <a name=
"boost_regex.ref.posix"></a><a class=
"link" href=
"posix.html" title=
"POSIX Compatible C API's">POSIX Compatible C API's
</a>
28 </h3></div></div></div>
29 <div class=
"note"><table border=
"0" summary=
"Note">
31 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Note]" src=
"../../../../../../doc/src/images/note.png"></td>
32 <th align=
"left">Note
</th>
34 <tr><td align=
"left" valign=
"top"><p>
35 this is an abridged reference to the POSIX API functions, these are provided
36 for compatibility with other libraries, rather than as an API to be used
37 in new code (unless you need access from a language other than C++). This
38 version of these functions should also happily coexist with other versions,
39 as the names used are macros that expand to the actual function names.
42 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">cregex
</span><span class=
"special">.
</span><span class=
"identifier">hpp
</span><span class=
"special">></span>
47 <pre class=
"programlisting"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">regex
</span><span class=
"special">.
</span><span class=
"identifier">h
</span><span class=
"special">></span>
50 The following functions are available for users who need a POSIX compatible
51 C library, they are available in both Unicode and narrow character versions,
52 the standard POSIX API names are macros that expand to one version or the
53 other depending upon whether UNICODE is defined or not.
55 <div class=
"important"><table border=
"0" summary=
"Important">
57 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Important]" src=
"../../../../../../doc/src/images/important.png"></td>
58 <th align=
"left">Important
</th>
60 <tr><td align=
"left" valign=
"top"><p>
61 Note that all the symbols defined here are enclosed inside namespace
<code class=
"computeroutput"><span class=
"identifier">boost
</span></code> when used in C++ programs, unless
62 you use
<code class=
"computeroutput"><span class=
"preprocessor">#include
</span> <span class=
"special"><</span><span class=
"identifier">boost
</span><span class=
"special">/
</span><span class=
"identifier">regex
</span><span class=
"special">.
</span><span class=
"identifier">h
</span><span class=
"special">></span></code>
63 instead - in which case the symbols are still defined in namespace boost,
64 but are made available in the global namespace as well.
68 The functions are defined as:
70 <pre class=
"programlisting"><span class=
"keyword">extern
</span> <span class=
"string">"C"</span> <span class=
"special">{
</span>
72 <span class=
"keyword">struct
</span> <span class=
"identifier">regex_tA
</span><span class=
"special">;
</span>
73 <span class=
"keyword">struct
</span> <span class=
"identifier">regex_tW
</span><span class=
"special">;
</span>
75 <span class=
"keyword">int
</span> <span class=
"identifier">regcompA
</span><span class=
"special">(
</span><span class=
"identifier">regex_tA
</span><span class=
"special">*,
</span> <span class=
"keyword">const
</span> <span class=
"keyword">char
</span><span class=
"special">*,
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
76 <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span> <span class=
"identifier">regerrorA
</span><span class=
"special">(
</span><span class=
"keyword">int
</span><span class=
"special">,
</span> <span class=
"keyword">const
</span> <span class=
"identifier">regex_tA
</span><span class=
"special">*,
</span> <span class=
"keyword">char
</span><span class=
"special">*,
</span> <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
77 <span class=
"keyword">int
</span> <span class=
"identifier">regexecA
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">regex_tA
</span><span class=
"special">*,
</span> <span class=
"keyword">const
</span> <span class=
"keyword">char
</span><span class=
"special">*,
</span> <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span><span class=
"special">,
</span> <span class=
"identifier">regmatch_t
</span><span class=
"special">*,
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
78 <span class=
"keyword">void
</span> <span class=
"identifier">regfreeA
</span><span class=
"special">(
</span><span class=
"identifier">regex_tA
</span><span class=
"special">*);
</span>
80 <span class=
"keyword">int
</span> <span class=
"identifier">regcompW
</span><span class=
"special">(
</span><span class=
"identifier">regex_tW
</span><span class=
"special">*,
</span> <span class=
"keyword">const
</span> <span class=
"keyword">wchar_t
</span><span class=
"special">*,
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
81 <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span> <span class=
"identifier">regerrorW
</span><span class=
"special">(
</span><span class=
"keyword">int
</span><span class=
"special">,
</span> <span class=
"keyword">const
</span> <span class=
"identifier">regex_tW
</span><span class=
"special">*,
</span> <span class=
"keyword">wchar_t
</span><span class=
"special">*,
</span> <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
82 <span class=
"keyword">int
</span> <span class=
"identifier">regexecW
</span><span class=
"special">(
</span><span class=
"keyword">const
</span> <span class=
"identifier">regex_tW
</span><span class=
"special">*,
</span> <span class=
"keyword">const
</span> <span class=
"keyword">wchar_t
</span><span class=
"special">*,
</span> <span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span><span class=
"special">,
</span> <span class=
"identifier">regmatch_t
</span><span class=
"special">*,
</span> <span class=
"keyword">int
</span><span class=
"special">);
</span>
83 <span class=
"keyword">void
</span> <span class=
"identifier">regfreeW
</span><span class=
"special">(
</span><span class=
"identifier">regex_tW
</span><span class=
"special">*);
</span>
85 <span class=
"preprocessor">#ifdef
</span> <span class=
"identifier">UNICODE
</span>
86 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regcomp
</span> <span class=
"identifier">regcompW
</span>
87 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regerror
</span> <span class=
"identifier">regerrorW
</span>
88 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regexec
</span> <span class=
"identifier">regexecW
</span>
89 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regfree
</span> <span class=
"identifier">regfreeW
</span>
90 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regex_t
</span> <span class=
"identifier">regex_tW
</span>
91 <span class=
"preprocessor">#else
</span>
92 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regcomp
</span> <span class=
"identifier">regcompA
</span>
93 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regerror
</span> <span class=
"identifier">regerrorA
</span>
94 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regexec
</span> <span class=
"identifier">regexecA
</span>
95 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regfree
</span> <span class=
"identifier">regfreeA
</span>
96 <span class=
"preprocessor">#define
</span> <span class=
"identifier">regex_t
</span> <span class=
"identifier">regex_tA
</span>
97 <span class=
"preprocessor">#endif
</span>
98 <span class=
"special">}
</span>
101 All the functions operate on structure regex_t, which exposes two public
104 <div class=
"informaltable"><table class=
"table">
125 <code class=
"computeroutput"><span class=
"keyword">unsigned
</span> <span class=
"keyword">int
</span>
126 <span class=
"identifier">re_nsub
</span></code>
131 This is filled in by
<code class=
"computeroutput"><span class=
"identifier">regcomp
</span></code>
132 and indicates the number of sub-expressions contained in the regular
140 <code class=
"computeroutput"><span class=
"keyword">const
</span> <span class=
"identifier">TCHAR
</span><span class=
"special">*
</span> <span class=
"identifier">re_endp
</span></code>
145 Points to the end of the expression to compile when the flag REG_PEND
152 <div class=
"note"><table border=
"0" summary=
"Note">
154 <td rowspan=
"2" align=
"center" valign=
"top" width=
"25"><img alt=
"[Note]" src=
"../../../../../../doc/src/images/note.png"></td>
155 <th align=
"left">Note
</th>
157 <tr><td align=
"left" valign=
"top"><p>
158 <code class=
"computeroutput"><span class=
"identifier">regex_t
</span></code> is actually a
159 <code class=
"computeroutput"><span class=
"preprocessor">#define
</span></code> - it is either
160 <code class=
"computeroutput"><span class=
"identifier">regex_tA
</span></code> or
<code class=
"computeroutput"><span class=
"identifier">regex_tW
</span></code> depending upon whether
<code class=
"computeroutput"><span class=
"identifier">UNICODE
</span></code> is defined or not,
<code class=
"computeroutput"><span class=
"identifier">TCHAR
</span></code> is either
<code class=
"computeroutput"><span class=
"keyword">char
</span></code>
161 or
<code class=
"computeroutput"><span class=
"keyword">wchar_t
</span></code> again depending
162 upon the macro
<code class=
"computeroutput"><span class=
"identifier">UNICODE
</span></code>.
165 <a name=
"regcomp"></a><h5>
166 <a name=
"boost_regex.ref.posix.h0"></a>
167 <span class=
"phrase"><a name=
"boost_regex.ref.posix.regcomp"></a></span><a class=
"link" href=
"posix.html#boost_regex.ref.posix.regcomp">regcomp
</a>
170 <code class=
"computeroutput"><span class=
"identifier">regcomp
</span></code> takes a pointer to
171 a
<code class=
"computeroutput"><span class=
"identifier">regex_t
</span></code>, a pointer to the
172 expression to compile and a flags parameter which can be a combination of:
174 <div class=
"informaltable"><table class=
"table">
200 Compiles modern regular expressions. Equivalent to
<code class=
"computeroutput"><span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">char_classes
</span> <span class=
"special">|
</span>
201 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">intervals
</span> <span class=
"special">|
</span>
202 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">bk_refs
</span></code>.
214 Compiles basic (obsolete) regular expression syntax. Equivalent
215 to
<code class=
"computeroutput"><span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">char_classes
</span> <span class=
"special">|
</span>
216 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">intervals
</span> <span class=
"special">|
</span>
217 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">limited_ops
</span> <span class=
"special">|
</span>
218 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">bk_braces
</span> <span class=
"special">|
</span>
219 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">bk_parens
</span> <span class=
"special">|
</span>
220 <span class=
"identifier">regbase
</span><span class=
"special">::
</span><span class=
"identifier">bk_refs
</span></code>.
232 All characters are ordinary, the expression is a literal string.
244 Compiles for matching that ignores character case.
256 Has no effect in this library.
268 When this flag is set a dot does not match the newline character.
280 When this flag is set the re_endp parameter of the regex_t structure
281 must point to the end of the regular expression to compile.
293 When this flag is set then locale dependent collation for character
294 ranges is turned off.
306 When this flag is set, then escape sequences are permitted in bracket
307 expressions (character sets).
319 When this flag is set then the newline character is equivalent
320 to the alternation operator |.
332 Compiles Perl like regular expressions.
344 A shortcut for awk-like behavior:
<code class=
"computeroutput"><span class=
"identifier">REG_EXTENDED
</span>
345 <span class=
"special">|
</span> <span class=
"identifier">REG_ESCAPE_IN_LISTS
</span></code>
357 A shortcut for grep like behavior:
<code class=
"computeroutput"><span class=
"identifier">REG_BASIC
</span>
358 <span class=
"special">|
</span> <span class=
"identifier">REG_NEWLINE_ALT
</span></code>
370 A shortcut for egrep like behavior:
<code class=
"computeroutput"><span class=
"identifier">REG_EXTENDED
</span>
371 <span class=
"special">|
</span> <span class=
"identifier">REG_NEWLINE_ALT
</span></code>
377 <a name=
"regerror"></a><h5>
378 <a name=
"boost_regex.ref.posix.h1"></a>
379 <span class=
"phrase"><a name=
"boost_regex.ref.posix.regerror"></a></span><a class=
"link" href=
"posix.html#boost_regex.ref.posix.regerror">regerror
</a>
382 regerror takes the following parameters, it maps an error code to a human
385 <div class=
"informaltable"><table class=
"table">
423 The regular expression (can be null).
435 The buffer to fill in with the error message.
442 unsigned int buf_size
454 If the error code is OR'ed with REG_ITOA then the message that results is
455 the printable name of the code rather than a message, for example
"REG_BADPAT".
456 If the code is REG_ATIO then e must not be null and e-
>re_pend must point
457 to the printable name of an error code, the return value is then the value
458 of the error code. For any other value of code, the return value is the number
459 of characters in the error message, if the return value is greater than or
460 equal to buf_size then regerror will have to be called again with a larger
463 <a name=
"regexec"></a><h5>
464 <a name=
"boost_regex.ref.posix.h2"></a>
465 <span class=
"phrase"><a name=
"boost_regex.ref.posix.regexec"></a></span><a class=
"link" href=
"posix.html#boost_regex.ref.posix.regexec">regexec
</a>
468 regexec finds the first occurrence of expression e within string buf. If
469 len is non-zero then
<span class=
"emphasis"><em>*m
</em></span> is filled in with what matched
470 the regular expression, m[
0] contains what matched the whole string, m[
1]
471 the first sub-expression etc, see regmatch_t in the header file declaration
472 for more details. The eflags parameter can be a combination of:
474 <div class=
"informaltable"><table class=
"table">
500 Parameter buf does not represent the start of a line.
512 Parameter buf does not terminate at the end of a line.
524 The string searched starts at buf + pmatch[
0].rm_so and ends at
525 buf + pmatch[
0].rm_eo.
531 <a name=
"regfree"></a><h5>
532 <a name=
"boost_regex.ref.posix.h3"></a>
533 <span class=
"phrase"><a name=
"boost_regex.ref.posix.regfree"></a></span><a class=
"link" href=
"posix.html#boost_regex.ref.posix.regfree">regfree
</a>
536 <code class=
"computeroutput"><span class=
"identifier">regfree
</span></code> frees all the memory
537 that was allocated by regcomp.
540 <table xmlns:
rev=
"http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
"100%"><tr>
541 <td align=
"left"></td>
542 <td align=
"right"><div class=
"copyright-footer">Copyright
© 1998-
2013 John Maddock
<p>
543 Distributed under the Boost Software License, Version
1.0. (See accompanying
544 file LICENSE_1_0.txt or copy at
<a href=
"http://www.boost.org/LICENSE_1_0.txt" target=
"_top">http://www.boost.org/LICENSE_1_0.txt
</a>)
549 <div class=
"spirit-nav">
550 <a accesskey=
"p" href=
"non_std_strings/mfc_strings/mfc_iter.html"><img src=
"../../../../../../doc/src/images/prev.png" alt=
"Prev"></a><a accesskey=
"u" href=
"../ref.html"><img src=
"../../../../../../doc/src/images/up.png" alt=
"Up"></a><a accesskey=
"h" href=
"../../index.html"><img src=
"../../../../../../doc/src/images/home.png" alt=
"Home"></a><a accesskey=
"n" href=
"concepts.html"><img src=
"../../../../../../doc/src/images/next.png" alt=
"Next"></a>