gloox
1.0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
compressiondefault.cpp
1
/*
2
* Copyright (c) 2009-2012 by Jakob Schroeter <js@camaya.net>
3
* This file is part of the gloox library. http://camaya.net/gloox
4
*
5
* This software is distributed under a license. The full license
6
* agreement can be found in the file LICENSE in this distribution.
7
* This software may not be copied, modified, sold or distributed
8
* other than expressed in the named license agreement.
9
*
10
* This software is distributed without any warranty.
11
*/
12
13
#include "compressiondefault.h"
14
15
#include "compressiondatahandler.h"
16
17
#include "config.h"
18
19
#if defined( HAVE_ZLIB )
20
# define HAVE_COMPRESSION
21
# include "compressionzlib.h"
22
#endif
23
24
// #if defined( HAVE_LZW )
25
// # define HAVE_COMPRESSION
26
// # include "compressionlzw.h"
27
// #endif
28
29
namespace
gloox
30
{
31
32
CompressionDefault::CompressionDefault
(
CompressionDataHandler
* cdh,
Method
method )
33
:
CompressionBase
( cdh ), m_impl( 0 )
34
{
35
switch
( method )
36
{
37
case
MethodZlib
:
38
#ifdef HAVE_ZLIB
39
m_impl =
new
CompressionZlib
( cdh );
40
#endif
41
break
;
42
case
MethodLZW
:
43
#ifdef HAVE_LZW
44
m_impl =
new
CompressionLZW( cdh );
45
#endif
46
break
;
47
default
:
48
break
;
49
}
50
}
51
52
CompressionDefault::~CompressionDefault
()
53
{
54
delete
m_impl;
55
}
56
57
bool
CompressionDefault::init
()
58
{
59
return
m_impl ? m_impl->
init
() :
false
;
60
}
61
62
int
CompressionDefault::types
()
63
{
64
int
types
= 0;
65
#ifdef HAVE_ZLIB
66
types |=
MethodZlib
;
67
#endif
68
#ifdef HAVE_LZW
69
types |=
MethodLZW
;
70
#endif
71
return
types
;
72
}
73
74
void
CompressionDefault::compress
(
const
std::string& data )
75
{
76
if
( m_impl )
77
m_impl->
compress
( data );
78
}
79
80
void
CompressionDefault::decompress
(
const
std::string& data )
81
{
82
if
( m_impl )
83
m_impl->
decompress
( data );
84
}
85
86
void
CompressionDefault::cleanup
()
87
{
88
if
( m_impl )
89
m_impl->
cleanup
();
90
}
91
92
}
Generated on Sun Jun 30 2013 14:37:36 for gloox by
1.8.1.2