File: GrcMasterTable.h

package info (click to toggle)
grcompiler 4.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,076 kB
  • ctags: 5,163
  • sloc: cpp: 45,565; sh: 4,451; ansic: 4,377; makefile: 185; xml: 175; perl: 127
file content (194 lines) | stat: -rw-r--r-- 5,492 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 1999, 2001 SIL International. All rights reserved.

Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.

File: GrcMasterTable.h
Responsibility: Sharon Correll
Last reviewed: Not yet.

Description:
    Classes to implement master tables used by the post-parser.
-------------------------------------------------------------------------------*//*:End Ignore*/
#ifdef _MSC_VER
#pragma once
#endif
#ifndef MASTERTBL_INCLUDED
#define MASTERTBL_INCLUDED

class GdlFeatureDefn;
class GdlGlyphClassDefn;
class GdlNameDefn;

/*----------------------------------------------------------------------------------------------
Class: GdlAssignment
Description: An expression, the statement number in which that expression was assigned,
	and the current values of relevant directives.
	This class, used by the master tables, is responsible for deleting the expression.
Hungarian: asgn
----------------------------------------------------------------------------------------------*/
class GdlAssignment : public GrcAssignment
{
	friend class GrcMasterValueList;
	friend class GrcMasterTable;

public:
	//	Constructors & destructor:
	GdlAssignment()
		:	GrcAssignment()
	{
	}

	GdlAssignment(GdlExpression * pexp, int nPR, int munitPR, bool fOverride, GrpLineAndFile const& lnf)
		:	GrcAssignment(pexp, nPR, munitPR, fOverride, lnf)
	{
	}

	~GdlAssignment()
	{
		if (m_pexp)
			delete m_pexp;
	}
	virtual void Set(GdlExpression * pexp, int nPR, int mPrUnits, bool fOverride,
		GrpLineAndFile const& lnf)
	{
		if (m_pexp)
			delete m_pexp;
		GrcAssignment::Set(pexp, nPR, mPrUnits, fOverride, lnf);
	}
};


/*----------------------------------------------------------------------------------------------
Class: GrcMasterValueList
Description: A list of values for a single entry in the master table; for instance, a list of
	glyph attributes for a class, or a list of feature information for a feature. The keys
	are Symbols of glyph attributes or feature fields; the values are assignment statements.
	Used only by the post-parser.
Hungarian: mvl
----------------------------------------------------------------------------------------------*/

class GrcMasterValueList	// hungarian: mvl
{
	friend class GrcMasterTable;

	typedef std::pair<Symbol, GdlAssignment*> ValuePair;
	typedef std::map<Symbol, GdlAssignment*> ValueMap; // hungarian: valmap

public:
	//	Constructor
	GrcMasterValueList()
	{
	}

	//	Destructor:
	~GrcMasterValueList()
	{
		//	Once the list has been processed, the assignment items might be deleted
		//	as part of the class definition, or whatever, so don't do it here.
		for (ValueMap::iterator it = m_valmapEntries.begin();
			it != m_valmapEntries.end();
			++it)
		{
			delete it->second; // GetValue();
		}
	}

	void AddItem(Symbol psym, GdlExpression * pexpValue,
		int nPR, int munitPR, bool fOverride, GrpLineAndFile const& lnf,
		std::string staDescription);

	//	Iterators:
	ValueMap::iterator EntriesBegin()
	{
		return m_valmapEntries.begin();
	}
	ValueMap::iterator EntriesEnd()
	{
		return m_valmapEntries.end();
	}

	//	Post-parser:
protected:
	void SetupFeatures(GdlFeatureDefn * pfeat);
	void SetupGlyphAttrs(GdlGlyphClassDefn * pglfc);
public:
	void SetupNameDefns(NameDefnMap & hmNameMap);

protected:
	//	instance variables:
//	SymbolType	m_symt	// ?????
	ValueMap	m_valmapEntries;
};


/*----------------------------------------------------------------------------------------------
Class: GrcMasterTable
Description: There will be two instances of this table: one to hold all the glyph attribute
	settings for all the classes, and one to hold all the feature definitions.

	For the glyph attribute table, the keys are class name Symbols; the values are
	GrMasterValueLists containing the attribute-setting statements for the class.

	For the feature table, the keys are feature name Symbols; the values are GrMasterValueLists
	containing the assignments for the feature.
Hungarian: mtb
----------------------------------------------------------------------------------------------*/

class GrcMasterTable
{
	friend class GrcMasterValueList;

	typedef std::pair<Symbol, GrcMasterValueList*> ValueListPair;
	typedef std::map<Symbol, GrcMasterValueList*> ValueListMap;	// hungarian: vlistmap

public:
	//	Destructor:
	~GrcMasterTable()
	{
		for (ValueListMap::iterator it = EntriesBegin();
			it != EntriesEnd();
			++it)
		{
			delete it->second;
			//delete it.GetValue();
		}
	}

	void AddItem(Symbol psym, GdlExpression * pexpValue,
		int nPR, int munitPR, bool fOverride, GrpLineAndFile const& lnf,
		std::string staDescription);

	GrcMasterValueList * ValueListFor(Symbol psym);
	GdlExpression * ItemValue(GrcStructName* psymClassOrFeat, GrcStructName* psymField);

	//	Find the feature corresponding to the standard styles. If it is there,
	//	store its settings in the master style list (clearing anything that does
	//	not belong).
	bool RecordStdStyles(GrcStructName * pxnsFeat);

	//	Iterators:
	ValueListMap::iterator EntriesBegin()
	{
		return m_vlistmapEntries.begin();
	}
	ValueListMap::iterator EntriesEnd()
	{
		return m_vlistmapEntries.end();
	}

public:
	//	Post-parser:
	void SetupFeatures();
	void SetupGlyphAttrs();

	//	Pre-compiler:

protected:
	//	instance variables:
	ValueListMap m_vlistmapEntries;
};


#endif // MASTERTBL_INCLUDED