LCOV - code coverage report
Current view: directory - frmts/pcidsk/sdk/core - pcidsk_pubutils.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 32 11 34.4 %
Date: 2010-01-09 Functions: 3 2 66.7 %

       1                 : /******************************************************************************
       2                 :  *
       3                 :  * Purpose:  Various public (documented) utility functions.
       4                 :  * 
       5                 :  ******************************************************************************
       6                 :  * Copyright (c) 2009
       7                 :  * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada
       8                 :  *
       9                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      10                 :  * copy of this software and associated documentation files (the "Software"),
      11                 :  * to deal in the Software without restriction, including without limitation
      12                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      13                 :  * and/or sell copies of the Software, and to permit persons to whom the
      14                 :  * Software is furnished to do so, subject to the following conditions:
      15                 :  *
      16                 :  * The above copyright notice and this permission notice shall be included
      17                 :  * in all copies or substantial portions of the Software.
      18                 :  *
      19                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      20                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      22                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      24                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      25                 :  * DEALINGS IN THE SOFTWARE.
      26                 :  ****************************************************************************/
      27                 : #include "pcidsk_config.h"
      28                 : #include "pcidsk_types.h"
      29                 : #include "pcidsk_exception.h"
      30                 : #include "core/pcidsk_utils.h"
      31                 : #include <cstdlib>
      32                 : #include <cstring>
      33                 : 
      34                 : using namespace PCIDSK;
      35                 : 
      36                 : /************************************************************************/
      37                 : /*                            DataTypeSize()                            */
      38                 : /************************************************************************/
      39                 : 
      40                 : /**
      41                 :  * Return size of data type.
      42                 :  *
      43                 :  * @param chan_type the channel type enumeration value.
      44                 :  *
      45                 :  * @return the size of the passed data type in bytes, or zero for unknown 
      46                 :  * values.
      47                 :  */
      48                 : 
      49             647 : int PCIDSK::DataTypeSize( eChanType chan_type )
      50                 : 
      51                 : {
      52             647 :     switch( chan_type )
      53                 :     {
      54                 :       case CHN_8U:
      55             449 :         return 1;
      56                 :       case CHN_16S:
      57              18 :         return 2;
      58                 :       case CHN_16U:
      59             162 :         return 2;
      60                 :       case CHN_32R:
      61              18 :         return 4;
      62                 :       default:
      63               0 :         return 0;
      64                 :     }
      65                 : }
      66                 : 
      67                 : /************************************************************************/
      68                 : /*                            DataTypeName()                            */
      69                 : /************************************************************************/
      70                 : 
      71                 : /**
      72                 :  * Return name for the data type.
      73                 :  *
      74                 :  * The returned values are suitable for display to people, and matches
      75                 :  * the portion of the name after the underscore (ie. "8U" for CHN_8U.
      76                 :  *
      77                 :  * @param chan_type the channel type enumeration value to be translated.
      78                 :  *
      79                 :  * @return a string representing the data type.
      80                 :  */
      81                 : 
      82               0 : std::string PCIDSK::DataTypeName( eChanType chan_type )
      83                 : 
      84                 : {
      85               0 :     switch( chan_type )
      86                 :     {
      87                 :       case CHN_8U:
      88               0 :         return "8U";
      89                 :       case CHN_16S:
      90               0 :         return "16S";
      91                 :       case CHN_16U:
      92               0 :         return "16U";
      93                 :       case CHN_32R:
      94               0 :         return "32R";
      95                 :       default:
      96               0 :         return "UNK";
      97                 :     }
      98                 : }
      99                 : /************************************************************************/
     100                 : /*                          SegmentTypeName()                           */
     101                 : /************************************************************************/
     102                 : 
     103                 : /**
     104                 :  * Return name for segment type.
     105                 :  *
     106                 :  * Returns a short name for the segment type code passed in.  This is normally
     107                 :  * the portion of the enumeration name that comes after the underscore - ie. 
     108                 :  * "BIT" for SEG_BIT. 
     109                 :  * 
     110                 :  * @param type the segment type code.
     111                 :  *
     112                 :  * @return the string for the segment type.
     113                 :  */
     114                 : 
     115              85 : std::string PCIDSK::SegmentTypeName( eSegType type )
     116                 : 
     117                 : {
     118              85 :     switch( type )
     119                 :     {
     120                 :       case SEG_BIT:
     121               0 :         return "BIT";
     122                 :       case SEG_VEC:
     123               0 :         return "VEC";
     124                 :       case SEG_SIG:
     125               0 :         return "SIG";
     126                 :       case SEG_TEX:
     127               0 :         return "TEX";
     128                 :       case SEG_GEO:
     129              52 :         return "GEO";
     130                 :       case SEG_ORB:
     131               0 :         return "ORB";
     132                 :       case SEG_LUT:
     133               0 :         return "LUT";
     134                 :       case SEG_PCT:
     135               2 :         return "PCT";
     136                 :       case SEG_BLUT:
     137               0 :         return "BLUT";
     138                 :       case SEG_BPCT:
     139               0 :         return "BPCT";
     140                 :       case SEG_BIN:
     141               0 :         return "BIN";
     142                 :       case SEG_ARR:
     143               0 :         return "ARR";
     144                 :       case SEG_SYS:
     145              31 :         return "SYS";
     146                 :       case SEG_GCPOLD:
     147               0 :         return "GCPOLD";
     148                 :       case SEG_GCP2:
     149               0 :         return "GCP2";
     150                 :       default:
     151               0 :         return "UNKNOWN";
     152                 :     }
     153                 : }
     154                 : 

Generated by: LCOV version 1.7