LTP GCOV extension - code coverage report
Current view: | directory - ept/debtags - tag.cc
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 59
Code covered: | 74.6 % |  | Executed lines: | 44

           1                 : /* -*- C++ -*-
           2                 :  * Copyright (C) 2005,2006  Enrico Zini <enrico@debian.org>
           3                 :  *
           4                 :  * This program is free software; you can redistribute it and/or modify
           5                 :  * it under the terms of the GNU General Public License as published by
           6                 :  * the Free Software Foundation; either version 2 of the License, or
           7                 :  * (at your option) any later version.
           8                 :  *
           9                 :  * This program is distributed in the hope that it will be useful,
          10                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
          11                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          12                 :  * GNU General Public License for more details.
          13                 :  *
          14                 :  * You should have received a copy of the GNU General Public License
          15                 :  * along with this program; if not, write to the Free Software
          16                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
          17                 :  */
          18                 :
          19                 : #include <ept/debtags/tag.h>
          20                 : #include <ept/debtags/vocabulary.h>
          21                 : #include <stdexcept>
          22                 :
          23                 : namespace ept {
          24                 : namespace debtags {
          25                 :
          26                 : static inline std::string constget(const std::map<std::string, std::string>& m,
          27            3898 :                                    const std::string& key)
          28                 : {
          29            3898 :         std::map<std::string, std::string>::const_iterator i = m.find(key);
          30            3898 :         if (i == m.end())
          31               4 :                 return std::string();
          32                 :         else
          33            3894 :                 return i->second;
          34                 : }
          35                 :
          36              59 : std::string Facet::name() const
          37                 : {
          38              59 :         if (valid())
          39              59 :                 return m_tags->facetName(m_id);
          40               0 :         throw std::out_of_range( "No name for this facet" );
          41                 : }
          42              29 : std::string Facet::name(const std::string& d) const
          43                 : {
          44              29 :         return valid() ? m_tags->facetName(m_id) : d;
          45                 : }
          46                 :
          47              59 : std::string Facet::shortDescription() const
          48                 : {
          49              59 :         if (valid())
          50              59 :                 return constget(m_tags->facetData(m_id), "_SD_");
          51               0 :         throw std::out_of_range( "No short description for this facet" );
          52                 : }
          53              29 : std::string Facet::shortDescription(const std::string& d) const
          54                 : {
          55              29 :         return valid() ? constget(m_tags->facetData(m_id), "_SD_") : d;
          56                 : }
          57                 :
          58              59 : std::string Facet::longDescription() const
          59                 : {
          60              59 :         if (valid())
          61              59 :                 return constget(m_tags->facetData(m_id), "Description");
          62               0 :         throw std::out_of_range( "No long description for this facet" );
          63                 : }
          64              29 : std::string Facet::longDescription(const std::string& d) const
          65                 : {
          66              29 :         return valid() ? constget(m_tags->facetData(m_id), "Description") : d;
          67                 : }
          68                 :
          69               0 : bool Facet::hasTag(const std::string& name) const
          70                 : {
          71               0 :         if (!valid())
          72               0 :                 throw std::out_of_range( "hasTag() called on an invalid facet" );
          73               0 :         return m_tags->hasTag(this->name() + "::" + name);
          74                 : }
          75                 :
          76              89 : std::set< Tag > Facet::tags() const
          77                 : {
          78              89 :         if (!valid())
          79               1 :                 throw std::out_of_range( "tags() called on an invalid facet" );
          80              88 :         return m_tags->tags(m_id);
          81                 : }
          82                 :
          83                 :
          84               0 : Facet Tag::facet() const
          85                 : {
          86               0 :         if (valid())
          87               0 :                 return m_tags->facetByTag(m_id);
          88               0 :         throw std::out_of_range( "No facet for this tag" );
          89                 : }
          90                 :
          91            1243 : std::string Tag::name() const
          92                 : {
          93            1243 :         if (valid())
          94            1243 :                 return m_tags->tagShortName(m_id);
          95               0 :         throw std::out_of_range( "No name for this tag" );
          96                 : }
          97             620 : std::string Tag::name(const std::string& d) const
          98                 : {
          99             620 :         return valid() ? m_tags->tagShortName(m_id) : d;
         100                 : }
         101                 :
         102            1284 : std::string Tag::fullname() const
         103                 : {
         104            1284 :         if (valid())
         105            1284 :                 return m_tags->tagName(m_id);
         106               0 :         throw std::out_of_range( "No full name for this tag" );
         107                 : }
         108             620 : std::string Tag::fullname(const std::string& d) const
         109                 : {
         110             620 :         return valid() ? m_tags->tagName(m_id) : d;
         111                 : }
         112                 :
         113            1242 : std::string Tag::shortDescription() const
         114                 : {
         115            1242 :         if (valid())
         116            1242 :                 return constget(m_tags->tagData(m_id), "_SD_");
         117               0 :         throw std::out_of_range( "No short description for this tag" );
         118                 : }
         119             620 : std::string Tag::shortDescription(const std::string& d) const
         120                 : {
         121             620 :         return valid() ? constget(m_tags->tagData(m_id), "_SD_") : d;
         122                 : }
         123                 :
         124            1240 : std::string Tag::longDescription() const
         125                 : {
         126            1240 :         if (valid())
         127            1240 :                 return constget(m_tags->tagData(m_id), "Description");
         128               0 :         throw std::out_of_range( "No long description for this tag" );
         129                 : }
         130             620 : std::string Tag::longDescription(const std::string& d) const
         131                 : {
         132             620 :         return valid() ? constget(m_tags->tagData(m_id), "Description") : d;
         133                 : }
         134                 :
         135                 : }
         136                 : }
         137                 :
         138                 : // vim:set ts=3 sw=3:

Generated by: LTP GCOV extension version 1.6