123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $XConsortium: Expression.h /main/4 1996/08/21 15:50:17 drk $ */
- #ifndef _Expression_h
- #define _Expression_h
- /* **************************************************************
- Defines the tree for evaluating expressions given as feature values
- in the Style Sheet
- * ************************************************************** */
- #include "SymTab.h"
- #ifndef CDE_NEXT
- typedef dlist_array<Symbol> f_items_t;
- #else
- #include "dti_cc/cc_povec.h"
- typedef dlist_array<Symbol> f_items_t;
- #endif
- class FeatureValue;
- class TermNode;
- // /////////////////////////////////////////////////////////////////////////
- // class Expression
- //
- // holds root of expression tree
- // /////////////////////////////////////////////////////////////////////////
- class Expression
- {
- public:
- Expression(TermNode *root);
- Expression(const Expression&);
- virtual ~Expression();
- virtual FeatureValue *evaluate() const;
- ostream &print(ostream &) const;
- private:
- TermNode* f_root;
- };
- class TermNode
- {
- public:
- virtual ~TermNode();
- virtual FeatureValue *evaluate() const = 0;
- virtual ostream &print(ostream &) const = 0;
- virtual TermNode *clone() const = 0;
- };
- class VariableNode: public TermNode
- {
- // for single name variables eg: "DEFAULT_FONT"
- public:
- VariableNode(const Symbol& name);
- virtual FeatureValue *evaluate() const;
- ostream &print(ostream &) const;
- virtual TermNode *clone() const;
- private:
- Symbol f_name;
- };
- class CompositeVariableNode : public TermNode
- {
- // for feature path variables (font.size)
- // eg: font: { size: font.size }
- public:
- CompositeVariableNode();
- CompositeVariableNode(size_t capac); /* if we know how many items to expect */
- ~CompositeVariableNode();
- virtual FeatureValue *evaluate() const ;
- ostream &print(ostream &) const;
- virtual TermNode *clone() const;
- void prependItem(const Symbol& item);
- void appendItem(const Symbol& item);
- const Symbol* convertableToVariable();
- private:
- //dlist_array<Symbol> f_items;
- f_items_t f_items;
- };
- class BinaryOperatorNode: public TermNode
- {
- public:
- enum operatorType { PLUS, MINUS, TIMES, DIVIDE };
- BinaryOperatorNode(operatorType, TermNode* left, TermNode* right);
- ~BinaryOperatorNode();
- virtual TermNode *clone() const;
- virtual FeatureValue *evaluate() const;
- ostream &print(ostream &) const;
- private:
- operatorType f_operator ;
- TermNode *f_left;
- TermNode *f_right;
- };
- class SgmlAttributeNode: public TermNode
- {
- public:
- SgmlAttributeNode(const Symbol& name);
- SgmlAttributeNode();
- virtual FeatureValue *evaluate() const ;
- ostream &print(ostream &) const;
- virtual TermNode *clone() const;
- private:
- Symbol f_name;
- };
- class ConstantNode: public TermNode
- {
- public:
- ConstantNode(FeatureValue*);
- ~ConstantNode();
- virtual FeatureValue *evaluate() const;
- ostream &print(ostream &) const;
- virtual TermNode *clone() const;
- private:
- FeatureValue *f_value;
- };
- ostream &operator <<(ostream &, const Expression &);
- ostream &operator <<(ostream &, const TermNode &);
- #endif /* _Expression_h */
- /* DO NOT ADD ANY LINES AFTER THIS #endif */
|