<!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++: Str.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++ <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 Page</span></a></li> <li><a href="pages.html"><span>Related 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 List</span></a></li> <li><a href="globals.html"><span>File 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('Str_8cc.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <h1>Str.cc</h1> </div> </div> <div class="contents"> <a href="Str_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 <jgallagher@opendap.org></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 <jgallagher@gso.uri.edu></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">// Implementation for Str.</span> <a name="l00033"></a>00033 <span class="comment">//</span> <a name="l00034"></a>00034 <span class="comment">// jhrg 9/7/94</span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span> <a name="l00038"></a>00038 <a name="l00039"></a>00039 <span class="keyword">static</span> <span class="keywordtype">char</span> rcsid[] <a class="code" href="config_8h.html#a05e109ec893d0b12023d5b0cf4f718c4">not_used</a> = <a name="l00040"></a>00040 {<span class="stringliteral">"$Id: Str.cc 21699 2009-11-05 00:06:01Z jimg $"</span> <a name="l00041"></a>00041 }; <a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="preprocessor">#include "<a class="code" href="Byte_8h.html">Byte.h</a>"</span> <a name="l00044"></a>00044 <span class="preprocessor">#include "<a class="code" href="Int16_8h.html">Int16.h</a>"</span> <a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="UInt16_8h.html">UInt16.h</a>"</span> <a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="Int32_8h.html">Int32.h</a>"</span> <a name="l00047"></a>00047 <span class="preprocessor">#include "<a class="code" href="UInt32_8h.html">UInt32.h</a>"</span> <a name="l00048"></a>00048 <span class="preprocessor">#include "<a class="code" href="Float32_8h.html">Float32.h</a>"</span> <a name="l00049"></a>00049 <span class="preprocessor">#include "<a class="code" href="Float64_8h.html">Float64.h</a>"</span> <a name="l00050"></a>00050 <span class="preprocessor">#include "<a class="code" href="Str_8h.html">Str.h</a>"</span> <a name="l00051"></a>00051 <span class="preprocessor">#include "<a class="code" href="Url_8h.html">Url.h</a>"</span> <a name="l00052"></a>00052 <span class="preprocessor">#include "<a class="code" href="Array_8h.html">Array.h</a>"</span> <a name="l00053"></a>00053 <span class="preprocessor">#include "<a class="code" href="Structure_8h.html">Structure.h</a>"</span> <a name="l00054"></a>00054 <span class="preprocessor">#include "<a class="code" href="Sequence_8h.html">Sequence.h</a>"</span> <a name="l00055"></a>00055 <span class="preprocessor">#include "<a class="code" href="Grid_8h.html">Grid.h</a>"</span> <a name="l00056"></a>00056 <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="preprocessor">#include "<a class="code" href="DDS_8h.html">DDS.h</a>"</span> <a name="l00059"></a>00059 <span class="preprocessor">#include "<a class="code" href="util_8h.html">util.h</a>"</span> <a name="l00060"></a>00060 <span class="preprocessor">#include "<a class="code" href="parser_8h.html">parser.h</a>"</span> <a name="l00061"></a>00061 <span class="preprocessor">#include "<a class="code" href="Operators_8h.html">Operators.h</a>"</span> <a name="l00062"></a>00062 <span class="preprocessor">#include "<a class="code" href="InternalErr_8h.html">InternalErr.h</a>"</span> <a name="l00063"></a>00063 <span class="preprocessor">#include "<a class="code" href="escaping_8h.html">escaping.h</a>"</span> <a name="l00064"></a>00064 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">debug.h</a>"</span> <a name="l00065"></a>00065 <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="keyword">using</span> std::cerr; <a name="l00068"></a>00068 <span class="keyword">using</span> std::endl; <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="keyword">namespace </span>libdap { <a name="l00071"></a>00071 <a name="l00080"></a><a class="code" href="classlibdap_1_1Str.html#a23a93ec403dc5cbb5264cdf47ea01c44">00080</a> <a class="code" href="classlibdap_1_1Str.html#a23a93ec403dc5cbb5264cdf47ea01c44">Str::Str</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n) : <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a>(n, <a class="code" href="namespacelibdap.html#a05ca706d4539ae7b750c3bc7066ab6e6ad620cef0bf41edebd4ee802071192a79">dods_str_c</a>), _buf(<span class="stringliteral">""</span>) <a name="l00081"></a>00081 {} <a name="l00082"></a>00082 <a name="l00090"></a><a class="code" href="classlibdap_1_1Str.html#a37e6b66c284c38052eb0bdebec18bba6">00090</a> <a class="code" href="classlibdap_1_1Str.html#a23a93ec403dc5cbb5264cdf47ea01c44">Str::Str</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &n, <span class="keyword">const</span> <span class="keywordtype">string</span> &d) <a name="l00091"></a>00091 : <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a>(n, d, <a class="code" href="namespacelibdap.html#a05ca706d4539ae7b750c3bc7066ab6e6ad620cef0bf41edebd4ee802071192a79">dods_str_c</a>), _buf(<span class="stringliteral">""</span>) <a name="l00092"></a>00092 {} <a name="l00093"></a>00093 <a name="l00094"></a><a class="code" href="classlibdap_1_1Str.html#a167bf89f44f4ca6daa132ecd7b0b70a5">00094</a> <a class="code" href="classlibdap_1_1Str.html#a23a93ec403dc5cbb5264cdf47ea01c44">Str::Str</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Str.html" title="Holds character string data.">Str</a> &copy_from) : <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a>(copy_from) <a name="l00095"></a>00095 { <a name="l00096"></a>00096 <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> = copy_from.<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>; <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <a name="l00099"></a>00099 <a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> * <a name="l00100"></a><a class="code" href="classlibdap_1_1Str.html#a4e92b00a6a3a8056c80b2f4467646f42">00100</a> <a class="code" href="classlibdap_1_1Str.html#a4e92b00a6a3a8056c80b2f4467646f42">Str::ptr_duplicate</a>() <a name="l00101"></a>00101 { <a name="l00102"></a>00102 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classlibdap_1_1Str.html#a23a93ec403dc5cbb5264cdf47ea01c44">Str</a>(*<span class="keyword">this</span>); <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a>00105 <a class="code" href="classlibdap_1_1Str.html" title="Holds character string data.">Str</a> & <a name="l00106"></a><a class="code" href="classlibdap_1_1Str.html#a00993d910a5bdb55dceee229bc0be336">00106</a> <a class="code" href="classlibdap_1_1Str.html#a00993d910a5bdb55dceee229bc0be336">Str::operator=</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Str.html" title="Holds character string data.">Str</a> &rhs) <a name="l00107"></a>00107 { <a name="l00108"></a>00108 <span class="keywordflow">if</span> (<span class="keyword">this</span> == &rhs) <a name="l00109"></a>00109 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="comment">// Call BaseType::operator=.</span> <a name="l00112"></a>00112 <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> &<span class="keyword">></span>(*this) = rhs; <a name="l00113"></a>00113 <a name="l00114"></a>00114 <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> = rhs.<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>; <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00120"></a><a class="code" href="classlibdap_1_1Str.html#a053049cf1df6c1cb78ce16ae06a1802f">00120</a> <a class="code" href="classlibdap_1_1Str.html#a053049cf1df6c1cb78ce16ae06a1802f">Str::length</a>() <a name="l00121"></a>00121 { <a name="l00122"></a>00122 <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>.length(); <a name="l00123"></a>00123 } <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00126"></a><a class="code" href="classlibdap_1_1Str.html#a7506602cf530cb7a76fa9714cc6ba203">00126</a> <a class="code" href="classlibdap_1_1Str.html#a7506602cf530cb7a76fa9714cc6ba203" title="Returns the size of the class instance data.">Str::width</a>() <a name="l00127"></a>00127 { <a name="l00128"></a>00128 <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(string); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="keywordtype">bool</span> <a name="l00132"></a><a class="code" href="classlibdap_1_1Str.html#a1f71320548c6cf29b85d66de5998144d">00132</a> <a class="code" href="classlibdap_1_1Str.html#a1f71320548c6cf29b85d66de5998144d" title="Move data to the net.">Str::serialize</a>(<a class="code" href="classlibdap_1_1ConstraintEvaluator.html" title="Evaluate a constraint expression.">ConstraintEvaluator</a> &eval, <a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds, <a name="l00133"></a>00133 <a class="code" href="classlibdap_1_1Marshaller.html" title="abstract base class used to marshal/serialize dap data objects">Marshaller</a> &m, <span class="keywordtype">bool</span> ce_eval) <a name="l00134"></a>00134 { <a name="l00135"></a>00135 <a name="l00136"></a>00136 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr << <span class="stringliteral">"Entering ("</span> << this-><a class="code" href="classlibdap_1_1BaseType.html#a0a0c6b5d57813607dc06255b8e0b9bdc" title="Returns the name of the class instance.">name</a>() << <span class="stringliteral">" ["</span> << <span class="keyword">this</span> << <span class="stringliteral">"])"</span> << endl); <a name="l00137"></a>00137 <a name="l00138"></a>00138 dds.<a class="code" href="classlibdap_1_1DDS.html#a8cd9b6a34f5e1a49665de3189e141de8">timeout_on</a>(); <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#a38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>()) <a name="l00141"></a>00141 <a class="code" href="classlibdap_1_1BaseType.html#a1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>(); <a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="preprocessor">#if EVAL</span> <a name="l00144"></a>00144 <span class="preprocessor"></span> <span class="keywordflow">if</span> (ce_eval && !eval.<a class="code" href="classlibdap_1_1ConstraintEvaluator.html#aa0066a57cf00c975f6ccbc2e90c64742" title="Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...">eval_selection</a>(dds, <a class="code" href="classlibdap_1_1BaseType.html#a9f102f5cc17ac7d2d80f9921e10d3baf" title="Returns the name of the dataset used to create this instance.">dataset</a>())) <a name="l00145"></a>00145 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00146"></a>00146 <span class="preprocessor">#endif</span> <a name="l00147"></a>00147 <span class="preprocessor"></span> <a name="l00148"></a>00148 dds.<a class="code" href="classlibdap_1_1DDS.html#a6740f99a5fc64640505924c5603ace0a">timeout_off</a>(); <a name="l00149"></a>00149 <a name="l00150"></a>00150 m.<a class="code" href="classlibdap_1_1Marshaller.html#a5a7d7e20f09cf039c17af9eb5c233208">put_str</a>( <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> ) ; <a name="l00151"></a>00151 <a name="l00152"></a>00152 <a class="code" href="debug_8h.html#a32adf79142f0a426b5e782fb7cd4cad3">DBG</a>(cerr << <span class="stringliteral">"Exiting: buf = "</span> << <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> << endl); <a name="l00153"></a>00153 <a name="l00154"></a>00154 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00155"></a>00155 } <a name="l00156"></a>00156 <a name="l00157"></a>00157 <span class="comment">// deserialize the string on stdin and put the result in BUF.</span> <a name="l00158"></a>00158 <a name="l00159"></a>00159 <span class="keywordtype">bool</span> <a name="l00160"></a><a class="code" href="classlibdap_1_1Str.html#a2bafe2f1851b3a4cac6089b0e2282010">00160</a> <a class="code" href="classlibdap_1_1Str.html#a2bafe2f1851b3a4cac6089b0e2282010" title="Receive data from the net.">Str::deserialize</a>(<a class="code" href="classlibdap_1_1UnMarshaller.html" title="abstract base class used to unmarshall/deserialize dap data objects">UnMarshaller</a> &um, <a class="code" href="classlibdap_1_1DDS.html">DDS</a> *, <span class="keywordtype">bool</span>) <a name="l00161"></a>00161 { <a name="l00162"></a>00162 um.<a class="code" href="classlibdap_1_1UnMarshaller.html#ac2b025e1bbede8039c8ed3a11ccf794e">get_str</a>( <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> ) ; <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <a name="l00176"></a>00176 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00177"></a><a class="code" href="classlibdap_1_1Str.html#aa63cf0376fe71ceb030b48e7fdbad863">00177</a> <a class="code" href="classlibdap_1_1Str.html#aa63cf0376fe71ceb030b48e7fdbad863">Str::buf2val</a>(<span class="keywordtype">void</span> **val) <a name="l00178"></a>00178 { <a name="l00179"></a>00179 <span class="comment">// Jose Garcia</span> <a name="l00180"></a>00180 <span class="comment">// The same comment justifying throwing an Error in val2buf applies here.</span> <a name="l00181"></a>00181 <span class="keywordflow">if</span> (!val) <a name="l00182"></a>00182 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <a name="l00183"></a>00183 <span class="stringliteral">"No place to store a reference to the data."</span>); <a name="l00184"></a>00184 <span class="comment">// If *val is null, then the caller has not allocated storage for the</span> <a name="l00185"></a>00185 <span class="comment">// value; we must. If there is storage there, assume it is a string and</span> <a name="l00186"></a>00186 <span class="comment">// assign _buf's value to that storage.</span> <a name="l00187"></a>00187 <span class="keywordflow">if</span> (!*val) <a name="l00188"></a>00188 *val = <span class="keyword">new</span> string(<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>); <a name="l00189"></a>00189 <span class="keywordflow">else</span> <a name="l00190"></a>00190 *<span class="keyword">static_cast<</span><span class="keywordtype">string</span>*<span class="keyword">></span>(*val) = <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>; <a name="l00191"></a>00191 <a name="l00192"></a>00192 <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<span class="keywordtype">string</span>*); <a name="l00193"></a>00193 } <a name="l00194"></a>00194 <a name="l00204"></a>00204 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a name="l00205"></a><a class="code" href="classlibdap_1_1Str.html#add396308f45a14355b60c411ed33bf7a">00205</a> <a class="code" href="classlibdap_1_1Str.html#add396308f45a14355b60c411ed33bf7a">Str::val2buf</a>(<span class="keywordtype">void</span> *val, <span class="keywordtype">bool</span>) <a name="l00206"></a>00206 { <a name="l00207"></a>00207 <span class="comment">// Jose Garcia</span> <a name="l00208"></a>00208 <span class="comment">// This method is public therefore and I believe it has being designed</span> <a name="l00209"></a>00209 <span class="comment">// to be use by read which must be implemented on the surrogated library,</span> <a name="l00210"></a>00210 <span class="comment">// thus if the pointer val is NULL, is an Internal Error.</span> <a name="l00211"></a>00211 <span class="keywordflow">if</span> (!val) <a name="l00212"></a>00212 <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">"NULL pointer."</span>); <a name="l00213"></a>00213 <a name="l00214"></a>00214 <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> = *<span class="keyword">static_cast<</span><span class="keywordtype">string</span>*<span class="keyword">></span>(val); <a name="l00215"></a>00215 <a name="l00216"></a>00216 <span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<span class="keywordtype">string</span>*); <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <a name="l00223"></a>00223 <span class="keywordtype">bool</span> <a name="l00224"></a><a class="code" href="classlibdap_1_1Str.html#ac4083a612e46a9ef2d1cddc2d40a955f">00224</a> <a class="code" href="classlibdap_1_1Str.html#ac4083a612e46a9ef2d1cddc2d40a955f">Str::set_value</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &value) <a name="l00225"></a>00225 { <a name="l00226"></a>00226 <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> = <a class="code" href="classlibdap_1_1Str.html#ad1c8898d979786da1699677c04264aa1">value</a>; <a name="l00227"></a>00227 <a class="code" href="classlibdap_1_1BaseType.html#a4533905a450d2a7af32e7d5acd557676" title="Sets the value of the read_p property.">set_read_p</a>(<span class="keyword">true</span>); <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <a name="l00234"></a>00234 <span class="keywordtype">string</span> <a name="l00235"></a><a class="code" href="classlibdap_1_1Str.html#ad1c8898d979786da1699677c04264aa1">00235</a> <a class="code" href="classlibdap_1_1Str.html#ad1c8898d979786da1699677c04264aa1">Str::value</a>()<span class="keyword"> const</span> <a name="l00236"></a>00236 <span class="keyword"></span>{ <a name="l00237"></a>00237 <span class="keywordflow">return</span> <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>; <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="preprocessor">#if FILE_METHODS</span> <a name="l00241"></a>00241 <span class="preprocessor"></span><span class="keywordtype">void</span> <a name="l00242"></a>00242 <a class="code" href="classlibdap_1_1Str.html#a7984e46de9b21ef554b156dec40cc559" title="Prints the value of the variable.">Str::print_val</a>(FILE *out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_decl_p) <a name="l00243"></a>00243 { <a name="l00244"></a>00244 <span class="keywordflow">if</span> (print_decl_p) { <a name="l00245"></a>00245 <a class="code" href="classlibdap_1_1BaseType.html#afd744b0ddeb04e7b173c9e83423ec572" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, <span class="keyword">false</span>); <a name="l00246"></a>00246 fprintf(out, <span class="stringliteral">" = \"%s\";\n"</span>, <a class="code" href="namespacelibdap.html#a17b72fe083734a5fefaf5542f640d87e">escattr</a>(<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>).c_str()) ; <a name="l00247"></a>00247 } <a name="l00248"></a>00248 <span class="keywordflow">else</span> <a name="l00249"></a>00249 fprintf(out, <span class="stringliteral">"\"%s\""</span>, <a class="code" href="namespacelibdap.html#a17b72fe083734a5fefaf5542f640d87e">escattr</a>(<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>).c_str()) ; <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <span class="preprocessor">#endif</span> <a name="l00252"></a>00252 <span class="preprocessor"></span> <a name="l00253"></a>00253 <span class="keywordtype">void</span> <a name="l00254"></a><a class="code" href="classlibdap_1_1Str.html#a7984e46de9b21ef554b156dec40cc559">00254</a> <a class="code" href="classlibdap_1_1Str.html#a7984e46de9b21ef554b156dec40cc559" title="Prints the value of the variable.">Str::print_val</a>(ostream &out, <span class="keywordtype">string</span> space, <span class="keywordtype">bool</span> print_decl_p) <a name="l00255"></a>00255 { <a name="l00256"></a>00256 <span class="keywordflow">if</span> (print_decl_p) { <a name="l00257"></a>00257 <a class="code" href="classlibdap_1_1BaseType.html#afd744b0ddeb04e7b173c9e83423ec572" title="Print an ASCII representation of the variable structure.">print_decl</a>(out, space, <span class="keyword">false</span>); <a name="l00258"></a>00258 out << <span class="stringliteral">" = \""</span> << <a class="code" href="namespacelibdap.html#a17b72fe083734a5fefaf5542f640d87e">escattr</a>(<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>) << <span class="stringliteral">"\";\n"</span> ; <a name="l00259"></a>00259 } <a name="l00260"></a>00260 <span class="keywordflow">else</span> <a name="l00261"></a>00261 out << <span class="stringliteral">"\""</span> << <a class="code" href="namespacelibdap.html#a17b72fe083734a5fefaf5542f640d87e">escattr</a>(<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>) << <span class="stringliteral">"\""</span> ; <a name="l00262"></a>00262 } <a name="l00263"></a>00263 <a name="l00264"></a>00264 <span class="keywordtype">bool</span> <a name="l00265"></a><a class="code" href="classlibdap_1_1Str.html#a5b74994fb52ceb3248c558015c4520a5">00265</a> <a class="code" href="classlibdap_1_1Str.html#a5b74994fb52ceb3248c558015c4520a5" title="Evaluate relational operators.">Str::ops</a>(<a class="code" href="classlibdap_1_1BaseType.html" title="The basic data type for the DODS DAP types.">BaseType</a> *b, <span class="keywordtype">int</span> op) <a name="l00266"></a>00266 { <a name="l00267"></a>00267 <span class="comment">// Extract the Byte arg's value.</span> <a name="l00268"></a>00268 <span class="keywordflow">if</span> (!<a class="code" href="classlibdap_1_1BaseType.html#a38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>() && !<a class="code" href="classlibdap_1_1BaseType.html#a1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>()) { <a name="l00269"></a>00269 <span class="comment">// Jose Garcia</span> <a name="l00270"></a>00270 <span class="comment">// Since the read method is virtual and implemented outside</span> <a name="l00271"></a>00271 <span class="comment">// libdap++ if we cannot read the data that is the problem</span> <a name="l00272"></a>00272 <span class="comment">// of the user or of whoever wrote the surrogate library</span> <a name="l00273"></a>00273 <span class="comment">// implemeting read therefore it is an internal error.</span> <a name="l00274"></a>00274 <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">"This value was not read!"</span>); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <a name="l00277"></a>00277 <span class="comment">// Extract the second arg's value.</span> <a name="l00278"></a>00278 <span class="keywordflow">if</span> (!b || !(b-><a class="code" href="classlibdap_1_1BaseType.html#a38ff819a432217c55db2e9071928d20c" title="Has this variable been read?">read_p</a>() || b-><a class="code" href="classlibdap_1_1BaseType.html#a1da003c53f2e663223f603ab3fbd7c8e" title="Read data into a local buffer.">read</a>())) { <a name="l00279"></a>00279 <span class="comment">// Jose Garcia</span> <a name="l00280"></a>00280 <span class="comment">// Since the read method is virtual and implemented outside</span> <a name="l00281"></a>00281 <span class="comment">// libdap++ if we cannot read the data that is the problem</span> <a name="l00282"></a>00282 <span class="comment">// of the user or of whoever wrote the surrogate library</span> <a name="l00283"></a>00283 <span class="comment">// implemeting read therefore it is an internal error.</span> <a name="l00284"></a>00284 <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">"Argument value was not read!"</span>); <a name="l00285"></a>00285 } <a name="l00286"></a>00286 <a name="l00287"></a>00287 <span class="keywordflow">switch</span> (b-><a class="code" href="classlibdap_1_1BaseType.html#abc6b2d7099f00bb5f324ec129bff2a17" title="Returns the type of the class instance.">type</a>()) { <a name="l00288"></a>00288 <span class="keywordflow">case</span> <a class="code" href="namespacelibdap.html#a05ca706d4539ae7b750c3bc7066ab6e6ad620cef0bf41edebd4ee802071192a79">dods_str_c</a>: <a name="l00289"></a>00289 <span class="keywordflow">return</span> rops<string, string, StrCmp<string, string> > <a name="l00290"></a>00290 (<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>, <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1Str.html" title="Holds character string data.">Str</a> *<span class="keyword">></span>(b)->_buf, op); <a name="l00291"></a>00291 <span class="keywordflow">case</span> <a class="code" href="namespacelibdap.html#a05ca706d4539ae7b750c3bc7066ab6e6a64d653d09a50d6d17537c43ed217f665">dods_url_c</a>: <a name="l00292"></a>00292 <span class="keywordflow">return</span> rops<string, string, StrCmp<string, string> > <a name="l00293"></a>00293 (<a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a>, <span class="keyword">dynamic_cast<</span><a class="code" href="classlibdap_1_1Url.html" title="Holds an Internet address (URL).">Url</a> *<span class="keyword">></span>(b)->_buf, op); <a name="l00294"></a>00294 <span class="keywordflow">default</span>: <a name="l00295"></a>00295 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00296"></a>00296 } <a name="l00297"></a>00297 } <a name="l00298"></a>00298 <a name="l00307"></a>00307 <span class="keywordtype">void</span> <a name="l00308"></a><a class="code" href="classlibdap_1_1Str.html#ad706e5b2b72822d8a5a30cf9c50ce570">00308</a> <a class="code" href="classlibdap_1_1Str.html#ad706e5b2b72822d8a5a30cf9c50ce570" title="dumps information about this object">Str::dump</a>(ostream &strm)<span class="keyword"> const</span> <a name="l00309"></a>00309 <span class="keyword"></span>{ <a name="l00310"></a>00310 strm << <a class="code" href="classlibdap_1_1DapIndent.html#a45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"Str::dump - ("</span> <a name="l00311"></a>00311 << (<span class="keywordtype">void</span> *)<span class="keyword">this</span> << <span class="stringliteral">")"</span> << endl ; <a name="l00312"></a>00312 <a class="code" href="classlibdap_1_1DapIndent.html#a4ed2cce66dbff9ad4320e89142103c6c">DapIndent::Indent</a>() ; <a name="l00313"></a>00313 <a class="code" href="classlibdap_1_1Str.html#ad706e5b2b72822d8a5a30cf9c50ce570" title="dumps information about this object">BaseType::dump</a>(strm) ; <a name="l00314"></a>00314 strm << <a class="code" href="classlibdap_1_1DapIndent.html#a45ca36e552f70fbdbca0599da4320aab">DapIndent::LMarg</a> << <span class="stringliteral">"value: "</span> << <a class="code" href="classlibdap_1_1Str.html#a0d878027b018b84bb545b8d08ca2e28d">_buf</a> << endl ; <a name="l00315"></a>00315 <a class="code" href="classlibdap_1_1DapIndent.html#a65c519d0916b031bcf60ca8d26fc82f8">DapIndent::UnIndent</a>() ; <a name="l00316"></a>00316 } <a name="l00317"></a>00317 <a name="l00318"></a>00318 } <span class="comment">// namespace libdap</span> <a name="l00319"></a>00319 </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="Str_8cc.html">Str.cc</a> </li> <li class="footer">Generated on Tue Feb 8 2011 for libdap++ by  <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>