LTP GCOV extension - code coverage report
Current view: directory - src/cpp/dev/idlc - wstring_value.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 29
Code covered: 82.8 % Executed lines: 24

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/dev/idlc/wstring_value.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 <stdio.h>
      23                 : 
      24                 : #include "src/cpp/prod/tool/DEVELOPMENT.h"
      25                 : #include "src/cpp/prod/tool/Assert.h"
      26                 : #include "src/cpp/prod/tool/WString.h"
      27                 : 
      28                 : #include "src/cpp/dev/idlc/wstring_value.h"
      29                 : #include "src/cpp/dev/idlc/yyutils.h"
      30                 : 
      31              48 : static IDLWStringType global_type ;
      32                 : 
      33               0 : IDLType* IDLWStringValue::GetValueType(void) const
      34                 : {
      35                 :    return & global_type ;
      36                 : }
      37                 : 
      38               1 : IDLWStringValue::IDLWStringValue(const WString& s)
      39               1 : : IDLValue(idl_wstring), _value(s)
      40               0 : {}
      41                 : 
      42               1 : IDLWStringValue::IDLWStringValue(const IDLWStringValue& v)
      43               1 : : IDLValue(v), _value(v._value)
      44               0 : {}
      45                 : 
      46               2 : IDLWStringValue::~IDLWStringValue()
      47               2 : {}
      48                 : 
      49               0 : const WString& IDLWStringValue::GetWString(void)
      50                 : {
      51                 :    return _value ;
      52                 : }
      53                 : 
      54               1 : IDLValue* IDLWStringValue::copy(void)
      55                 : {
      56               1 :    return new IDLWStringValue(*this) ;
      57                 : }
      58                 : 
      59               2 : void IDLWStringValue::print(std::ostream &str) const
      60                 : {
      61               2 :    if (IsError())
      62                 :    {
      63               1 :       str << "idl wstring <error>" ;
      64                 :    }
      65                 :    else
      66                 :    {
      67               1 :       str << "idl wstring L\"" ;
      68                 : 
      69                 :       // DO NOT DO THAT : str << _value
      70                 :       // This **assumes** ostream has an operator for wchar_t *,
      71                 :       // which is typically missing and defaulted to void * :(
      72                 : 
      73                 :       int i = 0 ;
      74               1 :       int len = _value.length() ;
      75               1 :       const wchar_t *tmp = _value ;
      76                 :       char buffer[10] ;
      77                 : 
      78              17 :       for (i = 0 ; i < len ; i++)
      79                 :       {
      80              16 :          sprintf(buffer, "%lc%c", tmp[i], 0) ;
      81              16 :          str << buffer ;
      82                 :       }
      83                 : 
      84               1 :       str << "\"" ;
      85                 :    }
      86                 : }
      87                 : 
      88               1 : void IDLWStringValue::convert(IDLType *type)
      89                 : {
      90               1 :    if (type->isA() != idl_wstring)
      91                 :    {
      92               1 :       typeConvertionError(type) ;
      93                 :    }
      94              48 : }
      95              48 : 

Generated by: LTP GCOV extension version 1.4