LCOV - code coverage report
Current view: top level - common - str.h (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 2 2 100.0 %
Date: 2019-06-30 05:20:33 Functions: 1 1 100.0 %
Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /** @file str.h
       2                 :            :  * @brief Convert types to std::string
       3                 :            :  */
       4                 :            : /* Copyright (C) 2009,2015 Olly Betts
       5                 :            :  *
       6                 :            :  * This program is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2 of the License, or
       9                 :            :  * (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                 :            : #ifndef XAPIAN_INCLUDED_STR_H
      22                 :            : #define XAPIAN_INCLUDED_STR_H
      23                 :            : 
      24                 :            : #include <string>
      25                 :            : 
      26                 :            : namespace Xapian {
      27                 :            : namespace Internal {
      28                 :            : 
      29                 :            : /// Convert int to std::string.
      30                 :            : std::string str(int value);
      31                 :            : 
      32                 :            : /// Convert unsigned int to std::string.
      33                 :            : std::string str(unsigned int value);
      34                 :            : 
      35                 :            : /// Convert long to std::string.
      36                 :            : std::string str(long value);
      37                 :            : 
      38                 :            : /// Convert unsigned long to std::string.
      39                 :            : std::string str(unsigned long value);
      40                 :            : 
      41                 :            : /// Convert long long to std::string.
      42                 :            : std::string str(long long value);
      43                 :            : 
      44                 :            : /// Convert unsigned long long to std::string.
      45                 :            : std::string str(unsigned long long value);
      46                 :            : 
      47                 :            : /// Convert double to std::string.
      48                 :            : std::string str(double value);
      49                 :            : 
      50                 :            : /// Convert const void * to std::string.
      51                 :            : std::string str(const void * value);
      52                 :            : 
      53                 :            : /** Convert std::string to std::string.
      54                 :            :  *
      55                 :            :  *  This is useful as it allows macros and templates to apply str() to a
      56                 :            :  *  type and have it work if that type is std::string.
      57                 :            :  */
      58                 :            : inline std::string str(const std::string & value) { return value; }
      59                 :            : 
      60                 :            : /// Convert const char * to std::string.
      61                 :            : inline std::string str(const char * value) { return value; }
      62                 :            : 
      63                 :            : /// Convert bool to std::string.
      64                 :          2 : inline std::string str(bool value) {
      65         [ +  - ]:          2 :     return std::string(1, '0' | static_cast<char>(value));
      66                 :            : }
      67                 :            : 
      68                 :            : }
      69                 :            : }
      70                 :            : 
      71                 :            : using Xapian::Internal::str;
      72                 :            : 
      73                 :            : #endif // XAPIAN_INCLUDED_STR_H

Generated by: LCOV version 1.11