LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
SingleConcatenatedEntry.cpp
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// NAUTITIA
7//
8// jys 1-OCT-2002
9//
10// SingleConcatenatedEntry is the way to access dictionary Concatenated word infos datas.
11// SingleConcatenatedEntry manages recurent calls to lists of linguistic infos.
12// Dictionaries in memory are specified in NA2002.r2128 JYS
13// Dictionaries iterators are specified in NA2002.r2129 JYS
14// <Len10><String>
15// <Len1><lingInfo>
16// ...
17
19
21#include <wchar.h>
22
23using namespace Lima::Common::Misc;
24
25namespace Lima {
26namespace LinguisticProcessing {
27namespace Dictionary {
28
29// Creates SingleConcatenatedEntry
32m_stringStartAddr(NULL),
33m_startAddr(NULL),
34m_dictionaryEntry(NULL) {
35}
36
37// copy constructor. Copies the specified SingleConcatenatedEntry
38// into self. Internal iteration pointers of self are reset
41m_stringStartAddr(concatenated.m_stringStartAddr),
42m_startAddr(concatenated.m_startAddr),
43m_dictionaryEntry(NULL) {
44 reset();
45}
46
48 unsigned char *stringStartAddr) :
50m_stringStartAddr(stringStartAddr),
51m_startAddr(startAddr),
52m_dictionaryEntry(NULL) {
53 reset();
54}
55
56// Destroys SingleConcatenatedEntry
59
60// Assignment operator. Copies the specified SingleConcatenatedEntry
61// into self. Returns a reference to self.
62// After assignment, internal iteration pointers of self are reset
64 const SingleConcatenatedEntry& single) {
65 m_stringStartAddr = single.m_stringStartAddr;
66 m_startAddr = single.m_startAddr;
67 reset();
68 return *this;
69}
70
71// Resets iteration pointers
73 if (m_startAddr != NULL) {
74 unsigned char *ptr = m_startAddr;
75 getEncodedNumber(ptr); // Skip <component>
76 m_dictionaryEntry = ptr;
77 }
78 else
79 m_dictionaryEntry = NULL;
80 return *this;
81}
82
83// Returns true if self is empty
85 return (m_startAddr == NULL);
86}
87
88// Returns component string
89// If self is empty, EmptyEntryException is raised
91 if (m_startAddr == NULL) throw EmptyEntryException();
92 return getUtf8StringNoMove(m_stringStartAddr + getEncodedNumberNoMove(m_startAddr)); //component
93}
94
95// Returns dictionary entry address attached to the component, if exists
96// If there is no dictionary entry, NULL is returned
97// (to solve recursivity datas definition)
99 if (m_startAddr == NULL) throw EmptyEntryException();
100 return m_dictionaryEntry;
101}
102
103} // closing namespace Dictionary
104} // closing namespace LinguisticProcessing
105} // closing namespace Lima
uint64_t getEncodedNumber(unsigned char *&ptr) const
Lima::LimaString getUtf8StringNoMove(unsigned char *ptr) const
uint64_t getEncodedNumberNoMove(unsigned char *ptr) const
SingleConcatenatedEntry & operator=(const SingleConcatenatedEntry &)
NAUTITIA.
QString LimaString
Definition LimaString.h:33