Wittyshare
0.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
wscore
src
Compression
WsDecompressor.cpp
Go to the documentation of this file.
1
/*
2
*
3
* Filename: WsDecompressor.cpp
4
*
5
* Description:
6
*
7
* Created: 07/25/2012 09:29:01 AM
8
*
9
* Author: Benoit Daccache, ben.daccache@gmail.com
10
*
11
*/
12
13
#include "
WsDecompressor.h
"
14
15
#include <
Include/WsGlobalConfig.h
>
16
#include <
Logger/WsLogger.h
>
17
18
#include <stdio.h>
19
#include <zlib.h>
20
21
22
using namespace
std;
23
24
long
WsDecompressor::decompress
(
const
char
* data,
size_t
size,
string
& uncompressedData)
25
{
26
uLongf unCompSize = 200 * size;
27
char
* to =
new
char
[unCompSize];
28
if
(uncompress((Bytef*)to, &unCompSize, (
const
Bytef*)data, size) != Z_OK) {
29
LOG
(
ERROR
) <<
"WsDecompressor :: Decompression failed"
;
30
return
ErrorCode::Failure
;
31
}
32
uncompressedData = string(to, unCompSize);
33
delete
[] to;
34
return
unCompSize;
35
}
36
WsLogger.h
ErrorCode::Failure
const int Failure
Definition:
WsGlobalConfig.h:21
LOG
#define LOG
Definition:
WsLogger.h:22
WsDecompressor::decompress
long decompress(const char *data, size_t size, std::string &uncompressedData)
decompress the input data and store result in uncompressedData
Definition:
WsDecompressor.cpp:24
WsGlobalConfig.h
WsDecompressor.h
ERROR
#define ERROR
Definition:
WsLogger.h:42
Generated on Wed Apr 23 2014 14:00:10 for Wittyshare by
1.8.6