LTP GCOV extension - code coverage report
Current view: directory - src/cpp/dev/idlc - define.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 25
Code covered: 52.0 % Executed lines: 13

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/dev/idlc/define.cpp>
       3                 : // This file is part of YaOrb : Yet Another Object Request Broker,
       4                 : // Copyright (c) 2000-2003, Marc Alff.
       5                 : //
       6                 : // This program is free software; you can redistribute it and/or
       7                 : // modify it under the terms of the GNU General Public License
       8                 : // as published by the Free Software Foundation; either version 2
       9                 : // of the License, or (at your option) any later version.
      10                 : //
      11                 : // This program is distributed in the hope that it will be useful,
      12                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 : // GNU General Public License for more details.
      15                 : //
      16                 : // You should have received a copy of the GNU General Public License
      17                 : // along with this program; if not, write to the Free Software
      18                 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
      19                 : //
      20                 : //==============================================================================
      21                 : 
      22                 : #include "src/cpp/dev/idlc/define.h"
      23                 : #include "src/cpp/dev/idlc/yyutils.h"
      24                 : 
      25              96 : Define::Define(const String& name, const String& value)
      26              96 : : _name(name), _value(value)
      27               0 : {}
      28                 : 
      29               0 : Define::~Define()
      30               0 : {}
      31                 : 
      32             431 : const String& Define::GetName(void) const
      33                 : {
      34                 :    return _name ;
      35                 : }
      36                 : 
      37              63 : DefineTable::DefineTable()
      38                 : : _defines()
      39                 : {}
      40                 : 
      41              63 : DefineTable::~DefineTable()
      42                 : {}
      43                 : 
      44              96 : void DefineTable::AddDefine(const String& name, const String& value)
      45                 : {
      46              96 :    if (IsDefined(name))
      47                 :    {
      48               0 :       IDLCompileError("#define already defined") ;
      49               0 :       errLog << "Trying to #define " << name << std::endl ;
      50                 :    }
      51                 :    else
      52                 :    {
      53              96 :       Define *d = new Define(name, value) ;
      54                 :       _defines.addTail(d) ;
      55                 :    }
      56                 : }
      57                 : 
      58               0 : void DefineTable::RemoveDefine(const String& name)
      59                 : {
      60                 :    Define *item ;
      61               0 :    DefineLstIt it(_defines) ;
      62                 : 
      63               0 :    while (it.GetNext())
      64                 :    {
      65                 :       item = it.GetItem() ;
      66               0 :       if (item->GetName() == name)
      67                 :       {
      68                 :          _defines.removeObject(item) ;
      69                 :          return ;
      70                 :       }
      71                 :    }
      72                 : 
      73               0 :    IDLCompileError("#define not defined") ;
      74               0 :    errLog << "Trying to #undef " << name << std::endl ;
      75                 : }
      76                 : 
      77             220 : bool DefineTable::IsDefined(const String& name)
      78                 : {
      79                 :    Define *item ;
      80                 :    DefineLstIt it(_defines) ;
      81                 : 
      82             851 :    while (it.GetNext())
      83                 :    {
      84                 :       item = it.GetItem() ;
      85             431 :       if (item->GetName() == name)
      86                 :       {
      87                 :          return true ;
      88                 :       }
      89                 :    }
      90                 : 
      91                 :    return false ;
      92              63 : }
      93              63 : 

Generated by: LTP GCOV extension version 1.4