strusAnalyzer  0.17
patternLexem.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_LEXEM_HPP_INCLUDED
11 #define _STRUS_ANALYZER_PATTERN_LEXEM_HPP_INCLUDED
12 #include "strus/analyzer/token.hpp"
14 #include <cstddef>
15 
16 namespace strus {
17 namespace analyzer {
18 
21  :public Token
22 {
23 public:
26  :Token(),m_id(0){}
28  PatternLexem( int id_, int ordpos_, const Position& origpos_, int origsize_)
29  :Token(ordpos_,origpos_,origsize_),m_id(id_){}
31 #if __cplusplus >= 201103L
32  PatternLexem( PatternLexem&& ) = default;
33  PatternLexem( const PatternLexem& ) = default;
34  PatternLexem& operator= ( PatternLexem&& ) = default;
35  PatternLexem& operator= ( const PatternLexem& ) = default;
36 #else
38  :Token(o),m_id(o.m_id){}
39 #endif
40  ~PatternLexem(){}
42 
44  int id() const {return m_id;}
45 
46  bool operator < (const PatternLexem& o) const
47  {
48  int cmp = Token::compare( o);
49  return (cmp == 0) ? m_id < o.m_id : cmp < 0;
50  }
51 
52 private:
53  int m_id;
54 };
55 
56 
57 }} //namespace
58 #endif
59 
~PatternLexem()
Destructor.
Definition: patternLexem.hpp:41
bool operator<(const PatternLexem &o) const
Definition: patternLexem.hpp:46
Structure describing a token with an id used for pattern matching.
Definition: patternLexem.hpp:20
Structure describing a token in the document by its start position and size.
PatternLexem(const PatternLexem &o)
Copy constructor.
Definition: patternLexem.hpp:37
int compare(const Token &o) const
Compare with another token.
Definition: token.hpp:75
PatternLexem()
Default constructor.
Definition: patternLexem.hpp:25
Structure describing a position in a document source by segment and offset.
int id() const
Internal identifier of the term.
Definition: patternLexem.hpp:44
PatternLexem(int id_, int ordpos_, const Position &origpos_, int origsize_)
Constructor.
Definition: patternLexem.hpp:28
Structure describing a position in a document source by segment and offset.
Definition: position.hpp:22
Structure describing a token in the document by its start and end position.
Definition: token.hpp:21