Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Element.h

Go to the documentation of this file.
00001 /* 
00002  * wsdlpull - A C++ parser  for WSDL  (Web services description language)
00003  * Copyright (C) 2005-2007 Vivek Krishna
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  *
00020  */
00021 #ifndef _ELEMENTH
00022 #define _ELEMENTH
00023 
00024 #include <string>
00025 #include "schemaparser/Constraint.h"
00026 
00027 namespace Schema {
00028 #define UNBOUNDED INT_MAX
00029 class Element
00030 {
00031  public:
00032   Element(const std::string & name, 
00033           int type_id, 
00034           int minimum = 1,
00035           int maximum = 1,
00036           bool qualified = false, 
00037           std::string def = "", 
00038           std::string fixed ="");
00039   
00040   Element(void);
00041   void setType(int id);
00042   std::string getName() const;
00043   int getType() const;
00044   int getMax() const ;
00045   int getMin() const;
00046   std::string & defaultVal();
00047   std::string & fixedVal();
00048   bool isQualified() const;
00049   Element& operator = (const Element & e);
00050   void setMin(int m);
00051   void setMax(int m);
00052   //add a key/keyref/unique constraint
00053   void addConstraint(Constraint* c);
00054   Constraint* constraint();
00055   int nOccurrences;
00056 
00057  private:
00058   std::string elemName;
00059   std::string dval, fval;
00060   int elemType;
00061   bool bQualified;
00062   int minOccurs, maxOccurs;
00063   Constraint* cstr;
00064 };
00065 
00066 #ifdef LOGGING
00067 std::ostream & operator << (std::ostream & stream, Element & e);
00068 #endif
00069 
00070 inline
00071 Element::Element(const std::string & name, 
00072                  int type_id, 
00073                  int minimum,
00074                  int maximum,
00075                  bool qualified, 
00076                  std::string def , 
00077                  std::string fixed)
00078   : nOccurrences(0),
00079      elemName(name),
00080      dval(def),
00081      fval(fixed),
00082      elemType(type_id),
00083      bQualified(qualified),
00084      minOccurs(minimum),
00085      maxOccurs(maximum),
00086      cstr(0)
00087 {
00088 }
00089 
00090 inline
00091 Element::Element(void)
00092   :nOccurrences(0),
00093      elemType(0),
00094      bQualified (false),
00095      minOccurs (1),
00096      maxOccurs (1),
00097      cstr(0)
00098 {
00099 }
00100 inline
00101 void
00102 Element::setType(int id)
00103 {
00104   elemType = id;
00105 }
00106 
00107 inline
00108 std::string
00109 Element::getName() const
00110 {
00111   return elemName;
00112 }
00113 
00114 inline
00115 int
00116 Element::getType() const
00117 {
00118   return elemType;
00119 }
00120 
00121 inline
00122 int
00123 Element::getMax() const
00124 {
00125   return maxOccurs;
00126 }
00127 inline
00128 int
00129 Element::getMin() const
00130 {
00131   return minOccurs;
00132 }
00133 
00134 inline
00135 std::string &
00136 Element::defaultVal()
00137 {
00138   return dval;
00139 }
00140 
00141 inline
00142 std::string &
00143 Element::fixedVal()
00144 {
00145   return fval;
00146 }
00147 
00148 inline
00149 bool
00150 Element::isQualified() const
00151 {
00152   return bQualified;
00153 }
00154 
00155 inline
00156 Element& 
00157 Element::operator = (const Element & e)
00158 {
00159   elemName = e.elemName;
00160   elemType = e.elemType;
00161   bQualified = e.isQualified();
00162   dval = e.dval;
00163   fval = e.fval;
00164   cstr = e.cstr;
00165   return *this;
00166   //minimum and maximum are not copied because they are specific to the
00167   //occurrence
00168 }
00169 inline
00170 void
00171 Element::setMin(int m)
00172 {
00173   minOccurs=m;
00174 }
00175 
00176 inline
00177 void 
00178 Element::setMax(int m)
00179 {
00180   maxOccurs=m;
00181 }
00182 
00183 inline
00184 void
00185 Element::addConstraint(Constraint* c)
00186 {
00187   cstr=c;
00188 }
00189 
00190 inline
00191 Constraint*
00192 Element::constraint()
00193 {
00194   return cstr;
00195 }
00196 }
00197 #endif                                            /*  */

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1