LCOV - code coverage report
Current view: top level - api - documentvaluelist.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core fcfb185a9dd5 Lines: 11 26 42.3 %
Date: 2019-04-18 16:33:14 Functions: 4 7 57.1 %
Branches: 2 32 6.2 %

           Branch data     Line data    Source code
       1                 :            : /** @file documentvaluelist.cc
       2                 :            :  * @brief Iteration over values in a document.
       3                 :            :  */
       4                 :            : /* Copyright (C) 2008,2009,2011,2013 Olly Betts
       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 as
       8                 :            :  * published by the Free Software Foundation; either version 2 of the
       9                 :            :  * 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 St, Fifth Floor, Boston, MA  02110-1301 USA
      19                 :            :  */
      20                 :            : 
      21                 :            : #include <config.h>
      22                 :            : 
      23                 :            : #include "documentvaluelist.h"
      24                 :            : 
      25                 :            : #include "backends/documentinternal.h"
      26                 :            : #include "omassert.h"
      27                 :            : #include "str.h"
      28                 :            : #include "unicode/description_append.h"
      29                 :            : 
      30                 :            : #include "xapian/error.h"
      31                 :            : 
      32                 :            : using namespace std;
      33                 :            : 
      34                 :            : Xapian::docid
      35                 :          0 : DocumentValueList::get_docid() const
      36                 :            : {
      37 [ #  # ][ #  # ]:          0 :     throw Xapian::InvalidOperationError("get_docid() isn't valid when iterating over values in a document");
                 [ #  # ]
      38                 :            : }
      39                 :            : 
      40                 :            : Xapian::valueno
      41                 :    2674242 : DocumentValueList::get_valueno() const
      42                 :            : {
      43                 :            :     Assert(!at_end());
      44                 :    2674242 :     return it->first;
      45                 :            : }
      46                 :            : 
      47                 :            : string
      48                 :    2812377 : DocumentValueList::get_value() const
      49                 :            : {
      50                 :            :     Assert(!at_end());
      51                 :    2812377 :     return it->second;
      52                 :            : }
      53                 :            : 
      54                 :            : bool
      55                 :    3053680 : DocumentValueList::at_end() const
      56                 :            : {
      57                 :    3053680 :     return it == doc->values->end();
      58                 :            : }
      59                 :            : 
      60                 :            : void
      61                 :    3053680 : DocumentValueList::next()
      62                 :            : {
      63         [ +  + ]:    3053680 :     if (it == doc->values->end()) {
      64                 :     379813 :         it = doc->values->begin();
      65                 :            :     } else {
      66                 :    2673867 :         ++it;
      67                 :            :     }
      68                 :    3053680 : }
      69                 :            : 
      70                 :            : void
      71                 :          0 : DocumentValueList::skip_to(Xapian::docid slot)
      72                 :            : {
      73                 :          0 :     it = doc->values->lower_bound(slot);
      74                 :          0 : }
      75                 :            : 
      76                 :            : string
      77                 :          0 : DocumentValueList::get_description() const
      78                 :            : {
      79         [ #  # ]:          0 :     string desc = "DocumentValueList(";
      80 [ #  # ][ #  # ]:          0 :     if (!at_end()) {
      81         [ #  # ]:          0 :         desc += "slot=";
      82 [ #  # ][ #  # ]:          0 :         desc += str(get_valueno());
                 [ #  # ]
      83         [ #  # ]:          0 :         desc += ", value=\"";
      84 [ #  # ][ #  # ]:          0 :         description_append(desc, get_value());
      85         [ #  # ]:          0 :         desc += "\")";
      86                 :            :     } else {
      87         [ #  # ]:          0 :         desc += "atend)";
      88                 :            :     }
      89                 :          0 :     return desc;
      90                 :            : }

Generated by: LCOV version 1.11