LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/ili - iomhelper.cpp
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 46
Code covered: 0.0 % Executed lines: 0

       1                 : /******************************************************************************
       2                 :  * $Id: iomhelper.cpp 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  Interlis 1/2 Translator
       5                 :  * Purpose:  Implementation of ILI1Reader class.
       6                 :  * Author:   Pirmin Kalberer, Sourcepole AG
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : 
      31                 : #include "iomhelper.h"
      32                 : #include "cpl_port.h"
      33                 : 
      34                 : CPL_CVSID("$Id: iomhelper.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
      35                 : 
      36                 : 
      37               0 : IOM_OBJECT GetAttrObj(IOM_BASKET model, IOM_OBJECT obj, const char* attrname) {
      38               0 :     IOM_OBJECT attrobj = iom_getattrobj(obj, attrname, 0);
      39               0 :     if (attrobj == NULL) return NULL;
      40               0 :     const char *refoid=iom_getobjectrefoid(attrobj);
      41               0 :     if (refoid == NULL) return NULL;
      42               0 :     return iom_getobject(model, refoid);
      43                 : }
      44                 : 
      45               0 : int GetAttrObjPos(IOM_OBJECT obj, const char* attrname) {
      46               0 :     IOM_OBJECT attrobj = iom_getattrobj(obj, attrname, 0);
      47               0 :     if (attrobj == NULL) return -1;
      48               0 :     return iom_getobjectreforderpos(attrobj);
      49                 : }
      50                 : 
      51               0 : const char* GetAttrObjName(IOM_BASKET model, IOM_OBJECT obj, const char* attrname) {
      52               0 :     return iom_getattrvalue(GetAttrObj(model, obj, attrname), "name");
      53                 : }
      54                 : 
      55               0 : IOM_OBJECT GetTypeObj(IOM_BASKET model, IOM_OBJECT obj) {
      56               0 :     IOM_OBJECT typeobj = GetAttrObj(model, obj, "type");
      57               0 :     if (typeobj && EQUAL(iom_getobjecttag(typeobj), "iom04.metamodel.TypeAlias")) {
      58               0 :         typeobj = GetTypeObj(model, GetAttrObj(model, typeobj, "aliasing"));
      59                 :     }
      60               0 :     return typeobj;
      61                 : }
      62                 : 
      63               0 : const char* GetTypeName(IOM_BASKET model, IOM_OBJECT obj) {
      64               0 :     IOM_OBJECT typeobj = GetTypeObj(model, obj);
      65               0 :     if (typeobj == NULL) return "(null)";
      66               0 :     return iom_getobjecttag(typeobj);
      67                 : }
      68                 : 
      69               0 : unsigned int GetCoordDim(IOM_BASKET model, IOM_OBJECT typeobj) {
      70               0 :   unsigned int dim = 0;
      71                 :   //find attribute of this type with highest orderpos
      72               0 :   IOM_ITERATOR modelelei=iom_iteratorobject(model);
      73               0 :   IOM_OBJECT modelele=iom_nextobject(modelelei);
      74               0 :   while(modelele){
      75               0 :     const char *tag=iom_getobjecttag(modelele);
      76               0 :     if (tag && EQUAL(tag,"iom04.metamodel.NumericType")) {
      77               0 :       if (GetAttrObj(model, modelele, "coordType") == typeobj) {
      78               0 :         unsigned int orderpos = GetAttrObjPos(modelele, "coordType");
      79               0 :         if (orderpos > dim) dim = orderpos;
      80                 :       }
      81                 :     }
      82               0 :     iom_releaseobject(modelele);
      83               0 :     modelele=iom_nextobject(modelelei);
      84                 :   }
      85               0 :   iom_releaseiterator(modelelei);
      86                 : 
      87               0 :   return dim;
      88                 : }
      89                 : 
      90               0 : const char* GetAttrObjName(IOM_BASKET model, const char* tagname) {
      91               0 :   const char* result = NULL;
      92               0 :   IOM_ITERATOR modelelei = iom_iteratorobject(model);
      93               0 :   IOM_OBJECT modelele = iom_nextobject(modelelei);
      94               0 :   while (modelele && result == NULL)
      95                 :   {
      96               0 :       if(EQUAL(iom_getobjecttag(modelele), tagname)){
      97                 :           // get name of topic
      98               0 :           result = iom_getattrvalue(modelele, "name");
      99                 :       }
     100               0 :       iom_releaseobject(modelele);
     101               0 :       modelele=iom_nextobject(modelelei);
     102                 :   }
     103               0 :   iom_releaseiterator(modelelei);
     104               0 :   return result;
     105                 : }

Generated by: LTP GCOV extension version 1.5