strusAnalyzer  0.17
markup_document_tags.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_ANALYZER_ATTRIBUTE_TAGS_LIB_HPP_INCLUDED
11 #define _STRUS_ANALYZER_ATTRIBUTE_TAGS_LIB_HPP_INCLUDED
14 #include "strus/reference.hpp"
15 #include <string>
16 #include <vector>
17 #include <algorithm>
18 #include <stdexcept>
19 #include <memory>
20 
22 namespace strus {
23 
25 class ErrorBufferInterface;
27 class TextProcessorInterface;
28 
30 {
31 public:
33  virtual strus::analyzer::DocumentAttribute synthesizeAttribute( const std::string& tagname, const std::vector<strus::analyzer::DocumentAttribute>& attributes) const=0;
34 };
35 
37 {
38 public:
40  const TagAttributeMarkupInterface* markup() const {return m_markup.get();}
42  const std::string& selectexpr() const {return m_selectexpr;}
43 
45  DocumentTagMarkupDef( TagAttributeMarkupInterface* markup_, const std::string& selectexpr_)
46  :m_markup(markup_),m_selectexpr(selectexpr_)
47  {
48  if (!m_markup.get()) throw std::bad_alloc();
49  }
50  DocumentTagMarkupDef( const strus::Reference<TagAttributeMarkupInterface>& markup_, const std::string& selectexpr_)
51  :m_markup(markup_),m_selectexpr(selectexpr_)
52  {
53  if (!m_markup.get()) throw std::bad_alloc();
54  }
57  :m_markup(o.m_markup),m_selectexpr(o.m_selectexpr){}
58 
59 private:
60  strus::Reference<TagAttributeMarkupInterface> m_markup;
61  std::string m_selectexpr;
62 };
63 
64 
73 std::string markupDocumentTags( const analyzer::DocumentClass& documentClass, const std::string& content, const std::vector<DocumentTagMarkupDef>& markups, const TextProcessorInterface* textproc, ErrorBufferInterface* errorhnd);
74 
75 }//namespace
76 #endif
77 
DocumentTagMarkupDef(TagAttributeMarkupInterface *markup_, const std::string &selectexpr_)
Constructor.
Definition: markup_document_tags.hpp:45
virtual ~TagAttributeMarkupInterface()
Definition: markup_document_tags.hpp:32
Structure describing the MIME type plus some attributes that could be relevant for analysis of a docu...
const TagAttributeMarkupInterface * markup() const
implementation of the markup generation
Definition: markup_document_tags.hpp:40
const std::string & selectexpr() const
expression selecting the tag or sibling attribute to markup with a new attribute
Definition: markup_document_tags.hpp:42
Definition: markup_document_tags.hpp:36
DocumentTagMarkupDef(const DocumentTagMarkupDef &o)
Copy constructor.
Definition: markup_document_tags.hpp:56
Structure describing a document attribute.
Definition: documentAttribute.hpp:20
DocumentTagMarkupDef(const strus::Reference< TagAttributeMarkupInterface > &markup_, const std::string &selectexpr_)
Definition: markup_document_tags.hpp:50
std::string markupDocumentTags(const analyzer::DocumentClass &documentClass, const std::string &content, const std::vector< DocumentTagMarkupDef > &markups, const TextProcessorInterface *textproc, ErrorBufferInterface *errorhnd)
Analyze a content and put markups on every tag matching an expression.
virtual strus::analyzer::DocumentAttribute synthesizeAttribute(const std::string &tagname, const std::vector< strus::analyzer::DocumentAttribute > &attributes) const =0
Definition: markup_document_tags.hpp:29
Structure describing a document attribute.