http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XMLUri.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 2001 The Apache Software Foundation.  All rights
00005  * reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in
00016  *    the documentation and/or other materials provided with the
00017  *    distribution.
00018  *
00019  * 3. The end-user documentation included with the redistribution,
00020  *    if any, must include the following acknowledgment:
00021  *       "This product includes software developed by the
00022  *        Apache Software Foundation (http://www.apache.org/)."
00023  *    Alternately, this acknowledgment may appear in the software itself,
00024  *    if and wherever such third-party acknowledgments normally appear.
00025  *
00026  * 4. The names "Xerces" and "Apache Software Foundation" must
00027  *    not be used to endorse or promote products derived from this
00028  *    software without prior written permission. For written
00029  *    permission, please contact apache\@apache.org.
00030  *
00031  * 5. Products derived from this software may not be called "Apache",
00032  *    nor may "Apache" appear in their name, without prior written
00033  *    permission of the Apache Software Foundation.
00034  *
00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  * ====================================================================
00048  *
00049  * This software consists of voluntary contributions made by many
00050  * individuals on behalf of the Apache Software Foundation, and was
00051  * originally based on software copyright (c) 1999, International
00052  * Business Machines, Inc., http://www.ibm.com .  For more information
00053  * on the Apache Software Foundation, please see
00054  * <http://www.apache.org/>.
00055  */
00056 
00057 /*
00058  * $Id: XMLUri.hpp,v 1.7 2003/01/06 19:43:18 tng Exp $
00059  * $Log: XMLUri.hpp,v $
00060  * Revision 1.7  2003/01/06 19:43:18  tng
00061  * New feature StandardUriConformant to force strict standard uri conformance.
00062  *
00063  * Revision 1.6  2002/11/21 15:42:39  gareth
00064  * Implemented copy constructor and operator =. Patch by Jennifer Schachter.
00065  *
00066  * Revision 1.5  2002/11/04 15:22:05  tng
00067  * C++ Namespace Support.
00068  *
00069  * Revision 1.4  2002/09/23 18:41:00  tng
00070  * DOM L3: Support baseURI.   Add fURIText to XMLUri.   Added by Gareth Reakes and Thomas Ford.
00071  *
00072  * Revision 1.3  2002/08/23 20:45:24  tng
00073  * .Memory leak fix: XMLUri data not deleted if constructor failed.
00074  *
00075  * Revision 1.2  2002/02/20 18:17:02  tng
00076  * [Bug 5977] Warnings on generating apiDocs.
00077  *
00078  * Revision 1.1.1.1  2002/02/01 22:22:17  peiyongz
00079  * sane_include
00080  *
00081  * Revision 1.3  2001/08/29 19:03:03  peiyongz
00082  * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method
00083  *
00084  * Revision 1.2  2001/08/16 14:09:44  peiyongz
00085  * Removed unused ctors and methods
00086  *
00087  * Revision 1.1  2001/08/10 16:23:41  peiyongz
00088  * XMLUri: creation
00089  *
00090  *
00091  */
00092 
00093 #if !defined(XMLURI_HPP)
00094 #define XMLURI_HPP
00095 
00096 #include <xercesc/util/XercesDefs.hpp>
00097 #include <xercesc/util/XMLException.hpp>
00098 #include <xercesc/util/XMLUniDefs.hpp>
00099 #include <xercesc/util/XMLString.hpp>
00100 
00101 XERCES_CPP_NAMESPACE_BEGIN
00102 
00103 /*
00104  * This class is a direct port of Java's URI class, to distinguish
00105  * itself from the XMLURL, we use the name XMLUri instead of
00106  * XMLURI.
00107  *
00108  * TODO: how to relate XMLUri and XMLURL since URL is part of URI.
00109  *
00110  */
00111 
00112 class  XMLUri
00113 {
00114 public:
00115 
00116     // -----------------------------------------------------------------------
00117     //  Constructors and Destructor
00118     // -----------------------------------------------------------------------
00119 
00145     XMLUri(const XMLCh* const    uriSpec);
00146 
00159     XMLUri(const XMLUri* const     baseURI
00160          , const XMLCh* const      uriSpec);
00161 
00165     XMLUri(const XMLUri& toCopy);
00166     XMLUri& operator=(const XMLUri& toAssign);
00167 
00168     virtual ~XMLUri();
00169 
00170     // -----------------------------------------------------------------------
00171     //  Getter methods
00172     // -----------------------------------------------------------------------
00178     const XMLCh* getUriText() const;
00179 
00185      const XMLCh* getScheme() const;
00186 
00192      const XMLCh* getUserInfo() const;
00193 
00194 
00200      const XMLCh* getHost() const;
00201 
00207      int getPort() const;
00208 
00215      const XMLCh* getPath() const;
00216 
00224      const XMLCh* getQueryString() const;
00225 
00233      const XMLCh* getFragment() const;
00234 
00235     // -----------------------------------------------------------------------
00236     //  Setter methods
00237     // -----------------------------------------------------------------------
00238 
00246      void setScheme(const XMLCh* const newScheme);
00247 
00255      void setUserInfo(const XMLCh* const newUserInfo);
00256 
00264      void setHost(const XMLCh* const newHost);
00265 
00275      void setPort(int newPort);
00276 
00297      void setPath(const XMLCh* const newPath);
00298 
00307      void setQueryString(const XMLCh* const newQueryString);
00308 
00317      void setFragment(const XMLCh* const newFragment);
00318 
00319      // -----------------------------------------------------------------------
00320     //  Miscellaneous methods
00321     // -----------------------------------------------------------------------
00322 
00330     static bool isURIString(const XMLCh* const uric);
00331 
00332 
00333 private:
00334 
00335     static const XMLCh RESERVED_CHARACTERS[];
00336     static const XMLCh MARK_CHARACTERS[];
00337     static const XMLCh SCHEME_CHARACTERS[];
00338     static const XMLCh USERINFO_CHARACTERS[];
00339 
00340     //helper method for getUriText
00341     void buildFullText();
00342 
00343     // -----------------------------------------------------------------------
00344     //  Private helper methods
00345     // -----------------------------------------------------------------------
00346 
00352     static bool isReservedCharacter(const XMLCh theChar);
00353 
00359     static bool isUnreservedCharacter(const XMLCh theChar);
00360 
00368     static bool isConformantSchemeName(const XMLCh* const scheme);
00369 
00375     static void isConformantUserInfo(const XMLCh* const userInfo);
00390      static bool isWellFormedAddress(const XMLCh* const addr);
00391 
00399      bool isGenericURI();
00400 
00401     // -----------------------------------------------------------------------
00402     //  Miscellaneous methods
00403     // -----------------------------------------------------------------------
00404 
00410      void initialize(const XMLUri& toCopy);
00411 
00426      void initialize(const XMLUri* const baseURI
00427                    , const XMLCh*  const uriSpec);
00428 
00435      void initializeScheme(const XMLCh* const uriSpec);
00436 
00444      void initializeAuthority(const XMLCh* const uriSpec);
00445 
00452      void initializePath(const XMLCh* const uriSpec);
00453 
00458      void cleanUp();
00459 
00460     // -----------------------------------------------------------------------
00461     //  Data members
00462     //
00463     //  for all the data member, we own it,
00464     //  responsible for the creation and/or deletion for
00465     //  the memory allocated.
00466     //
00467     // -----------------------------------------------------------------------
00468 
00469     XMLCh*          fScheme;
00470     XMLCh*          fUserInfo;
00471     XMLCh*          fHost;
00472     int             fPort;
00473     XMLCh*          fPath;
00474     XMLCh*          fQueryString;
00475     XMLCh*          fFragment;
00476     XMLCh*          fURIText;
00477 
00478 };
00479 
00480 // ---------------------------------------------------------------------------
00481 //  XMLUri: Getter methods
00482 // ---------------------------------------------------------------------------
00483 inline const XMLCh* XMLUri::getScheme() const
00484 {
00485     return fScheme;
00486 }
00487 
00488 inline const XMLCh* XMLUri::getUserInfo() const
00489 {
00490     return fUserInfo;
00491 }
00492 
00493 inline const XMLCh* XMLUri::getHost() const
00494 {
00495     return fHost;
00496 }
00497 
00498 inline int XMLUri::getPort() const
00499 {
00500     return fPort;
00501 }
00502 
00503 inline const XMLCh* XMLUri::getPath() const
00504 {
00505     return fPath;
00506 }
00507 
00508 inline const XMLCh* XMLUri::getQueryString() const
00509 {
00510     return fQueryString;
00511 }
00512 
00513 inline const XMLCh* XMLUri::getFragment() const
00514 {
00515     return fFragment;
00516 }
00517 
00518 inline const XMLCh* XMLUri::getUriText() const
00519 {
00520     //
00521     //  Fault it in if not already. Since this is a const method and we
00522     //  can't use mutable members due the compilers we have to support,
00523     //  we have to cast off the constness.
00524     //
00525     if (!fURIText)
00526         ((XMLUri*)this)->buildFullText();
00527 
00528     return fURIText;
00529 }
00530 
00531 // ---------------------------------------------------------------------------
00532 //  XMLUri: Helper methods
00533 // ---------------------------------------------------------------------------
00534 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00535 {
00536     return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00537 }
00538 
00539 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00540 {
00541     return (XMLString::isAlphaNum(theChar) ||
00542             XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00543 }
00544 
00545 XERCES_CPP_NAMESPACE_END
00546 
00547 #endif


Copyright © 2000 The Apache Software Foundation. All Rights Reserved.