strusAnalyzer  0.17
pattern_serialize.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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_PATTERN_SERIALIZE_LIB_HPP_INCLUDED
11 #define _STRUS_ANALYZER_PATTERN_SERIALIZE_LIB_HPP_INCLUDED
12 #include <string>
13 #include <iostream>
14 
16 namespace strus {
17 
19 class PatternTermFeederInterface;
21 class PatternTermFeederInstanceInterface;
23 class PatternLexerInterface;
25 class PatternLexerInstanceInterface;
27 class PatternMatcherInterface;
29 class PatternMatcherInstanceInterface;
31 class ErrorBufferInterface;
33 struct SerializerData;
34 
38 {
39 public:
40  enum {MaxContentBufSize=1<<20};
41 
42 public:
44  PatternSerializer( SerializerData* serializerData_, PatternLexerInstanceInterface* lexer_, PatternMatcherInstanceInterface* matcher_, ErrorBufferInterface* errorhnd_)
45  :m_errorhnd(errorhnd_),m_serializerData(serializerData_),m_lexer(lexer_),m_feeder(0),m_matcher(matcher_){}
47  PatternSerializer( SerializerData* serializerData_, PatternTermFeederInstanceInterface* feeder_, PatternMatcherInstanceInterface* matcher_, ErrorBufferInterface* errorhnd_)
48  :m_errorhnd(errorhnd_),m_serializerData(serializerData_),m_lexer(0),m_feeder(feeder_),m_matcher(matcher_){}
51 
53  PatternLexerInstanceInterface* lexer() {return m_lexer;}
58 
59  bool close();
60 
61 private:
62  PatternSerializer( const PatternSerializer&){} //... non copyable
63  void operator=( const PatternSerializer&){} //... non copyable
64 
65 private:
66  ErrorBufferInterface* m_errorhnd;
67  SerializerData* m_serializerData;
68  PatternLexerInstanceInterface* m_lexer;
69  PatternTermFeederInstanceInterface* m_feeder;
70  PatternMatcherInstanceInterface* m_matcher;
71 };
72 
75 {
78 };
79 
83  const std::string& m_itrcontent,
84  ErrorBufferInterface* errorhnd);
85 
86 
91 PatternSerializer*
93  const std::string& filename,
94  const PatternSerializerType& serializerType,
95  ErrorBufferInterface* errorhnd);
96 
101 PatternSerializer*
103  std::ostream& output,
104  const PatternSerializerType& serializerType,
105  ErrorBufferInterface* errorhnd);
106 
113  const std::string& source,
114  PatternLexerInstanceInterface* lexer,
115  PatternMatcherInstanceInterface* matcher,
116  ErrorBufferInterface* errorhnd);
117 
124  const std::string& source,
125  PatternTermFeederInstanceInterface* feeder,
126  PatternMatcherInstanceInterface* matcher,
127  ErrorBufferInterface* errorhnd);
128 }//namespace
129 #endif
130 
PatternTermFeederInstanceInterface * feeder()
Get the term feeder interface to instantiate or 0, if not defined.
Definition: pattern_serialize.hpp:55
Definition: pattern_serialize.hpp:76
Instance interface for defining a mapping of terms of the document analysis outout as lexems used as ...
Definition: patternTermFeederInstanceInterface.hpp:20
bool isPatternSerializerContent(const std::string &m_itrcontent, ErrorBufferInterface *errorhnd)
Evaluate, if a content is a pattern serialization.
Definition: pattern_serialize.hpp:40
Interface for building the automaton for detecting patterns in text.
Definition: patternMatcherInstanceInterface.hpp:22
~PatternSerializer()
Destructor.
Interface for building the automaton for detecting lexems used as basic entities by pattern matching ...
Definition: patternLexerInstanceInterface.hpp:23
PatternSerializer * createPatternSerializerText(std::ostream &output, const PatternSerializerType &serializerType, ErrorBufferInterface *errorhnd)
Create a serializer of patterns loaded as text to a stream.
PatternSerializer(SerializerData *serializerData_, PatternLexerInstanceInterface *lexer_, PatternMatcherInstanceInterface *matcher_, ErrorBufferInterface *errorhnd_)
Constructor.
Definition: pattern_serialize.hpp:44
PatternSerializerType
Defines different types of pattern matchers to serialize.
Definition: pattern_serialize.hpp:74
PatternSerializer * createPatternSerializer(const std::string &filename, const PatternSerializerType &serializerType, ErrorBufferInterface *errorhnd)
Create a serializer of patterns loaded.
Object with all interfaces needed for serialization.
Definition: pattern_serialize.hpp:37
PatternLexerInstanceInterface * lexer()
Get the lexer interface to instantiate or 0, if not defined.
Definition: pattern_serialize.hpp:53
PatternMatcherInstanceInterface * matcher()
Get the pattern matcher interface to instantiate.
Definition: pattern_serialize.hpp:57
Definition: pattern_serialize.hpp:77
bool loadPatternMatcherFromSerialization(const std::string &source, PatternLexerInstanceInterface *lexer, PatternMatcherInstanceInterface *matcher, ErrorBufferInterface *errorhnd)
Instantiate pattern matching interfaces from serialization.
PatternSerializer(SerializerData *serializerData_, PatternTermFeederInstanceInterface *feeder_, PatternMatcherInstanceInterface *matcher_, ErrorBufferInterface *errorhnd_)
Constructor.
Definition: pattern_serialize.hpp:47