strusAnalyzer  0.17
pattern_resultformat.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_PATTERN_RESULTFORMAT_LIB_HPP_INCLUDED
11 #define _STRUS_ANALYZER_PATTERN_RESULTFORMAT_LIB_HPP_INCLUDED
13 #include <utility>
14 
16 namespace strus {
17 
19 class ErrorBufferInterface;
21 class DebugTraceContextInterface;
22 
25 
28 {
29 public:
32  explicit PatternResultFormatContext( ErrorBufferInterface* errorhnd_);
35 
41  const char* map( const PatternResultFormat* fmt, const analyzer::PatternMatcherResultItem* items, std::size_t nofItems);
42 
43 private:
44  ErrorBufferInterface* m_errorhnd;
45  DebugTraceContextInterface* m_debugtrace;
46  struct Impl;
47  Impl* m_impl;
48 };
49 
53 {
54 public:
56 
57  virtual const char* getVariable( const std::string& name) const=0;
58 };
59 
62 {
63 public:
64  PatternResultFormatTable( const PatternResultFormatVariableMap* variableMap_, ErrorBufferInterface* errorhnd_);
66 
71  const PatternResultFormat* createResultFormat( const char* src);
72 
73 private:
74  ErrorBufferInterface* m_errorhnd;
75  const PatternResultFormatVariableMap* m_variableMap;
76  struct Impl;
77  Impl* m_impl;
78 };
79 
80 
83 {
84  const char* value;
85  std::size_t valuesize;
86  int start_seg;
87  int start_pos;
88  int end_seg;
89  int end_pos;
90 
92  static bool parseNext( PatternResultFormatChunk& result, char const*& src, ErrorBufferInterface* errorhnd);
93 };
94 
97 {
98 public:
118  PatternResultFormatMap( const char* src_, ErrorBufferInterface* errorhnd_);
121 
125  std::string map( const analyzer::PatternMatcherResult& res) const;
126 
127 private:
128  std::string mapItem( const analyzer::PatternMatcherResultItem& res) const;
129 
130 private:
131  ErrorBufferInterface* m_errorhnd;
132  struct Impl;
133  Impl* m_impl;
134 };
135 
136 }//namespace
137 #endif
138 
const char * value
pointer to value (not 0-terminated) assigned to the chunk in case of a constant chunk ...
Definition: pattern_resultformat.hpp:84
PatternResultFormatContext(ErrorBufferInterface *errorhnd_)
Constructor.
const char * map(const PatternResultFormat *fmt, const analyzer::PatternMatcherResultItem *items, std::size_t nofItems)
Map a result to a string.
int start_pos
start position in case of a chunk referencing content
Definition: pattern_resultformat.hpp:87
struct PatternResultFormat PatternResultFormat
Result format representation (hidden implementation)
Definition: pattern_resultformat.hpp:24
virtual ~PatternResultFormatVariableMap()
Definition: pattern_resultformat.hpp:55
Single chunk of a result format for iterating ans build the pattern match result. ...
Definition: pattern_resultformat.hpp:82
int end_pos
end position in case of a chunk referencing content
Definition: pattern_resultformat.hpp:89
Structure desribing a result of a token pattern matcher.
PatternResultFormatTable(const PatternResultFormatVariableMap *variableMap_, ErrorBufferInterface *errorhnd_)
Context for mapping result format strings (allocator,maps,etc.)
Definition: pattern_resultformat.hpp:27
Interface to map variables to a pointer to string.
Definition: pattern_resultformat.hpp:52
virtual const char * getVariable(const std::string &name) const =0
const PatternResultFormat * createResultFormat(const char *src)
Create a format string representation out of its source.
static bool parseNext(PatternResultFormatChunk &result, char const *&src, ErrorBufferInterface *errorhnd)
\ brief Parse the next chunk in a mapped pattern match result value
~PatternResultFormatMap()
Destructor.
std::size_t valuesize
size of value in bytes
Definition: pattern_resultformat.hpp:85
Result item structure of a pattern match result.
Definition: patternMatcherResultItem.hpp:19
Structure desribing a result of a token pattern matcher.
Definition: patternMatcherResult.hpp:21
std::string map(const analyzer::PatternMatcherResult &res) const
Map a result to a string in a format to be decoded with PatternResultFormatChunk::parseNext.
int start_seg
start segment in case of a chunk referencing content
Definition: pattern_resultformat.hpp:86
int end_seg
end segment in case of a chunk referencing content
Definition: pattern_resultformat.hpp:88
Result format for the output of pattern match results with names of members as variables in curly bra...
Definition: pattern_resultformat.hpp:96
Parser for result format strings.
Definition: pattern_resultformat.hpp:61
PatternResultFormatMap(const char *src_, ErrorBufferInterface *errorhnd_)
Constructor.