/usr/include/x86_64-linux-gnu/zypp/ByteCount.h is in libzypp-dev 15.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | /*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
| / /__ | | | | | | |
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
/** \file zypp/ByteCount.h
*
*/
#ifndef ZYPP_BYTECOUNT_H
#define ZYPP_BYTECOUNT_H
#include <iosfwd>
#include "zypp/base/Unit.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ByteCount
//
/** Store and operate with byte count.
*
*/
class ByteCount
{
friend std::ostream & operator<<( std::ostream & str, const ByteCount & obj );
public:
typedef base::Unit Unit;
typedef Unit::ValueType SizeType;
/** \name Byte unit constants. */
//@{
/** 1 Byte */
static const Unit B;
/** 1024 Byte */
static const Unit K;
static const Unit KiB;
/** 1024^2 Byte */
static const Unit M;
static const Unit MiB;
/** 1024^3 Byte */
static const Unit G;
static const Unit GiB;
/** 1024^4 Byte */
static const Unit T;
static const Unit TiB;
/** 1000 Byte */
static const Unit kB;
/** 1000^2 Byte */
static const Unit MB;
/** 1000^3 Byte */
static const Unit GB;
/** 1000^4 Byte */
static const Unit TB;
//@}
public:
/** Default ctor */
ByteCount()
: _count( 0 )
{}
/** Ctor taking 1 Unit. */
ByteCount( const Unit & unit_r )
: _count( unit_r.factor() )
{}
/** Ctor taking a count and optinal Unit. */
ByteCount( const SizeType count_r, const Unit & unit_r = B )
: _count( count_r * unit_r.factor() )
{}
public:
/** Conversion to SizeType. */
operator SizeType() const
{ return _count; }
/** \name Arithmetic operations.
* \c + \c - \c * \c / are provided via conversion to SizeType.
*/
//@{
ByteCount & operator+=( const SizeType rhs ) { _count += rhs; return *this; }
ByteCount & operator-=( const SizeType rhs ) { _count -= rhs; return *this; }
ByteCount & operator*=( const SizeType rhs ) { _count *= rhs; return *this; }
ByteCount & operator/=( const SizeType rhs ) { _count /= rhs; return *this; }
ByteCount & operator++(/*prefix*/) { _count += 1; return *this; }
ByteCount & operator--(/*prefix*/) { _count -= 1; return *this; }
ByteCount operator++(int/*postfix*/) { return _count++; }
ByteCount operator--(int/*postfix*/) { return _count--; }
//@}
/** Adjust count to multiple of \a blocksize_r (default 1K).
* Zero blocksize_r is treated as 1B.
*/
ByteCount & fillBlock( ByteCount blocksize_r = K );
/** Return count adjusted to multiple of \a blocksize_r (default 1K). */
ByteCount fullBlocks( ByteCount blocksize_r = K ) const
{ return ByteCount(*this).fillBlock( blocksize_r ); }
/** Return number of blocks of size \a blocksize_r (default 1K). */
SizeType blocks( ByteCount blocksize_r = K ) const
{ return fullBlocks( blocksize_r ) / blocksize_r; }
public:
/** Return the best Unit (B,K,M,G,T) for count. */
const Unit & bestUnit() const;
/** Return the best Unit (B,kB,MB,GB,TB) for count. */
const Unit & bestUnit1000() const;
/** \name Conversion to string.
* \li \a field_width_r Width for the number part (incl. precision)
* \li \a unit_width_r With for the unit symbol (without symbol if zero)
* \li \a prec_r Precision to use.
* \see zypp::base::Unit
*/
//@{
/** Auto selected Unit and precision. */
std::string asString( unsigned field_width_r = 0,
unsigned unit_width_r = 1 ) const
{ return asString( bestUnit(), field_width_r, unit_width_r ); }
/** Auto selected Unit. */
std::string asString( unsigned field_width_r,
unsigned unit_width_r,
unsigned prec_r ) const
{ return asString( bestUnit(), field_width_r, unit_width_r, prec_r ); }
/** Auto selected precision. */
std::string asString( const Unit & unit_r,
unsigned field_width_r = 0,
unsigned unit_width_r = 1 ) const
{ return asString( unit_r, field_width_r, unit_width_r, unit_r.prec() ); }
/** Nothing auto selected. */
std::string asString( const Unit & unit_r,
unsigned field_width_r,
unsigned unit_width_r,
unsigned prec_r ) const
{ return unit_r.form( _count, field_width_r, unit_width_r, prec_r ); }
//@}
private:
SizeType _count;
};
///////////////////////////////////////////////////////////////////
/** \relates ByteCount Stream output */
inline std::ostream & operator<<( std::ostream & str, const ByteCount & obj )
{ return str << obj.asString(); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_BYTECOUNT_H
|