2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Group.h /main/1 1996/07/29 16:52:34 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef Group_INCLUDED
28 #define Group_INCLUDED 1
34 #include "ContentToken.h"
36 #include "MessageArg.h"
42 namespace SP_NAMESPACE {
47 GroupToken() : type(invalid) { }
52 dataTagLiteral, // data tag (padding) template
60 StringC token; // name nameToken; with substitution
61 Owner<ModelGroup> model;
62 Owner<ContentToken> contentToken; // elementToken pcdata dataTagGroup
64 Vector<Text> textVector;
66 GroupToken(const GroupToken &); // undefined
67 void operator=(const GroupToken &); // undefined
70 class AllowedGroupTokens {
72 AllowedGroupTokens(GroupToken::Type,
73 GroupToken::Type = GroupToken::invalid,
74 GroupToken::Type = GroupToken::invalid,
75 GroupToken::Type = GroupToken::invalid);
76 Boolean groupToken(GroupToken::Type) const;
77 // modelGroup, dataTagTemplateGroup
78 GroupToken::Type group() const;
79 GroupToken::Type nameStart() const;
81 void allow(GroupToken::Type);
85 struct GroupConnector {
96 class AllowedGroupConnectors {
98 AllowedGroupConnectors(GroupConnector::Type);
99 AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type);
100 AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type,
101 GroupConnector::Type);
102 AllowedGroupConnectors(GroupConnector::Type, GroupConnector::Type,
103 GroupConnector::Type, GroupConnector::Type);
104 Boolean groupConnector(GroupConnector::Type) const;
106 void allow(GroupConnector::Type);
110 class AllowedGroupTokensMessageArg : public MessageArg {
112 AllowedGroupTokensMessageArg(const AllowedGroupTokens &allow,
113 const ConstPtr<Syntax> &syntax);
114 MessageArg *copy() const;
115 void append(MessageBuilder &) const;
117 AllowedGroupTokens allow_;
118 ConstPtr<Syntax> syntax_;
121 class AllowedGroupConnectorsMessageArg : public MessageArg {
123 AllowedGroupConnectorsMessageArg(const AllowedGroupConnectors &allow,
124 const ConstPtr<Syntax> &syntax);
125 MessageArg *copy() const;
126 void append(MessageBuilder &) const;
128 AllowedGroupConnectors allow_;
129 ConstPtr<Syntax> syntax_;
133 Boolean AllowedGroupTokens::groupToken(GroupToken::Type i) const
135 return ((1 << i) & flags_) != 0;
139 GroupToken::Type AllowedGroupTokens::group() const
141 if (groupToken(GroupToken::modelGroup))
142 return GroupToken::modelGroup;
143 else if (groupToken(GroupToken::dataTagTemplateGroup))
144 return GroupToken::dataTagTemplateGroup;
146 return GroupToken::invalid;
150 GroupToken::Type AllowedGroupTokens::nameStart() const
152 if (groupToken(GroupToken::elementToken))
153 return GroupToken::elementToken;
154 else if (groupToken(GroupToken::nameToken))
155 return GroupToken::nameToken;
156 else if (groupToken(GroupToken::name))
157 return GroupToken::name;
159 return GroupToken::invalid;
163 void AllowedGroupTokens::allow(GroupToken::Type t)
170 Boolean AllowedGroupConnectors::groupConnector(GroupConnector::Type c) const
172 return (flags_ & (1 << c)) != 0;
176 void AllowedGroupConnectors::allow(GroupConnector::Type c)
186 #endif /* not Group_INCLUDED */