1 | // SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later |
---|---|
2 | // Copyright 2010, SIL International, All rights reserved. |
3 | |
4 | #pragma once |
5 | #include <cstring> |
6 | #include <cassert> |
7 | #include "inc/Main.h" |
8 | #include "inc/List.h" |
9 | |
10 | namespace graphite2 { |
11 | |
12 | class FeatureRef; |
13 | class FeatureMap; |
14 | |
15 | class FeatureVal : public Vector<uint32> |
16 | { |
17 | public: |
18 | FeatureVal() : m_pMap(0) { } |
19 | FeatureVal(int num, const FeatureMap & pMap) : Vector<uint32>(num), m_pMap(&pMap) {} |
20 | FeatureVal(const FeatureVal & rhs) : Vector<uint32>(rhs), m_pMap(rhs.m_pMap) {} |
21 | |
22 | FeatureVal & operator = (const FeatureVal & rhs) { Vector<uint32>::operator = (rhs); m_pMap = rhs.m_pMap; return *this; } |
23 | |
24 | bool operator ==(const FeatureVal & b) const |
25 | { |
26 | size_t n = size(); |
27 | if (n != b.size()) return false; |
28 | |
29 | for(const_iterator l = begin(), r = b.begin(); n && *l == *r; --n, ++l, ++r); |
30 | |
31 | return n == 0; |
32 | } |
33 | |
34 | CLASS_NEW_DELETE |
35 | private: |
36 | friend class FeatureRef; //so that FeatureRefs can manipulate m_vec directly |
37 | const FeatureMap* m_pMap; |
38 | }; |
39 | |
40 | typedef FeatureVal Features; |
41 | |
42 | } // namespace graphite2 |
43 | |
44 | |
45 | struct gr_feature_val : public graphite2::FeatureVal {}; |
46 |