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 "xmlpull/wsdlpull_export.h"
00026 #include "schemaparser/Constraint.h"
00027 
00028 namespace Schema {
00029 #define UNBOUNDED INT_MAX
00030 class WSDLPULL_EXPORT Element
00031 {
00032  public:
00033   Element(const std::string & name, 
00034       const std::string & typeNs,
00035           int type_id, 
00036           int minimum = 1,
00037           int maximum = 1,
00038           bool qualified = false, 
00039           std::string def = "", 
00040           std::string fixed ="");
00041   
00042   Element(void);
00043   void setType(int id);
00044   std::string getName() const;
00045     void setTypeNamespace(std::string ns);
00046     std::string getTypeNamespace() const;
00047   int getType() const;
00048   int getMax() const ;
00049   int getMin() const;
00050   std::string & defaultVal();
00051   std::string & fixedVal();
00052   bool isQualified() const;
00053   Element& operator = (const Element & e);
00054   void setMin(int m);
00055   void setMax(int m);
00056   //add a key/keyref/unique constraint
00057   void addConstraint(Constraint* c);
00058   Constraint* constraint();
00059   int nOccurrences;
00060 
00061  private:
00062   std::string elemName;
00063   std::string dval, fval;
00064   int elemType;
00065   bool bQualified;
00066   int minOccurs, maxOccurs;
00067   std::string elemTypeNamespace;
00068   Constraint* cstr;
00069 };
00070 
00071 #ifdef LOGGING
00072 std::ostream & operator << (std::ostream & stream, Element & e);
00073 #endif
00074 
00075 inline
00076 Element::Element(const std::string & name, 
00077     const std::string & typeNs, 
00078                  int type_id, 
00079                  int minimum,
00080                  int maximum,
00081                  bool qualified, 
00082                  std::string def , 
00083                  std::string fixed)
00084   : nOccurrences(0),
00085      elemName(name),
00086      dval(def),
00087      fval(fixed),
00088      elemType(type_id),
00089      bQualified(qualified),
00090      minOccurs(minimum),
00091      maxOccurs(maximum),
00092     elemTypeNamespace(typeNs),
00093      cstr(0)
00094 {
00095 }
00096 
00097 inline
00098 Element::Element(void)
00099   :nOccurrences(0),
00100      elemType(0),
00101      bQualified (false),
00102      minOccurs (1),
00103      maxOccurs (1),
00104      cstr(0)
00105 {
00106 }
00107 inline
00108 void
00109 Element::setType(int id)
00110 {
00111   elemType = id;
00112 }
00113 
00114 inline
00115 std::string
00116 Element::getName() const
00117 {
00118   return elemName;
00119 }
00120 
00121 inline
00122 void
00123 Element::setTypeNamespace(std::string ns)
00124 {
00125   elemTypeNamespace = ns;
00126 }
00127 
00128 inline
00129 std::string 
00130 Element::getTypeNamespace() const
00131 {
00132   return elemTypeNamespace;
00133 }
00134 
00135 inline
00136 int
00137 Element::getType() const
00138 {
00139   return elemType;
00140 }
00141 
00142 inline
00143 int
00144 Element::getMax() const
00145 {
00146   return maxOccurs;
00147 }
00148 inline
00149 int
00150 Element::getMin() const
00151 {
00152   return minOccurs;
00153 }
00154 
00155 inline
00156 std::string &
00157 Element::defaultVal()
00158 {
00159   return dval;
00160 }
00161 
00162 inline
00163 std::string &
00164 Element::fixedVal()
00165 {
00166   return fval;
00167 }
00168 
00169 inline
00170 bool
00171 Element::isQualified() const
00172 {
00173   return bQualified;
00174 }
00175 
00176 inline
00177 Element& 
00178 Element::operator = (const Element & e)
00179 {
00180   elemName = e.elemName;
00181   elemType = e.elemType;
00182   bQualified = e.isQualified();
00183   dval = e.dval;
00184   fval = e.fval;
00185     elemTypeNamespace = e.elemTypeNamespace;
00186   cstr = e.cstr;
00187   return *this;
00188   //minimum and maximum are not copied because they are specific to the
00189   //occurrence
00190 }
00191 inline
00192 void
00193 Element::setMin(int m)
00194 {
00195   minOccurs=m;
00196 }
00197 
00198 inline
00199 void 
00200 Element::setMax(int m)
00201 {
00202   maxOccurs=m;
00203 }
00204 
00205 inline
00206 void
00207 Element::addConstraint(Constraint* c)
00208 {
00209   cstr=c;
00210 }
00211 
00212 inline
00213 Constraint*
00214 Element::constraint()
00215 {
00216   return cstr;
00217 }
00218 }
00219 #endif                                            /*  */

Generated on Wed Apr 12 18:51:55 2006 for wsdlpull by  doxygen 1.3.9.1