LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
PropertyAccessor.cpp
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/***************************************************************************
7 * Copyright (C) 2004 by CEA LIST *
8 * *
9 ***************************************************************************/
10
11#include "PropertyAccessor.h"
12#include <iostream>
13
14using namespace std;
15
16namespace Lima
17{
18namespace Common
19{
20namespace PropertyCode
21{
22
24{
25 friend class PropertyAccessor;
26
34 PropertyAccessorPrivate(const std::string& name,
35 const LinguisticCode& mask,
36 const LinguisticCode& emptyNessMask);
37 ~PropertyAccessorPrivate() = default;
40
41 LinguisticCode m_mask;
42 LinguisticCode m_emptyNessMask;
43 std::string m_name;
44
45};
46
47PropertyAccessorPrivate::PropertyAccessorPrivate(
48 const std::string& name,
49 const LinguisticCode& mask,
50 const LinguisticCode& emptyNessMask) :
51 m_mask(mask),
52 m_emptyNessMask(emptyNessMask),
53 m_name(name)
54{
55}
56
57PropertyAccessorPrivate::PropertyAccessorPrivate(const PropertyAccessorPrivate& pap)
58{
59 m_mask = pap.m_mask;
60 m_emptyNessMask = pap.m_emptyNessMask;
61 m_name = pap.m_name;
62}
63
64PropertyAccessorPrivate& PropertyAccessorPrivate::operator=(const PropertyAccessorPrivate& pap)
65{
66 m_mask = pap.m_mask;
67 m_emptyNessMask = pap.m_emptyNessMask;
68 m_name = pap.m_name;
69 return *this;
70}
71
72
74 const std::string& name,
75 const LinguisticCode& mask,
76 const LinguisticCode& emptyNessMask) :
77 m_d(new PropertyAccessorPrivate(name, mask, emptyNessMask))
78{}
79
81{
82 delete m_d;
83 m_d = nullptr;
84}
85
87 m_d(new PropertyAccessorPrivate(pa.m_d->m_name, pa.m_d->m_mask, pa.m_d->m_emptyNessMask))
88{
89}
90
92{
93 m_d->m_mask = pa.m_d->m_mask;
94 m_d->m_emptyNessMask = pa.m_d->m_emptyNessMask;
95 m_d->m_name = pa.m_d->m_name;
96
97 return *this;
98}
99
100const std::string& PropertyAccessor::getPropertyName() const
101{
102 return m_d->m_name;
103}
104
106{
107#ifdef DEBUG_LP
109 LDEBUG << "PropertyAccessor::readValue" << code;
110 Q_ASSERT(m_d != nullptr);
111#endif
112 return code & m_d->m_mask;
113}
114
116 const LinguisticCode& value,
117 LinguisticCode& code) const
118{
119 Q_ASSERT(m_d != nullptr);
120 code = ( code & ( ~ m_d->m_mask ) ) | ( value & m_d->m_mask );
121}
122
124 const LinguisticCode& l2) const
125{
126 Q_ASSERT(m_d != nullptr);
127 return !(m_d->m_mask & (l1 ^ l2));
128}
129
131{
132 Q_ASSERT(m_d != nullptr);
133 return !(l & m_d->m_emptyNessMask);
134}
135
136} // PropertyCode
137} // Common
138} // Lima
#define LDEBUG
Definition LimaCommon.h:157
#define PROPERTYCODELOGINIT
Definition LimaCommon.h:213
Provide function to read write and check a property.
PropertyAccessor(const std::string &name, const LinguisticCode &mask, const LinguisticCode &emptyNessMask)
Constructor.
PropertyAccessor & operator=(const PropertyAccessor &)
void writeValue(const LinguisticCode &value, LinguisticCode &code) const
write a property value in a coded int.
bool equal(const LinguisticCode &l1, const LinguisticCode &l2) const
check property equality for two linguisticCode
const std::string & getPropertyName() const
Get the property name.
LinguisticCode readValue(const LinguisticCode &code) const
read a property in a coded int.
bool empty(const LinguisticCode &l) const
Test if the given code has property data.
NAUTITIA.
STL namespace.