LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AbstractXmlDocumentHandler.h
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 * File : abstractXmlDocumentHandler.cpp
8 * Author : CEA LIST
9 * Created on : janvier 2010
10 * Copyright : (c) 2010 by CEA
11 * brief : Manipulateur de données XML
12 ******************************************************************************/
13#ifndef ABSTRACTXMLDOCUMENTHANDLER_H
14#define ABSTRACTXMLDOCUMENTHANDLER_H
15
16#include <sstream>
17#include <vector>
24
25
26namespace Lima {
27
32 public StructureHandler,
35 public ContentHandler<Common::Misc::GenericDocumentProperties>,
36 public ContentHandler< std::vector<float> >
37{
38public:
39 AbstractXmlDocumentHandler(std::shared_ptr<const ShiftFrom> shiftFrom):
43// AbstractTextualAnalysisHandler(),
44 ContentHandler<Common::Misc::GenericDocumentProperties>(),
45 ContentHandler< std::vector<float> >(),
48 m_lastNode(0),
50 {}
51
53
57
60 };
61
63 {
64 m_lastNode=NID;
65 };
66
68 {
69 return m_lastNode;
70 };
71
72 std::string get_lastUri() const
73 {
74 if (m_metadata.find("LastUri")!=m_metadata.end())
75 return m_metadata.find("LastUri")->second;
76 else
77 return "";
78 };
79
80 void set_lastUri(std::string uri)
81 {
82 m_metadata["LastUri"]=uri;
83 };
84
85 void set_lang(std::string lang)
86 {
87 m_metadata["Lang"]=lang;
88 };
89
90 std::string get_lang() const
91 {
92 if (m_metadata.find("Lang")!=m_metadata.end())
93 return m_metadata.find("Lang")->second;
94 else
95 return ""; //should not suppose a default language. Weird bugs otherwise.
96 };
97
98 virtual void startAnalysis() {}
99 virtual void startAnalysis(const std::string& bloc_type) {LIMA_UNUSED(bloc_type)}
100
101 std::vector<NODE_ID> m_openedNodes;
102 std::vector<NODE_ID>::iterator m_lastOpenedNode;
105 std::map<std::string,std::string> m_metadata;
106};
107
108}
109
110#endif
#define LIMA_UNUSED(x)
Definition LimaCommon.h:224
The AbstractAnalysisHandler class defines the callback interface: the functions that are to be define...
std::shared_ptr< const ShiftFrom > shiftFrom() const
abstract handler for XML processing : just inherits from different handlers
virtual void startAnalysis()
function called by the LIMA analyzer on start of a new document
virtual void startAnalysis(const std::string &bloc_type)
AbstractXmlDocumentHandler(std::shared_ptr< const ShiftFrom > shiftFrom)
std::map< std::string, std::string > m_metadata
std::vector< NODE_ID >::iterator m_lastOpenedNode
manipulateur de contenu
NAUTITIA.
uint64_t NODE_ID
Identifier of a node in a document.
Definition DataTypes.h:40
STL namespace.