LCOV - code coverage report
Current view: top level - snapwebsites - qstring_stream.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 4 0.0 %
Date: 2019-12-15 17:13:15 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Snap Websites Servers -- allow for QString in ostream (i.e. "std::cout << qstring")
       2             : // Copyright (c) 2011-2019  Made to Order Software Corp.  All Rights Reserved
       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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      17             : 
      18             : #pragma once
      19             : 
      20             : // Qt lib
      21             : //
      22             : #include <QString>
      23             : 
      24             : 
      25             : // C++ lib
      26             : //
      27             : #include <iostream>
      28             : 
      29             : 
      30             : 
      31           0 : inline std::ostream & operator << ( std::ostream & strm, QByteArray const & qarray )
      32             : {
      33           0 :     return strm << qarray.data();
      34             : }
      35             : 
      36             : 
      37           0 : inline std::ostream & operator << ( std::ostream & strm, QString const & qstr )
      38             : {
      39           0 :     return strm << qstr.toUtf8();
      40             : }
      41             : 
      42             : 
      43             : inline std::ostream & operator << ( std::ostream & strm, QStringRef const & qstr )
      44             : {
      45             :     return strm << qstr.toString();
      46             : }
      47             : 
      48             : 
      49             : inline std::string operator + ( std::string const & str, QByteArray const & qarray )
      50             : {
      51             :     return str + qarray.data();
      52             : }
      53             : 
      54             : 
      55             : inline std::string operator + ( std::string const & str, QString const & qstr )
      56             : {
      57             :     return str + qstr.toUtf8();
      58             : }
      59             : 
      60             : 
      61             : inline std::string operator + ( std::string const & str, QStringRef const & qstr )
      62             : {
      63             :     return str + qstr.toString();
      64             : }
      65             : 
      66             : 
      67             : inline std::string & operator += ( std::string & str, QByteArray const & qarray )
      68             : {
      69             :     str = str + qarray;
      70             :     return str;
      71             : }
      72             : 
      73             : 
      74             : inline std::string & operator += ( std::string & str, QString const & qstr )
      75             : {
      76             :     str = str + qstr;
      77             :     return str;
      78             : }
      79             : 
      80             : 
      81             : inline std::string & operator += ( std::string & str, QStringRef const & qstr )
      82             : {
      83             :     str = str + qstr;
      84             :     return str;
      85             : }
      86             : 
      87             : 
      88             : inline QString toQString(std::string const & s)
      89             : {
      90             :     return QString::fromUtf8(s.c_str());
      91             : }
      92             : 
      93             : 
      94             : inline std::string to_string(QString const & q)
      95             : {   
      96             :     return std::string(q.toUtf8().data());
      97             : }
      98             : 
      99             : 
     100             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13