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 #define UNBOUNDED 1000
00028 class Element
00029 {
00030  public:
00031   Element(const std::string & name, 
00032           int type_id, 
00033           int min = 1, 
00034           int max = 1, 
00035           bool qualified = false, 
00036           std::string def = "", 
00037           std::string fixed ="");
00038   
00039   Element(void);
00040 
00041   void setType(int id);
00042   std::string getName() const;
00043   int getType() const;
00044   int max() const ;
00045   int min() const;
00046   std::string & defaultVal();
00047   std::string & fixedVal();
00048   bool isQualified() const;
00049   Element& operator = (const Element & e);
00050   void min(int m);
00051   void max(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 ostream & operator << (ostream & stream, Element & e);
00068 #endif
00069 
00070 inline
00071 Element::Element(const std::string & name, 
00072                  int type_id, 
00073                  int min , 
00074                  int max , 
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(min),
00085      maxOccurs(max),
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 
00101 inline
00102 void
00103 Element::setType(int id)
00104 {
00105   elemType = id;
00106 }
00107 
00108 inline
00109 std::string
00110 Element::getName() const
00111 {
00112   return elemName;
00113 }
00114 
00115 inline
00116 int
00117 Element::getType() const
00118 {
00119   return elemType;
00120 }
00121 
00122 inline
00123 int
00124 Element::max() const 
00125 {
00126   return maxOccurs;
00127 }
00128 inline
00129 int
00130 Element::min() const
00131 {
00132   return minOccurs;
00133 }
00134 
00135 inline
00136 std::string &
00137 Element::defaultVal()
00138 {
00139   return dval;
00140 }
00141 
00142 inline
00143 std::string &
00144 Element::fixedVal()
00145 {
00146   return fval;
00147 }
00148 
00149 inline
00150 bool
00151 Element::isQualified() const
00152 {
00153   return bQualified;
00154 }
00155 
00156 inline
00157 Element& 
00158 Element::operator = (const Element & e)
00159 {
00160   elemName = e.elemName;
00161   elemType = e.elemType;
00162   bQualified = e.isQualified();
00163   dval = e.dval;
00164   fval = e.fval;
00165   return *this;
00166   //min and max are not copied because they are specific to the
00167   //occurrence
00168 }
00169 inline
00170 void
00171 Element::min(int m)
00172 {
00173   minOccurs=m;
00174 }
00175 
00176 inline
00177 void 
00178 Element::max(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 #endif                                            /*  */

Generated on Sun Oct 16 10:11:52 2005 for wsdlpull by  doxygen 1.3.9.1