Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > d67485fb8ce60f8952179bbde3b5d022 > files > 105

libgdal0-devel-1.1.7-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>gdalmajorobject.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.3-20001105 on Thu Mar 28 09:47:30 2002 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>gdalmajorobject.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * $Id: gdalmajorobject_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Project:  GDAL Core</font>
00005 <font class="comment"> * Purpose:  Base class for objects with metadata, etc.</font>
00006 <font class="comment"> * Author:   Frank Warmerdam, warmerda@home.com</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> ******************************************************************************</font>
00009 <font class="comment"> * Copyright (c) 2000, Frank Warmerdam</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</font>
00012 <font class="comment"> * copy of this software and associated documentation files (the "Software"),</font>
00013 <font class="comment"> * to deal in the Software without restriction, including without limitation</font>
00014 <font class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</font>
00015 <font class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</font>
00016 <font class="comment"> * Software is furnished to do so, subject to the following conditions:</font>
00017 <font class="comment"> *</font>
00018 <font class="comment"> * The above copyright notice and this permission notice shall be included</font>
00019 <font class="comment"> * in all copies or substantial portions of the Software.</font>
00020 <font class="comment"> *</font>
00021 <font class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</font>
00022 <font class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</font>
00023 <font class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL</font>
00024 <font class="comment"> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</font>
00025 <font class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</font>
00026 <font class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</font>
00027 <font class="comment"> * DEALINGS IN THE SOFTWARE.</font>
00028 <font class="comment"> ******************************************************************************</font>
00029 <font class="comment"> *</font>
00030 <font class="comment"> * $Log: gdalmajorobject_cpp-source.html,v $
00030 <font class="comment"> * Revision 1.10  2002/04/16 13:11:48  warmerda
00030 <font class="comment"> * updated
00030 <font class="comment"> *</font>
00031 <font class="comment"> * Revision 1.4  2001/09/25 15:56:37  warmerda</font>
00032 <font class="comment"> * implemented rest of C entry points for metadata, document C++ methods</font>
00033 <font class="comment"> *</font>
00034 <font class="comment"> * Revision 1.3  2001/07/18 04:04:30  warmerda</font>
00035 <font class="comment"> * added CPL_CVSID</font>
00036 <font class="comment"> *</font>
00037 <font class="comment"> * Revision 1.2  2000/06/26 15:26:21  warmerda</font>
00038 <font class="comment"> * added GDALGetDescription</font>
00039 <font class="comment"> *</font>
00040 <font class="comment"> * Revision 1.1  2000/04/20 20:52:03  warmerda</font>
00041 <font class="comment"> * New</font>
00042 <font class="comment"> *</font>
00043 <font class="comment"> */</font>
00044 
00045 <font class="preprocessor">#include "gdal_priv.h"</font>
00046 <font class="preprocessor">#include "cpl_string.h"</font>
00047 
00048 CPL_CVSID(<font class="stringliteral">"$Id: gdalmajorobject_cpp-source.html,v 1.10 2002/04/16 13:11:48 warmerda Exp $"</font>);
00049 
00050 <font class="comment">/************************************************************************/</font>
00051 <font class="comment">/*                          GDALMajorObject()                           */</font>
00052 <font class="comment">/************************************************************************/</font>
00053 
00054 GDALMajorObject::GDALMajorObject()<font class="keyword"></font>
00055 <font class="keyword"></font>
00056 <font class="keyword"></font>{
00057     pszDescription = NULL;
00058     papszMetadata = NULL;
00059 }
00060 
00061 <font class="comment">/************************************************************************/</font>
00062 <font class="comment">/*                          ~GDALMajorObject()                          */</font>
00063 <font class="comment">/************************************************************************/</font>
00064 
00065 GDALMajorObject::~GDALMajorObject()<font class="keyword"></font>
00066 <font class="keyword"></font>
00067 <font class="keyword"></font>{
00068     CPLFree( pszDescription );
00069     CSLDestroy( papszMetadata );
00070 }
00071 
00072 <font class="comment">/************************************************************************/</font>
00073 <font class="comment">/*                           GetDescription()                           */</font>
00074 <font class="comment">/************************************************************************/</font>
00075 
00086 <font class="keyword">const</font> <font class="keywordtype">char</font> *GDALMajorObject::GetDescription()<font class="keyword"> const</font>
00087 <font class="keyword"></font>
00088 <font class="keyword"></font>{
00089     <font class="keywordflow">if</font>( pszDescription == NULL )
00090         <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
00091     <font class="keywordflow">else</font>
00092         <font class="keywordflow">return</font> pszDescription;
00093 }
00094 
00095 <font class="comment">/************************************************************************/</font>
00096 <font class="comment">/*                         GDALGetDescription()                         */</font>
00097 <font class="comment">/************************************************************************/</font>
00098 
00099 <font class="keyword">const</font> <font class="keywordtype">char</font> *GDALGetDescription( GDALMajorObjectH hObject )<font class="keyword"></font>
00100 <font class="keyword"></font>
00101 <font class="keyword"></font>{
00102     <font class="keywordflow">return</font> ((GDALMajorObject *) hObject)-&gt;GetDescription();
00103 }
00104 
00105 <font class="comment">/************************************************************************/</font>
00106 <font class="comment">/*                           SetDescription()                           */</font>
00107 <font class="comment">/************************************************************************/</font>
00108 
00109 <font class="keywordtype">void</font> GDALMajorObject::SetDescription( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszNewDesc )<font class="keyword"> </font>
00110 <font class="keyword"></font>
00111 <font class="keyword"></font>{
00112     CPLFree( pszDescription );
00113     pszDescription = <a class="code" href="cpl_conv_h.html#a6">CPLStrdup</a>( pszNewDesc );
00114 }
00115 
00116 <font class="comment">/************************************************************************/</font>
00117 <font class="comment">/*                            GetMetadata()                             */</font>
00118 <font class="comment">/************************************************************************/</font>
00119 
00138 <font class="keywordtype">char</font> **GDALMajorObject::GetMetadata( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszDomain )<font class="keyword"></font>
00139 <font class="keyword"></font>
00140 <font class="keyword"></font>{
00141     <font class="keywordflow">if</font>( pszDomain == NULL || EQUAL(pszDomain,<font class="stringliteral">""</font>) )
00142         <font class="keywordflow">return</font> papszMetadata;
00143     <font class="keywordflow">else</font>
00144         <font class="keywordflow">return</font> NULL;
00145 }
00146 
00147 <font class="comment">/************************************************************************/</font>
00148 <font class="comment">/*                          GDALGetMetadata()                           */</font>
00149 <font class="comment">/************************************************************************/</font>
00150 
00151 <font class="keywordtype">char</font> **GDALGetMetadata( GDALMajorObjectH hObject, <font class="keyword">const</font> <font class="keywordtype">char</font> * pszDomain )<font class="keyword"></font>
00152 <font class="keyword"></font>
00153 <font class="keyword"></font>{
00154     <font class="keywordflow">return</font> ((GDALMajorObject *) hObject)-&gt;GetMetadata(pszDomain);
00155 }
00156 
00157 <font class="comment">/************************************************************************/</font>
00158 <font class="comment">/*                            SetMetadata()                             */</font>
00159 <font class="comment">/************************************************************************/</font>
00160 
00175 CPLErr GDALMajorObject::SetMetadata( <font class="keywordtype">char</font> ** papszMetadataIn, 
00176                                      <font class="keyword">const</font> <font class="keywordtype">char</font> * pszDomain )<font class="keyword"></font>
00177 <font class="keyword"></font>
00178 <font class="keyword"></font>{
00179     <font class="keywordflow">if</font>( pszDomain != NULL &amp;&amp; !EQUAL(pszDomain,<font class="stringliteral">""</font>) )
00180     {
00181         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_NotSupported, 
00182                   <font class="stringliteral">"Non-default domain not supported for this object."</font> );
00183         <font class="keywordflow">return</font> CE_Failure;
00184     }
00185 
00186     CSLDestroy( papszMetadata );
00187     papszMetadata = CSLDuplicate( papszMetadataIn );
00188     
00189     <font class="keywordflow">return</font> CE_None;
00190 }
00191 
00192 <font class="comment">/************************************************************************/</font>
00193 <font class="comment">/*                          GDALSetMetadata()                           */</font>
00194 <font class="comment">/************************************************************************/</font>
00195 
00196 CPLErr GDALSetMetadata( GDALMajorObjectH hObject, <font class="keywordtype">char</font> **papszMD, 
00197                         <font class="keyword">const</font> <font class="keywordtype">char</font> *pszDomain )<font class="keyword"></font>
00198 <font class="keyword"></font>
00199 <font class="keyword"></font>{
00200     <font class="keywordflow">return</font> ((GDALMajorObject *) hObject)-&gt;SetMetadata( papszMD, pszDomain );
00201 }
00202 
00203 
00204 <font class="comment">/************************************************************************/</font>
00205 <font class="comment">/*                          GetMetadataItem()                           */</font>
00206 <font class="comment">/************************************************************************/</font>
00207 
00220 <font class="keyword">const</font> <font class="keywordtype">char</font> *GDALMajorObject::GetMetadataItem( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszName, 
00221                                               <font class="keyword">const</font> <font class="keywordtype">char</font> * pszDomain )<font class="keyword"></font>
00222 <font class="keyword"></font>
00223 <font class="keyword"></font>{
00224     <font class="keywordtype">char</font>  **papszMD = GetMetadata( pszDomain );
00225     
00226     <font class="keywordflow">return</font> CSLFetchNameValue( papszMD, pszName );
00227 }
00228 
00229 <font class="comment">/************************************************************************/</font>
00230 <font class="comment">/*                        GDALGetMetadataItem()                         */</font>
00231 <font class="comment">/************************************************************************/</font>
00232 
00233 <font class="keyword">const</font> <font class="keywordtype">char</font> *GDALGetMetadataItem( GDALMajorObjectH hObject, 
00234                                  <font class="keyword">const</font> <font class="keywordtype">char</font> *pszName, 
00235                                  <font class="keyword">const</font> <font class="keywordtype">char</font> *pszDomain )<font class="keyword"></font>
00236 <font class="keyword"></font>
00237 <font class="keyword"></font>{
00238     <font class="keywordflow">return</font> ((GDALMajorObject *) hObject)-&gt;GetMetadataItem( pszName, pszDomain);
00239 }
00240 
00241 <font class="comment">/************************************************************************/</font>
00242 <font class="comment">/*                          SetMetadataItem()                           */</font>
00243 <font class="comment">/************************************************************************/</font>
00244 
00257 CPLErr GDALMajorObject::SetMetadataItem( <font class="keyword">const</font> <font class="keywordtype">char</font> * pszName, 
00258                                          <font class="keyword">const</font> <font class="keywordtype">char</font> * pszValue, 
00259                                          <font class="keyword">const</font> <font class="keywordtype">char</font> * pszDomain )<font class="keyword"></font>
00260 <font class="keyword"></font>
00261 <font class="keyword"></font>{
00262     <font class="keywordflow">if</font>( pszDomain != NULL &amp;&amp; !EQUAL(pszDomain,<font class="stringliteral">""</font>) )
00263     {
00264         <a class="code" href="cpl_error_h.html#a17">CPLError</a>( CE_Failure, CPLE_NotSupported, 
00265                   <font class="stringliteral">"Non-default domain not supported for this object."</font> );
00266         <font class="keywordflow">return</font> CE_Failure;
00267     }
00268 
00269     papszMetadata = CSLSetNameValue( papszMetadata, pszName, pszValue );
00270 
00271     <font class="keywordflow">return</font> CE_None;
00272 }
00273 
00274 <font class="comment">/************************************************************************/</font>
00275 <font class="comment">/*                        GDALSetMetadataItem()                         */</font>
00276 <font class="comment">/************************************************************************/</font>
00277 
00278 CPLErr GDALSetMetadataItem( GDALMajorObjectH hObject, 
00279                             <font class="keyword">const</font> <font class="keywordtype">char</font> *pszName, <font class="keyword">const</font> <font class="keywordtype">char</font> *pszValue, 
00280                             <font class="keyword">const</font> <font class="keywordtype">char</font> *pszDomain )<font class="keyword"></font>
00281 <font class="keyword"></font>
00282 <font class="keyword"></font>{
00283     <font class="keywordflow">return</font> ((GDALMajorObject *) hObject)-&gt;SetMetadataItem( pszName, pszValue,
00284                                                            pszDomain );
00285 }
</div></pre><hr><address><small>Generated at Thu Mar 28 09:47:30 2002 for GDAL by
<a href="http://www.stack.nl/~dimitri/doxygen/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.3-20001105 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2000</small></address>
</body>
</html>