Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > c9cfbd1355daacaf3b34517a6d7b18cc > files > 143

libdap-doc-3.11.0-2.fc15.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>libdap++: Error.cc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">libdap++&#160;<span id="projectnumber">Updated for version 3.8.2</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('Error_8cc.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>Error.cc</h1>  </div>
</div>
<div class="contents">
<a href="Error_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span>
<a name="l00003"></a>00003 
<a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span>
<a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2002,2003 OPeNDAP, Inc.</span>
<a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher &lt;jgallagher@opendap.org&gt;</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This library is free software; you can redistribute it and/or</span>
<a name="l00011"></a>00011 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00012"></a>00012 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00013"></a>00013 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// This library is distributed in the hope that it will be useful,</span>
<a name="l00016"></a>00016 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00017"></a>00017 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00018"></a>00018 <span class="comment">// Lesser General Public License for more details.</span>
<a name="l00019"></a>00019 <span class="comment">//</span>
<a name="l00020"></a>00020 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<a name="l00021"></a>00021 <span class="comment">// License along with this library; if not, write to the Free Software</span>
<a name="l00022"></a>00022 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<a name="l00023"></a>00023 <span class="comment">//</span>
<a name="l00024"></a>00024 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="comment">// (c) COPYRIGHT URI/MIT 1994-1999</span>
<a name="l00027"></a>00027 <span class="comment">// Please read the full copyright statement in the file COPYRIGHT_URI.</span>
<a name="l00028"></a>00028 <span class="comment">//</span>
<a name="l00029"></a>00029 <span class="comment">// Authors:</span>
<a name="l00030"></a>00030 <span class="comment">//      jhrg,jimg       James Gallagher &lt;jgallagher@gso.uri.edu&gt;</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">// Implementation for the Error class.</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &quot;<a class="code" href="config_8h.html">config.h</a>&quot;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="keyword">static</span> <span class="keywordtype">char</span> rcsid[] <a class="code" href="config_8h.html#a05e109ec893d0b12023d5b0cf4f718c4">not_used</a> =
<a name="l00038"></a>00038     {<span class="stringliteral">&quot;$Id: Error.cc 18940 2008-06-25 19:22:37Z jimg $&quot;</span>
<a name="l00039"></a>00039     };
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;cstdio&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;cassert&gt;</span>
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="preprocessor">#include &quot;<a class="code" href="Error_8h.html">Error.h</a>&quot;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &quot;<a class="code" href="parser_8h.html">parser.h</a>&quot;</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &quot;<a class="code" href="InternalErr_8h.html">InternalErr.h</a>&quot;</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="debug_8h.html">debug.h</a>&quot;</span>
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="keyword">using namespace </span>std;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="comment">// Glue routines declared in Error.lex</span>
<a name="l00052"></a>00052 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="Error_8cc.html#aa1dc432625185fae6933cefeea085d5b">Error_switch_to_buffer</a>(<span class="keywordtype">void</span> *new_buffer);
<a name="l00053"></a>00053 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="Error_8cc.html#a6ab0f7ae420eb26a950794dd0c9090d8">Error_delete_buffer</a>(<span class="keywordtype">void</span> * buffer);
<a name="l00054"></a>00054 <span class="keyword">extern</span> <span class="keywordtype">void</span> *<a class="code" href="Error_8cc.html#adfec1b31b9c0855ec3f39c9114b085bd">Error_buffer</a>(FILE *fp);
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="Error_8cc.html#aa1fda01b3e6a55e118578be3127c28a1">Errorrestart</a>(FILE *yyin); <span class="comment">// defined in Error.tab.c</span>
<a name="l00057"></a>00057 <span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="Error_8cc.html#a451f3a09d4697c0ceb2dc1fa9d5caa9c">Errorparse</a>(<span class="keywordtype">void</span> *arg);
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="keyword">namespace </span>libdap {
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 <span class="comment">// There are two entries for &#39;cannot read file&#39; because of an error made </span>
<a name="l00062"></a>00062 <span class="comment">// when the message was first added to this class. </span>
<a name="l00063"></a>00063 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *err_messages[] = {
<a name="l00064"></a>00064     <span class="stringliteral">&quot;Undefined error&quot;</span>,
<a name="l00065"></a>00065     <span class="stringliteral">&quot;Unknown error&quot;</span>,
<a name="l00066"></a>00066     <span class="stringliteral">&quot;Internal error&quot;</span>,
<a name="l00067"></a>00067     <span class="stringliteral">&quot;No such file&quot;</span>,
<a name="l00068"></a>00068     <span class="stringliteral">&quot;No such variable&quot;</span>,
<a name="l00069"></a>00069     <span class="stringliteral">&quot;Malformed expression&quot;</span>,
<a name="l00070"></a>00070     <span class="stringliteral">&quot;No authorization&quot;</span>,
<a name="l00071"></a>00071     <span class="stringliteral">&quot;Cannot read file&quot;</span>,
<a name="l00072"></a>00072     <span class="stringliteral">&quot;Cannot read file&quot;</span>
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074 
<a name="l00077"></a><a class="code" href="classlibdap_1_1Error.html#a0d75f4244ed27998bf2e5e031bc1bf4b">00077</a> Error::Error() : _error_code(<a class="code" href="Error_8h.html#a48926e61b0a4fd4bdfded04ba1c06793" title="Undefined error code.">undefined_error</a>), _error_message(<span class="stringliteral">&quot;&quot;</span>)
<a name="l00078"></a>00078 {}
<a name="l00079"></a>00079 
<a name="l00089"></a><a class="code" href="classlibdap_1_1Error.html#aa29df17396d7558f61fe0c7d16944221">00089</a> <a class="code" href="classlibdap_1_1Error.html#a0d75f4244ed27998bf2e5e031bc1bf4b">Error::Error</a>(<a class="code" href="namespacelibdap.html#a4d08204a35e99e555cda79022648362f" title="An enumerated type for common errors.">ErrorCode</a> ec, <span class="keywordtype">string</span> msg)
<a name="l00090"></a>00090         : _error_code(ec), _error_message(msg)
<a name="l00091"></a>00091 {}
<a name="l00092"></a>00092 
<a name="l00098"></a><a class="code" href="classlibdap_1_1Error.html#a5501a52112b0736474a6fbe31ff35952">00098</a> <a class="code" href="classlibdap_1_1Error.html#a0d75f4244ed27998bf2e5e031bc1bf4b">Error::Error</a>(<span class="keywordtype">string</span> msg)
<a name="l00099"></a>00099         : _error_code(<a class="code" href="Error_8h.html#a40b0db75d00d0338a597aa84e71109bf" title="Unknown error.">unknown_error</a>), _error_message(msg)
<a name="l00100"></a>00100 {}
<a name="l00101"></a>00101 
<a name="l00102"></a><a class="code" href="classlibdap_1_1Error.html#a749c827344436b813dc86b6c202069ad">00102</a> <a class="code" href="classlibdap_1_1Error.html#a0d75f4244ed27998bf2e5e031bc1bf4b">Error::Error</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp;copy_from)
<a name="l00103"></a>00103         : _error_code(copy_from._error_code),
<a name="l00104"></a>00104         _error_message(copy_from._error_message)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107 
<a name="l00108"></a><a class="code" href="classlibdap_1_1Error.html#a746f8a7ae2a12f2c8f5c7b6d0e5c6283">00108</a> <a class="code" href="classlibdap_1_1Error.html#a746f8a7ae2a12f2c8f5c7b6d0e5c6283">Error::~Error</a>()
<a name="l00109"></a>00109 {
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp;
<a name="l00113"></a><a class="code" href="classlibdap_1_1Error.html#a351366d737b8b5899e68599b055fd596">00113</a> <a class="code" href="classlibdap_1_1Error.html#a351366d737b8b5899e68599b055fd596">Error::operator=</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp;rhs)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115     assert(<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00116"></a>00116 
<a name="l00117"></a>00117     <span class="keywordflow">if</span> (&amp;rhs == <span class="keyword">this</span>)  <span class="comment">// are they identical?</span>
<a name="l00118"></a>00118         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00119"></a>00119     <span class="keywordflow">else</span> {
<a name="l00120"></a>00120         <a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a> = rhs.<a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a>;
<a name="l00121"></a>00121         <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a> = rhs.<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>;
<a name="l00122"></a>00122 
<a name="l00123"></a>00123         assert(this-&gt;<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00124"></a>00124 
<a name="l00125"></a>00125         <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00126"></a>00126     }
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128 
<a name="l00135"></a>00135 <span class="keywordtype">bool</span>
<a name="l00136"></a><a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e">00136</a> <a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">Error::OK</a>()<span class="keyword"> const</span>
<a name="l00137"></a>00137 <span class="keyword"></span>{
<a name="l00138"></a>00138     <span class="comment">// The object is empty - users cannot make these, but this class can!</span>
<a name="l00139"></a>00139     <span class="keywordtype">bool</span> empty = ((<a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a> == <a class="code" href="Error_8h.html#a48926e61b0a4fd4bdfded04ba1c06793" title="Undefined error code.">undefined_error</a>)
<a name="l00140"></a>00140                   &amp;&amp; (<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.empty()));
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     <span class="comment">// Just a message - the program part is null.</span>
<a name="l00143"></a>00143     <span class="keywordtype">bool</span> message = ((<a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a> != <a class="code" href="Error_8h.html#a48926e61b0a4fd4bdfded04ba1c06793" title="Undefined error code.">undefined_error</a>)
<a name="l00144"></a>00144                     &amp;&amp; (!<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.empty()));
<a name="l00145"></a>00145 
<a name="l00146"></a>00146     <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr &lt;&lt; <span class="stringliteral">&quot;empty: &quot;</span> &lt;&lt; empty &lt;&lt; <span class="stringliteral">&quot;, message: &quot;</span> &lt;&lt; message &lt;&lt; endl);
<a name="l00147"></a>00147     <span class="keywordflow">return</span> empty || message;
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149 
<a name="l00158"></a>00158 <span class="keywordtype">bool</span>
<a name="l00159"></a><a class="code" href="classlibdap_1_1Error.html#ac705b3c1cfab1f7530d66a974eb0e8b6">00159</a> <a class="code" href="classlibdap_1_1Error.html#ac705b3c1cfab1f7530d66a974eb0e8b6" title="Parse an Error object.">Error::parse</a>(FILE *fp)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161     <span class="keywordflow">if</span> (!fp)
<a name="l00162"></a>00162         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;Null input stream&quot;</span>);
<a name="l00163"></a>00163 
<a name="l00164"></a>00164     <span class="keywordtype">void</span> *buffer = <a class="code" href="Error_8cc.html#adfec1b31b9c0855ec3f39c9114b085bd">Error_buffer</a>(fp);
<a name="l00165"></a>00165     <a class="code" href="Error_8cc.html#aa1dc432625185fae6933cefeea085d5b">Error_switch_to_buffer</a>(buffer);
<a name="l00166"></a>00166 
<a name="l00167"></a>00167     <a class="code" href="structlibdap_1_1parser__arg.html" title="Pass parameters by reference to a parser.">parser_arg</a> arg(<span class="keyword">this</span>);
<a name="l00168"></a>00168 
<a name="l00169"></a>00169     <span class="keywordtype">bool</span> status;
<a name="l00170"></a>00170     <span class="keywordflow">try</span> {
<a name="l00171"></a>00171         status = <a class="code" href="Error_8cc.html#a451f3a09d4697c0ceb2dc1fa9d5caa9c">Errorparse</a>((<span class="keywordtype">void</span> *) &amp; arg) == 0;
<a name="l00172"></a>00172         <a class="code" href="Error_8cc.html#a6ab0f7ae420eb26a950794dd0c9090d8">Error_delete_buffer</a>(buffer);
<a name="l00173"></a>00173     }
<a name="l00174"></a>00174     <span class="keywordflow">catch</span> (<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a> &amp;e) {
<a name="l00175"></a>00175         <a class="code" href="Error_8cc.html#a6ab0f7ae420eb26a950794dd0c9090d8">Error_delete_buffer</a>(buffer);
<a name="l00176"></a>00176         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, e.<a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">get_error_message</a>());
<a name="l00177"></a>00177     }
<a name="l00178"></a>00178 
<a name="l00179"></a>00179     <span class="comment">// STATUS is the result of the parser function; if a recoverable error</span>
<a name="l00180"></a>00180     <span class="comment">// was found it will be true but arg.status() will be false.</span>
<a name="l00181"></a>00181     <span class="comment">// I&#39;m throwing an InternalErr here since Error objects are generated by</span>
<a name="l00182"></a>00182     <span class="comment">// the core; they should always parse! 9/21/2000 jhrg</span>
<a name="l00183"></a>00183     <span class="keywordflow">if</span> (!status || !arg.<a class="code" href="structlibdap_1_1parser__arg.html#a9d4f550e0ca6188501290d42382e85a2">status</a>())
<a name="l00184"></a>00184         <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">&quot;Error parsing error object!&quot;</span>);
<a name="l00185"></a>00185     <span class="keywordflow">else</span>
<a name="l00186"></a>00186         <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>();  <span class="comment">// Check object consistency</span>
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 
<a name="l00200"></a>00200 <span class="keywordtype">void</span>
<a name="l00201"></a><a class="code" href="classlibdap_1_1Error.html#af2185ebeb4236e2902abda772a2b5a49">00201</a> <a class="code" href="classlibdap_1_1Error.html#af2185ebeb4236e2902abda772a2b5a49">Error::print</a>(FILE *out)<span class="keyword"> const</span>
<a name="l00202"></a>00202 <span class="keyword"></span>{
<a name="l00203"></a>00203     assert(<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00204"></a>00204 
<a name="l00205"></a>00205     fprintf(out, <span class="stringliteral">&quot;Error {\n&quot;</span>) ;
<a name="l00206"></a>00206 
<a name="l00207"></a>00207     fprintf(out, <span class="stringliteral">&quot;    code = %d;\n&quot;</span>, static_cast&lt;int&gt;(<a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a>)) ;
<a name="l00208"></a>00208 
<a name="l00209"></a>00209     <span class="comment">// If the error message is wrapped in double quotes, print it, else, add</span>
<a name="l00210"></a>00210     <span class="comment">// wrapping double quotes.</span>
<a name="l00211"></a>00211     <span class="keywordflow">if</span> (*<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.begin() == <span class="charliteral">&#39;&quot;&#39;</span> &amp;&amp; *(<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.end() - 1) == <span class="charliteral">&#39;&quot;&#39;</span>)
<a name="l00212"></a>00212         fprintf(out, <span class="stringliteral">&quot;    message = %s;\n&quot;</span>, <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.c_str()) ;
<a name="l00213"></a>00213     <span class="keywordflow">else</span>
<a name="l00214"></a>00214         fprintf(out, <span class="stringliteral">&quot;    message = \&quot;%s\&quot;;\n&quot;</span>, <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.c_str()) ;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216     fprintf(out, <span class="stringliteral">&quot;};\n&quot;</span>) ;
<a name="l00217"></a>00217 }
<a name="l00218"></a>00218 
<a name="l00229"></a>00229 <span class="keywordtype">void</span>
<a name="l00230"></a><a class="code" href="classlibdap_1_1Error.html#ab411acbae4f6592c6ec23760eed622ed">00230</a> <a class="code" href="classlibdap_1_1Error.html#af2185ebeb4236e2902abda772a2b5a49">Error::print</a>(ostream &amp;strm)<span class="keyword"> const</span>
<a name="l00231"></a>00231 <span class="keyword"></span>{
<a name="l00232"></a>00232     assert(<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00233"></a>00233 
<a name="l00234"></a>00234     strm &lt;&lt; <span class="stringliteral">&quot;Error {\n&quot;</span> ;
<a name="l00235"></a>00235 
<a name="l00236"></a>00236     strm &lt;&lt; <span class="stringliteral">&quot;    code = &quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(<a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a>) &lt;&lt; <span class="stringliteral">&quot;;\n&quot;</span> ;
<a name="l00237"></a>00237 
<a name="l00238"></a>00238     <span class="comment">// If the error message is wrapped in double quotes, print it, else, add</span>
<a name="l00239"></a>00239     <span class="comment">// wrapping double quotes.</span>
<a name="l00240"></a>00240     <span class="keywordflow">if</span> (*<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.begin() == <span class="charliteral">&#39;&quot;&#39;</span> &amp;&amp; *(<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.end() - 1) == <span class="charliteral">&#39;&quot;&#39;</span>)
<a name="l00241"></a>00241         strm &lt;&lt; <span class="stringliteral">&quot;    message = &quot;</span> &lt;&lt; <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.c_str() &lt;&lt; <span class="stringliteral">&quot;;\n&quot;</span> ;
<a name="l00242"></a>00242     <span class="keywordflow">else</span>
<a name="l00243"></a>00243         strm &lt;&lt; <span class="stringliteral">&quot;    message = \&quot;&quot;</span> &lt;&lt; <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.c_str() &lt;&lt; <span class="stringliteral">&quot;\&quot;;\n&quot;</span>  ;
<a name="l00244"></a>00244 
<a name="l00245"></a>00245     strm &lt;&lt; <span class="stringliteral">&quot;};\n&quot;</span> ;
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247 
<a name="l00249"></a>00249 <a class="code" href="namespacelibdap.html#a4d08204a35e99e555cda79022648362f" title="An enumerated type for common errors.">ErrorCode</a>
<a name="l00250"></a><a class="code" href="classlibdap_1_1Error.html#a207b7ba3e52b236a5c48440525c99ab8">00250</a> <a class="code" href="classlibdap_1_1Error.html#a207b7ba3e52b236a5c48440525c99ab8">Error::get_error_code</a>()<span class="keyword"> const</span>
<a name="l00251"></a>00251 <span class="keyword"></span>{
<a name="l00252"></a>00252     assert(<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00253"></a>00253     <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a>;
<a name="l00254"></a>00254 }
<a name="l00255"></a>00255 
<a name="l00262"></a>00262 <span class="keywordtype">void</span>
<a name="l00263"></a><a class="code" href="classlibdap_1_1Error.html#a47c0f4b6a38d8ca075d1056076d2845d">00263</a> <a class="code" href="classlibdap_1_1Error.html#a47c0f4b6a38d8ca075d1056076d2845d">Error::set_error_code</a>(<a class="code" href="namespacelibdap.html#a4d08204a35e99e555cda79022648362f" title="An enumerated type for common errors.">ErrorCode</a> ec)
<a name="l00264"></a>00264 {
<a name="l00265"></a>00265     <a class="code" href="classlibdap_1_1Error.html#a30226017ae9dfbe2e27be502b4fbdef4">_error_code</a> = ec;
<a name="l00266"></a>00266     <span class="comment">// Added check to make sure that err_messages is not accessed beyond its</span>
<a name="l00267"></a>00267     <span class="comment">// bounds. 02/02/04 jhrg</span>
<a name="l00268"></a>00268     <span class="keywordflow">if</span> (<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>.empty()
<a name="l00269"></a>00269         &amp;&amp; ec &gt; <a class="code" href="Error_8h.html#a48926e61b0a4fd4bdfded04ba1c06793" title="Undefined error code.">undefined_error</a> &amp;&amp; ec &lt;= <a class="code" href="Error_8h.html#abfb3e05b1e44bdd0f9be651a01ba464b">cannot_read_file</a>) {
<a name="l00270"></a>00270         <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a> = err_messages[ec - <a class="code" href="Error_8h.html#a48926e61b0a4fd4bdfded04ba1c06793" title="Undefined error code.">undefined_error</a>];
<a name="l00271"></a>00271     }
<a name="l00272"></a>00272     <span class="keywordflow">else</span> {
<a name="l00273"></a>00273         <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a> = err_messages[0];
<a name="l00274"></a>00274     }
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276 
<a name="l00278"></a>00278 <span class="keywordtype">string</span>
<a name="l00279"></a><a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">00279</a> <a class="code" href="classlibdap_1_1Error.html#a917fdf537b7dd7e587e9cf6dc7e4c687">Error::get_error_message</a>()<span class="keyword"> const</span>
<a name="l00280"></a>00280 <span class="keyword"></span>{
<a name="l00281"></a>00281     assert(<a class="code" href="classlibdap_1_1Error.html#a5624b1cca8a752a24d76a50e092fd61e" title="Is the Error object valid?">OK</a>());
<a name="l00282"></a>00282 
<a name="l00283"></a>00283     <span class="keywordflow">return</span> string(<a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a>);
<a name="l00284"></a>00284 }
<a name="l00285"></a>00285 
<a name="l00287"></a>00287 <span class="keywordtype">void</span>
<a name="l00288"></a><a class="code" href="classlibdap_1_1Error.html#af48fc071e737b88925dfd0bff8995304">00288</a> <a class="code" href="classlibdap_1_1Error.html#af48fc071e737b88925dfd0bff8995304">Error::set_error_message</a>(<span class="keywordtype">string</span> msg)
<a name="l00289"></a>00289 {
<a name="l00290"></a>00290     <a class="code" href="classlibdap_1_1Error.html#a86b1ed1e500e2ad6bbcfdd046b870728">_error_message</a> = msg;
<a name="l00291"></a>00291 }
<a name="l00292"></a>00292 
<a name="l00293"></a>00293 } <span class="comment">// namespace libdap</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="Error_8cc.html">Error.cc</a>      </li>
      <li class="footer">Generated on Tue Feb 8 2011 for libdap++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>