libzypp
11.13.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
libzypp
Welcome to libzypp
Code Pitfalls - Frequently made mistakes
Code Snippets
Environment Variables
Testing for provided features.
Notes on revisions
Extending ZYpp: Plugins and Hooks
Services
Solver - Vendor protection
Writing and tunning testcases
Libzypp and threads
Todo List
Deprecated List
Modules
Namespaces
Classes
Files
File List
zypp
base
media
misc
parser
pool
repo
sat
solver
target
thread
ui
url
ws
zypp_detail
APIConfig.h
Arch.cc
Arch.h
AutoDispose.h
Bit.h
ByteCount.cc
ByteCount.h
Callback.h
Capabilities.cc
Capabilities.h
Capability.cc
Capability.h
CapMatch.cc
CapMatch.h
Changelog.cc
Changelog.h
CheckSum.cc
CheckSum.h
CountryCode.cc
CountryCode.h
Date.cc
Date.h
Dep.cc
Dep.h
Digest.cc
Digest.h
DiskUsage.cc
DiskUsage.h
DiskUsageCounter.cc
DiskUsageCounter.h
DownloadMode.cc
DownloadMode.h
Edition.cc
Edition.h
ExternalProgram.cc
ExternalProgram.h
Fetcher.cc
Fetcher.h
FileChecker.cc
FileChecker.h
Filter.h
Glob.cc
Glob.h
HistoryLog.cc
HistoryLog.h
HistoryLogData.cc
HistoryLogData.h
IdString.cc
IdString.h
IdStringType.h
InstanceId.cc
InstanceId.h
KeyContext.h
KeyRing.cc
KeyRing.h
KVMap.h
LanguageCode.cc
LanguageCode.h
Locale.cc
Locale.h
Locks.cc
Locks.h
ManagedFile.h
MediaProducts.cc
MediaProducts.h
MediaSetAccess.cc
MediaSetAccess.h
Misc.h
OnMediaLocation.cc
OnMediaLocation.h
Package.cc
Package.h
PackageKeyword.h
Patch.cc
Patch.h
PathInfo.cc
PathInfo.h
Pathname.cc
Pathname.h
Pattern.cc
Pattern.h
PluginFrame.cc
PluginFrame.h
PluginFrameException.cc
PluginFrameException.h
PluginScript.cc
PluginScript.h
PluginScriptException.cc
PluginScriptException.h
PoolItem.cc
PoolItem.h
PoolItemBest.cc
PoolItemBest.h
PoolQuery.cc
PoolQuery.h
PoolQueryResult.cc
PoolQueryResult.h
PoolQueryUtil.tcc
ProblemSolution.cc
ProblemSolution.h
ProblemTypes.h
Product.cc
Product.h
ProgressData.cc
ProgressData.h
ProvideFilePolicy.cc
ProvideFilePolicy.h
PublicKey.cc
PublicKey.h
Range.cc
Range.h
Rel.cc
Rel.h
RelCompare.h
RepoInfo.cc
RepoInfo.h
RepoManager.cc
RepoManager.h
Repository.cc
Repository.h
RepoStatus.cc
RepoStatus.h
ResFilters.h
ResKind.cc
ResKind.h
ResObject.cc
ResObject.h
ResObjects.h
Resolvable.cc
Resolvable.h
Resolver.cc
Resolver.h
ResolverProblem.cc
ResolverProblem.h
ResPool.cc
ResPool.h
ResPoolProxy.cc
ResPoolProxy.h
ResStatus.cc
ResStatus.h
ResTraits.h
ServiceInfo.cc
ServiceInfo.h
Signature.cc
Signature.h
SrcPackage.cc
SrcPackage.h
SysContent.cc
SysContent.h
Target.cc
Target.h
TmpPath.cc
TmpPath.h
TriBool.h
Url.cc
Url.h
Vendor.h
VendorAttr.cc
VendorAttr.h
VendorSupportOptions.cc
VendorSupportOptions.h
ZConfig.cc
ZConfig.h
ZYpp.cc
ZYpp.h
ZYppCallbacks.h
ZYppCommit.h
ZYppCommitPolicy.cc
ZYppCommitPolicy.h
ZYppCommitResult.cc
ZYppCommitResult.h
ZYppFactory.cc
ZYppFactory.h
File Members
ByteCount.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <iostream>
13
14
#include "
zypp/ByteCount.h
"
15
16
using
std::endl;
17
19
namespace
zypp
20
{
21
22
const
ByteCount::Unit
ByteCount::B
( 1LL,
"B"
, 0 );
23
24
const
ByteCount::Unit
ByteCount::K
( 1024LL,
"KiB"
, 1 );
25
const
ByteCount::Unit
ByteCount::KiB
( K );
26
const
ByteCount::Unit
ByteCount::M
( 1048576LL,
"MiB"
, 1 );
27
const
ByteCount::Unit
ByteCount::MiB
( M );
28
const
ByteCount::Unit
ByteCount::G
( 1073741824LL,
"GiB"
, 2 );
29
const
ByteCount::Unit
ByteCount::GiB
( G );
30
const
ByteCount::Unit
ByteCount::T
( 1099511627776LL,
"TiB"
, 3 );
31
const
ByteCount::Unit
ByteCount::TiB
( T );
32
33
const
ByteCount::Unit
ByteCount::kB
( 1000LL,
"kB"
, 1 );
34
const
ByteCount::Unit
ByteCount::MB
( 1000000LL,
"MB"
, 1 );
35
const
ByteCount::Unit
ByteCount::GB
( 1000000000LL,
"GB"
, 2 );
36
const
ByteCount::Unit
ByteCount::TB
( 1000000000000LL,
"TB"
, 3 );
37
39
//
40
// METHOD NAME : ByteCount::fillBlock
41
// METHOD TYPE : ByteCount &
42
//
43
ByteCount
&
ByteCount::fillBlock
(
ByteCount
blocksize_r )
44
{
45
if
(
_count
&& blocksize_r )
46
{
47
SizeType
diff =
_count
% blocksize_r;
48
if
( diff )
49
{
50
if
(
_count
> 0 )
51
{
52
_count
+= blocksize_r;
53
_count
-= diff;
54
}
55
else
56
{
57
_count
-= blocksize_r;
58
_count
+= diff;
59
}
60
}
61
}
62
return
*
this
;
63
}
64
66
//
67
// METHOD NAME : ByteCount::bestUnit
68
// METHOD TYPE : ByteCount::Unit
69
//
70
const
ByteCount::Unit
&
ByteCount::bestUnit
()
const
71
{
72
SizeType
usize(
_count
< 0 ? -
_count
:
_count
);
73
if
( usize <
K
.
factor
() )
74
return
B
;
75
if
( usize <
M
.
factor
() )
76
return
K
;
77
if
( usize <
G
.
factor
() )
78
return
M
;
79
if
( usize <
T
.
factor
() )
80
return
G
;
81
return
T
;
82
}
83
85
//
86
// METHOD NAME : ByteCount::bestUnit1000
87
// METHOD TYPE : ByteCount::Unit
88
//
89
const
ByteCount::Unit
&
ByteCount::bestUnit1000
()
const
90
{
91
SizeType
usize(
_count
< 0 ? -
_count
:
_count
);
92
if
( usize <
kB
.
factor
() )
93
return
B
;
94
if
( usize <
MB
.
factor
() )
95
return
kB
;
96
if
( usize <
GB
.
factor
() )
97
return
MB
;
98
if
( usize <
TB
.
factor
() )
99
return
GB
;
100
return
TB
;
101
}
102
104
}
// namespace zypp
zypp
ByteCount.cc
Generated by
1.8.1