LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
DumperStream.cpp
Go to the documentation of this file.
1
// Copyright 2002-2013 CEA LIST
2
// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3
//
4
// SPDX-License-Identifier: MIT
5
6
/************************************************************************
7
*
8
* @file DumperStream.cpp
9
* @author Romaric Besancon (romaric.besancon@cea.fr)
10
* @date Fri Jan 21 2011
11
* copyright Copyright (C) 2011-2012 by CEA LIST
12
*
13
***********************************************************************/
14
15
#include "
DumperStream.h
"
16
#include <fstream>
17
18
using namespace
std
;
19
20
namespace
Lima
{
21
22
//***********************************************************************
23
// constructors and destructors
24
DumperStream::DumperStream
(
AbstractAnalysisHandler
* handler):
25
m_useHandler(true),
26
m_handler(handler),
27
m_buffer(0),
28
m_out(0)
29
{
30
// DUMPERLOGINIT;
31
// LDEBUG << "DumperStream constructor: initialize buffer" ;
32
// initialize handler stream buffer
33
m_buffer=
new
HandlerStreamBuf
(m_handler);
34
m_out=
new
ostream(m_buffer);
35
// start communication with handler
36
// LDEBUG << "DumperStream constructor: start analysis (handler=" << m_handler << ")";
37
m_handler->startAnalysis();
38
}
39
40
DumperStream::DumperStream
(
const
std::string& filename,
bool
append):
41
m_useHandler(false),
42
m_handler(0),
43
m_buffer(0),
44
m_out(0)
45
{
46
if
(append) {
47
m_out=
new
ofstream(filename.c_str(),ios::app | std::ofstream::binary);
48
}
49
else
{
50
m_out=
new
ofstream(filename.c_str(), std::ofstream::binary);
51
}
52
}
53
54
DumperStream::~DumperStream
()
55
{
56
if
(m_useHandler) {
57
m_out->flush();
58
m_handler->endAnalysis();
59
delete
m_out;
60
m_out=0;
61
// do not delete the handler : allocated outside, should be deleted outside
62
//delete m_handler;
63
//m_handler=0;
64
delete
m_buffer;
65
m_buffer=0;
66
}
67
else
{
68
static_cast<
ofstream*
>
(m_out)->close();
69
delete
m_out;
70
m_out=0;
71
}
72
}
73
74
//***********************************************************************
75
76
}
// end namespace
DumperStream.h
Lima::AbstractAnalysisHandler
The AbstractAnalysisHandler class defines the callback interface: the functions that are to be define...
Definition
AbstractAnalysisHandler.h:23
Lima::DumperStream::DumperStream
DumperStream(AbstractAnalysisHandler *handler)
Definition
DumperStream.cpp:24
Lima::DumperStream::~DumperStream
~DumperStream()
Definition
DumperStream.cpp:54
Lima::HandlerStreamBuf
Definition
HandlerStreamBuf.h:23
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
std
STL namespace.
lima_common
src
common
MediaProcessors
DumperStream.cpp
Generated by
1.15.0