1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>get.cc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3-rc3 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center>
<hr><h1>get.cc</h1><a href="get_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>
00002 <span class="comment"> *</span>
00003 <span class="comment"> * This file is part of the PCRE++ Class Library.</span>
00004 <span class="comment"> *</span>
00005 <span class="comment"> * By accessing this software, PCRE++, you are duly informed</span>
00006 <span class="comment"> * of and agree to be bound by the conditions described below</span>
00007 <span class="comment"> * in this notice:</span>
00008 <span class="comment"> *</span>
00009 <span class="comment"> * This software product, PCRE++, is developed by Thomas Linden</span>
00010 <span class="comment"> * and copyrighted (C) 2002-2003 by Thomas Linden,with all rights </span>
00011 <span class="comment"> * reserved.</span>
00012 <span class="comment"> *</span>
00013 <span class="comment"> * There is no charge for PCRE++ software. You can redistribute</span>
00014 <span class="comment"> * it and/or modify it under the terms of the GNU Lesser General</span>
00015 <span class="comment"> * Public License, which is incorporated by reference herein.</span>
00016 <span class="comment"> *</span>
00017 <span class="comment"> * PCRE++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS,</span>
00018 <span class="comment"> * OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that</span>
00019 <span class="comment"> * the use of it will not infringe on any third party's intellec-</span>
00020 <span class="comment"> * tual property rights.</span>
00021 <span class="comment"> *</span>
00022 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
00023 <span class="comment"> * License along with PCRE++. Copies can also be obtained from:</span>
00024 <span class="comment"> *</span>
00025 <span class="comment"> * http://www.gnu.org/licenses/lgpl.txt</span>
00026 <span class="comment"> *</span>
00027 <span class="comment"> * or by writing to:</span>
00028 <span class="comment"> *</span>
00029 <span class="comment"> * Free Software Foundation, Inc.</span>
00030 <span class="comment"> * 59 Temple Place, Suite 330</span>
00031 <span class="comment"> * Boston, MA 02111-1307</span>
00032 <span class="comment"> * USA</span>
00033 <span class="comment"> *</span>
00034 <span class="comment"> * Or contact:</span>
00035 <span class="comment"> *</span>
00036 <span class="comment"> * "Thomas Linden" <tom@daemon.de></span>
00037 <span class="comment"> *</span>
00038 <span class="comment"> *</span>
00039 <span class="comment"> */</span>
00040
00041
00042 <span class="preprocessor">#include "<a class="code" href="pcre++_8h.html">pcre++.h</a>"</span>
00043
00044 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
00045 <span class="keyword">using</span> <span class="keyword">namespace </span>pcrepp;
00046
00047 <span class="comment">/*</span>
00048 <span class="comment"> * get_*() methods which return (sub)informations such as matches</span>
00049 <span class="comment"> * or strings</span>
00050 <span class="comment"> */</span>
00051
00052
<a name="l00053"></a><a class="code" href="classpcrepp_1_1Pcre.html#a10">00053</a> vector<string>* Pcre::get_sub_strings()<span class="keyword"> const </span>{
00054 <span class="keywordflow">if</span>(resultset != NULL)
00055 <span class="keywordflow">return</span> resultset;
00056 <span class="keywordflow">else</span>
00057 <span class="keywordflow">return</span> NULL;
00058 }
00059
<a name="l00060"></a><a class="code" href="classpcrepp_1_1Pcre.html#a11">00060</a> string Pcre::get_match(<span class="keywordtype">int</span> pos)<span class="keyword"> const </span>{
00061 <span class="keywordflow">if</span>(pos >= 0 && pos < num_matches) {
00062 vector<string>::iterator P = resultset->begin() + pos;
00063 <span class="keywordflow">return</span> *P;
00064 }
00065 <span class="keywordflow">else</span> {
00066 <span class="keywordflow">throw</span> <a class="code" href="classpcrepp_1_1Pcre_1_1exception.html">exception</a>(<span class="stringliteral">"Pcre::get_match(int): out of range"</span>);
00067 }
00068 }
00069
<a name="l00070"></a><a class="code" href="classpcrepp_1_1Pcre.html#a14">00070</a> <span class="keywordtype">int</span> Pcre::get_match_start()<span class="keyword"> const </span>{
00071 <span class="keywordflow">if</span> (sub_vec)
00072 <span class="keywordflow">return</span> sub_vec[0];
00073 <span class="keywordflow">else</span>
00074 <span class="keywordflow">return</span> -1;
00075 }
00076
<a name="l00077"></a><a class="code" href="classpcrepp_1_1Pcre.html#a15">00077</a> <span class="keywordtype">int</span> Pcre::get_match_end()<span class="keyword"> const </span>{
00078 <span class="keywordflow">if</span> (sub_vec)
00079 <span class="keywordflow">return</span> sub_vec[1] - 1;
00080 <span class="keywordflow">else</span>
00081 <span class="keywordflow">return</span> -1;
00082 }
00083
<a name="l00084"></a><a class="code" href="classpcrepp_1_1Pcre.html#a12">00084</a> <span class="keywordtype">int</span> Pcre::get_match_start(<span class="keywordtype">int</span> pos)<span class="keyword"> const </span>{
00085 <span class="keywordflow">if</span>(pos >= 0 && pos <= num_matches) {
00086 <span class="comment">/*</span>
00087 <span class="comment"> * sub_vec[0] and [1] is the start/end of the entire string.</span>
00088 <span class="comment"> */</span>
00089 <span class="keywordflow">return</span> sub_vec[ (++pos) * 2 ];
00090 }
00091 <span class="keywordflow">else</span> {
00092 <span class="keywordflow">throw</span> <a class="code" href="classpcrepp_1_1Pcre_1_1exception.html">exception</a>(<span class="stringliteral">"Pcre::get_match_start(int): out of range"</span>);
00093 }
00094 }
00095
<a name="l00096"></a><a class="code" href="classpcrepp_1_1Pcre.html#a13">00096</a> <span class="keywordtype">int</span> Pcre::get_match_end(<span class="keywordtype">int</span> pos)<span class="keyword"> const </span>{
00097 <span class="keywordflow">if</span>(pos >= 0 && pos <= num_matches) {
00098 <span class="comment">/*</span>
00099 <span class="comment"> * the end offset of a subpattern points to</span>
00100 <span class="comment"> * the first offset of the next substring,</span>
00101 <span class="comment"> * therefore -1</span>
00102 <span class="comment"> */</span>
00103 <span class="keywordflow">return</span> sub_vec[ ((++pos) * 2) + 1 ] - 1;
00104 }
00105 <span class="keywordflow">else</span> {
00106 <span class="keywordflow">throw</span> <a class="code" href="classpcrepp_1_1Pcre_1_1exception.html">exception</a>(<span class="stringliteral">"Pcre::get_match_end(int): out of range"</span>);
00107 }
00108 }
00109
<a name="l00110"></a><a class="code" href="classpcrepp_1_1Pcre.html#a16">00110</a> size_t Pcre::get_match_length(<span class="keywordtype">int</span> pos)<span class="keyword"> const </span>{
00111 <span class="keywordflow">if</span>(pos >= 0 && pos < num_matches) {
00112 vector<string>::iterator P = resultset->begin() + pos;
00113 <span class="keywordflow">return</span> P->length();
00114 }
00115 <span class="keywordflow">else</span> {
00116 <span class="keywordflow">throw</span> <a class="code" href="classpcrepp_1_1Pcre_1_1exception.html">exception</a>(<span class="stringliteral">"Pcre::get_match_length(int): out of range"</span>);
00117 }
00118 }
</pre></div><hr><address style="align: right;"><small>Generated on Wed Aug 25 01:38:04 2004 for PCRE++ by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.3-rc3 </small></address>
</body>
</html>
|