LCOV - code coverage report
Current view: top level - lunchbox - array.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 2 2 100.0 %
Date: 2014-10-01 Functions: 2 2 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2012-2014, Stefan Eilemann <eile@eyescale.ch>
       3             :  *
       4             :  * This file is part of Lunchbox <https://github.com/Eyescale/Lunchbox>
       5             :  *
       6             :  * This library is free software; you can redistribute it and/or modify it under
       7             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       8             :  * by the Free Software Foundation.
       9             :  *
      10             :  * This library is distributed in the hope that it will be useful, but WITHOUT
      11             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      12             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      13             :  * details.
      14             :  *
      15             :  * You should have received a copy of the GNU Lesser General Public License
      16             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      17             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             :  */
      19             : 
      20             : #ifndef LUNCHBOX_ARRAY_H
      21             : #define LUNCHBOX_ARRAY_H
      22             : 
      23             : #include <lunchbox/types.h>
      24             : #include <lunchbox/debug.h>
      25             : 
      26             : namespace lunchbox
      27             : {
      28             : /** A wrapper for C arrays without any memory management. */
      29             : template< class T > class Array
      30             : {
      31             : public:
      32             :     /** Create a new array wrapper for the given data. @version 1.9.1 */
      33         566 :     Array( T* data_, const size_t num_ ) : data( data_ ), num( num_ ) {}
      34             : 
      35             :     /** @return the number of bytes stored in the pointer. @version 1.9.1 */
      36             :     size_t getNumBytes() const { return num * sizeof( T ); }
      37             : 
      38             :     T* data; //!< The data
      39             :     size_t num; //!<  The number of elements in the data
      40             : };
      41             : 
      42        1132 : template<> inline size_t Array< void >::getNumBytes() const { return num; }
      43             : template<> inline size_t Array< const void >::getNumBytes() const { return num;}
      44             : 
      45             : /** Pretty-print all members of the array. @version 1.9.1 */
      46             : template< class T >
      47             : inline std::ostream& operator << ( std::ostream& os, const Array< T >& array )
      48             : {
      49             :     return os << lunchbox::format( array.data, array.num );
      50             : }
      51             : 
      52             : }
      53             : #endif // LUNCHBOX_ARRAY_H

Generated by: LCOV version 1.10