LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
HandlerStreamBuf.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
* Copyright (C) 2004-2012 by CEA LIST *
8
* *
9
***************************************************************************/
10
#include "
HandlerStreamBuf.h
"
11
12
#define BUFFER_SIZE 4096
13
14
using namespace
std
;
15
16
namespace
Lima
{
17
18
19
HandlerStreamBuf::HandlerStreamBuf
(
AbstractAnalysisHandler
* handler) :
20
m_handler(handler)
21
{
22
m_pbuf =
new
char
[
BUFFER_SIZE
];
23
setp(m_pbuf,m_pbuf+
BUFFER_SIZE
);
24
}
25
26
27
HandlerStreamBuf::~HandlerStreamBuf
()
28
{
29
sync
();
30
delete
[] m_pbuf;
31
}
32
33
int
HandlerStreamBuf::overflow
(
int
c)
34
{
35
if
(
sync
())
return
EOF;
36
if
(c != EOF)
37
{
38
char
cbuf[1];
39
cbuf[0] = c;
40
m_handler->
handle
(cbuf,1);
41
}
42
return
0;
43
}
44
45
int
HandlerStreamBuf::sync
()
46
{
47
if
(pbase()!=pptr())
48
{
49
flushBuffer
();
50
}
51
return
0;
52
}
53
54
void
HandlerStreamBuf::flushBuffer
()
55
{
56
streamsize len = (pptr() - pbase());
57
m_handler->
handle
(pbase(),len);
58
setp(pbase(), epptr());
59
}
60
61
62
}
BUFFER_SIZE
#define BUFFER_SIZE
Definition
HandlerStreamBuf.cpp:12
HandlerStreamBuf.h
Lima::AbstractAnalysisHandler
The AbstractAnalysisHandler class defines the callback interface: the functions that are to be define...
Definition
AbstractAnalysisHandler.h:23
Lima::AbstractAnalysisHandler::handle
virtual void handle(const char *buf, int length)=0
main function of the handler: handle data produced by the dumper at end of the analysis of a given te...
Lima::HandlerStreamBuf::HandlerStreamBuf
HandlerStreamBuf(AbstractAnalysisHandler *handler)
Definition
HandlerStreamBuf.cpp:19
Lima::HandlerStreamBuf::flushBuffer
void flushBuffer()
Definition
HandlerStreamBuf.cpp:54
Lima::HandlerStreamBuf::sync
int sync() override
Definition
HandlerStreamBuf.cpp:45
Lima::HandlerStreamBuf::overflow
int overflow(int c) override
Definition
HandlerStreamBuf.cpp:33
Lima::HandlerStreamBuf::~HandlerStreamBuf
virtual ~HandlerStreamBuf()
Definition
HandlerStreamBuf.cpp:27
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
std
STL namespace.
lima_common
src
common
MediaProcessors
HandlerStreamBuf.cpp
Generated by
1.9.8