Link with C++ linker
[oweals/cde.git] / cde / programs / nsgmls / ElementType.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: ElementType.C /main/1 1996/07/29 16:49:35 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifdef __GNUG__
28 #pragma implementation
29 #endif
30 #include "splib.h"
31 #include "ElementType.h"
32 #include "ContentToken.h"
33 #include "macros.h"
34
35 #ifdef SP_NAMESPACE
36 namespace SP_NAMESPACE {
37 #endif
38
39 ElementType::ElementType(const StringC &name, size_t index)
40 : Named(name), index_(index), map_(0), defIndex_(0)
41 {
42 }
43
44 ElementDefinition::ElementDefinition(const Location &location,
45                                      size_t index,
46                                      unsigned char omitFlags,
47                                      DeclaredContent declaredContent)
48 : location_(location),
49   index_(index),
50   omitFlags_(omitFlags),
51   declaredContent_(declaredContent)
52 {
53   computeMode();
54 }
55
56 ElementDefinition::ElementDefinition(const Location &location,
57                                      size_t index,
58                                      unsigned char omitFlags,
59                                      DeclaredContent declaredContent,
60                                      Owner<CompiledModelGroup> &modelGroup)
61 : location_(location),
62   index_(index),
63   omitFlags_(omitFlags),
64   declaredContent_(declaredContent),
65   modelGroup_(modelGroup.extract())
66 {
67   computeMode();
68 }
69
70 void ElementDefinition::computeMode()
71 {
72   switch (declaredContent_) {
73   case modelGroup:
74     if (!modelGroup_->containsPcdata()) {
75       netMode_ = econnetMode;
76       mode_ = econMode;
77       break;
78     }
79     // fall through
80   case any:
81     netMode_ = mconnetMode;
82     mode_ = mconMode;
83     break;
84   case cdata:
85     netMode_ = cconnetMode;
86     mode_ = cconMode;
87     break;
88   case rcdata:
89     netMode_ = rcconnetMode;
90     mode_ = rcconMode;
91     break;
92   case empty:
93     break;
94   default:
95     CANNOT_HAPPEN();
96   }
97 }
98
99 void ElementType::swap(ElementType &to)
100 {
101   Named::swap(to);
102   {
103     size_t tem = to.index_;
104     to.index_ = index_;
105     index_ = tem;
106   }
107   {
108     size_t tem = to.defIndex_;
109     to.defIndex_ = defIndex_;
110     defIndex_ = tem;
111   }
112   def_.swap(to.def_);
113   {
114     const ShortReferenceMap *tem = to.map_;
115     to.map_ = map_;
116     map_ = tem;
117   }
118 }
119
120 RankStem::RankStem(const StringC &name, size_t index)
121 : Named(name), index_(index)
122 {
123 }
124
125 void RankStem::addDefinition(const ConstPtr<ElementDefinition> &p)
126 {
127   def_.push_back(p);
128 }
129
130
131 #ifdef SP_NAMESPACE
132 }
133 #endif