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

Qname.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 _QNAMEH
00022 #define _QNAMEH
00023 
00024 #include <string>
00025 #include <iostream>
00026 class Qname
00027 {
00028  public:
00029   Qname (const std::string & name);
00030   Qname (const Qname & qn);
00031   Qname ();
00032   std::string  getLocalName (void)const;
00033   std::string  getPrefix (void) const;
00034   std::string  getNamespace (void)const;
00035   void setNamespace (std::string uri);
00036   bool operator== (const Qname & qn)const;
00037   void operator= (const std::string & name);
00038   friend std::ostream & operator<<(std::ostream & os,const Qname& qn);
00039  private:
00040   void parse (const std::string & name);
00041   std::string namespaceUri, localname, prefix;
00042 };
00043 
00044 inline
00045 Qname::Qname (const std::string & name)
00046 {
00047   parse (name);
00048 }
00049 
00050 inline
00051 Qname::Qname (const Qname & qn)
00052 {
00053   localname = qn.localname;
00054   prefix = qn.prefix;
00055   namespaceUri = qn.namespaceUri;
00056 }
00057 
00058 inline
00059 Qname::Qname ()
00060 {
00061 }
00062 
00063 inline
00064 void 
00065 Qname::operator= (const std::string & name)
00066 {
00067   parse (name);
00068 }
00069 
00070 inline
00071 std::string
00072 Qname::getLocalName (void)const
00073 {
00074   return localname;
00075 }
00076 
00077 inline
00078 std::string
00079 Qname::getPrefix (void) const
00080 {
00081   return prefix;
00082 }
00083 
00084 inline
00085 std::string 
00086 Qname::getNamespace (void)const
00087 {
00088   return namespaceUri;
00089 }
00090 
00091 inline
00092 void
00093 Qname::setNamespace (std::string uri)
00094 {
00095   namespaceUri = uri;
00096 }
00097 
00098 inline
00099 bool 
00100 Qname::operator== (const Qname & qn)const
00101 {
00102   if (qn.getNamespace () == namespaceUri && qn.getLocalName () == localname)
00103     return true;
00104   else
00105     return false;
00106 }
00107 
00108 inline
00109 void
00110 Qname::parse (const std::string & name)
00111 {
00112   int cut = -1;
00113   if (name.empty ())
00114     return;
00115   cut = name.find (":");
00116   if (cut == -1 || cut == 0)
00117     localname = name;
00118 
00119   else
00120 
00121     {
00122       localname = name.substr (cut + 1);
00123       prefix = name.substr (0, cut);
00124     }
00125   cut = localname.find ("[]");
00126   if (cut > 0)
00127     localname = localname.substr (0, cut);
00128 }
00129 
00130 inline
00131 std::ostream & operator<<(std::ostream & os,const Qname& qn)
00132 {
00133   os<<qn.getPrefix()<<"{"<<qn.getNamespace()<<"}:"<<qn.getLocalName();
00134   return os;
00135 }
00136 #endif                                            /*  */

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