LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
EventHandler.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 "EventHandler.h"
11
12#include <sstream>
13
14using namespace std;
15
16using namespace Lima::LinguisticProcessing;
17
18namespace Lima
19{
20
21namespace LinguisticProcessing
22
23{
24namespace EventAnalysis
25{
26
27 EventHandler::EventHandler(std::ostream* out)
28 : AbstractTextualAnalysisHandler(), m_stream(0), m_writer(0), m_events()
29{
30 LIMA_UNUSED(out);
31}
32
34 : AbstractTextualAnalysisHandler(), m_stream(0), m_writer(0), m_events()
35{}
36
37
39{
40 if (m_writer != 0) delete m_writer;
41 if (m_stream != 0) delete m_stream;
42}
43
45{
46 return m_events;
47}
48
49void EventHandler::setOut( std::ostream* out ) {
50 m_out = out;
51
52}
53
58
61
63{
65 LDEBUG << "EventHandler::endAnalysis()";
66 m_writer->endAnalysis();
67 istringstream in(m_stream->str());
68 LDEBUG << "EventHandler::endAnalysis(): m_stream->str= " << m_stream->str();
69 m_events.read(in);
70}
71
73{
75 LDEBUG << "EventHandler::startAnalysis()";
76 if (m_writer!=0) {
77 LDEBUG << "EventHandler::startAnalysis(): delete m_writer";
78 delete m_writer;
79 m_writer=0;
80 }
81 if (m_stream!=0) {
82 LDEBUG << "EventHandler::startAnalysis(): delete m_stream";
83 delete m_stream;
84 m_writer=0;
85 }
86 m_stream= new ostringstream();
87 m_writer=new SimpleStreamHandler();
88 m_writer->setOut(m_stream);
89 LDEBUG << "EventHandler::startAnalysis(): m_stream->StartAnalysis()...";
90 m_writer->startAnalysis();
91}
92
93
94void EventHandler::handle(const char* buf,int length)
95{
97 LDEBUG << "EventHandler::handle( buff, " << length << ")";
98 m_writer->handle(buf,length);
99}
100
101void EventHandler::startNode( const std::string& elementName, bool forIndexing )
102{
103 LIMA_UNUSED(elementName);
104 LIMA_UNUSED(forIndexing);
105}
106
111
112} // closing namespace EventAnalysis
113} // closing namespace LinguisticProcessing
114} // closing namespace Lima
#define LIMA_UNUSED(x)
Definition LimaCommon.h:224
#define LDEBUG
Definition LimaCommon.h:157
#define DUMPERLOGINIT
void endNode(const Common::Misc::GenericDocumentProperties &props) override
notify the end of a hierarchyNode
void startAnalysis() override
function called by the LIMA analyzer on start of a new document
void handle(const char *buf, int length) override
gives content.
void startNode(const std::string &elementName, bool forIndexing) override
notify the start of a new hierarchyNode
void startDocument(const Common::Misc::GenericDocumentProperties &props) override
notify the start of a new document
void endAnalysis() override
function called by the LIMA analyzer on the end of a text part that is to be analyzed
virtual void setOut(std::ostream *out) override
set the output stream.
void endDocument() override
notify the end of the document
virtual void read(std::istream &file)
Definition Events.cpp:34
void startAnalysis() override
function called by the LIMA analyzer on start of a new document
void setOut(std::ostream *out) override
set the output stream.
void endAnalysis() override
function called by the LIMA analyzer on the end of a text part that is to be analyzed
void handle(const char *buf, int length) override
gives content.
NAUTITIA.
STL namespace.