secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/validators/schema/NamespaceScope.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: NamespaceScope.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 #if !defined(NAMESPACESCOPE_HPP)
       
    39 #define NAMESPACESCOPE_HPP
       
    40 
       
    41 #include <xercesc/util/StringPool.hpp>
       
    42 
       
    43 XERCES_CPP_NAMESPACE_BEGIN
       
    44 
       
    45 //
       
    46 // NamespaceScope provides a data structure for mapping namespace prefixes
       
    47 // to their URI's. The mapping accurately reflects the scoping of namespaces
       
    48 // at a particular instant in time.
       
    49 //
       
    50 
       
    51 class VALIDATORS_EXPORT NamespaceScope : public XMemory
       
    52 {
       
    53 public :
       
    54     // -----------------------------------------------------------------------
       
    55     //  Class specific data types
       
    56     //
       
    57     //  These really should be private, but some of the compilers we have to
       
    58     //  support are too dumb to deal with that.
       
    59     //
       
    60     //  PrefMapElem
       
    61     //      fURIId is the id of the URI from the validator's URI map. The
       
    62     //      fPrefId is the id of the prefix from our own prefix pool. The
       
    63     //      namespace stack consists of these elements.
       
    64     //
       
    65     //  StackElem
       
    66     //      The fMapCapacity is how large fMap has grown so far. fMapCount
       
    67     //      is how many of them are valid right now.
       
    68     // -----------------------------------------------------------------------
       
    69     struct PrefMapElem : public XMemory
       
    70     {
       
    71         unsigned int        fPrefId;
       
    72         unsigned int        fURIId;
       
    73     };
       
    74 
       
    75     struct StackElem : public XMemory
       
    76     {
       
    77         PrefMapElem*        fMap;
       
    78         unsigned int        fMapCapacity;
       
    79         unsigned int        fMapCount;
       
    80     };
       
    81 
       
    82 
       
    83     // -----------------------------------------------------------------------
       
    84     //  Constructors and Destructor
       
    85     // -----------------------------------------------------------------------
       
    86     NamespaceScope(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
       
    87     ~NamespaceScope();
       
    88 
       
    89 
       
    90     // -----------------------------------------------------------------------
       
    91     //  Stack access
       
    92     // -----------------------------------------------------------------------
       
    93     unsigned int increaseDepth();
       
    94     unsigned int decreaseDepth();
       
    95 
       
    96     // -----------------------------------------------------------------------
       
    97     //  Prefix map methods
       
    98     // -----------------------------------------------------------------------
       
    99     void addPrefix(const XMLCh* const prefixToAdd,
       
   100                    const unsigned int uriId);
       
   101 
       
   102     unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap) const;
       
   103     unsigned int getNamespaceForPrefix(const XMLCh* const prefixToMap,
       
   104                                        const int depthLevel) const;
       
   105 
       
   106 
       
   107     // -----------------------------------------------------------------------
       
   108     //  Miscellaneous methods
       
   109     // -----------------------------------------------------------------------
       
   110     bool isEmpty() const;
       
   111     void reset(const unsigned int emptyId);
       
   112 
       
   113 
       
   114 private :
       
   115     // -----------------------------------------------------------------------
       
   116     //  Unimplemented constructors and operators
       
   117     // -----------------------------------------------------------------------
       
   118     NamespaceScope(const NamespaceScope&);
       
   119     NamespaceScope& operator=(const NamespaceScope&);
       
   120 
       
   121 
       
   122     // -----------------------------------------------------------------------
       
   123     //  Private helper methods
       
   124     // -----------------------------------------------------------------------
       
   125     void expandMap(StackElem* const toExpand);
       
   126     void expandStack();
       
   127 
       
   128 
       
   129     // -----------------------------------------------------------------------
       
   130     //  Data members
       
   131     //
       
   132     //  fEmptyNamespaceId
       
   133     //      This is the special URI id for the "" namespace, which is magic
       
   134     //      because of the xmlns="" operation.
       
   135     //
       
   136     //  fPrefixPool
       
   137     //      This is the prefix pool where prefixes are hashed and given unique
       
   138     //      ids. These ids are used to track prefixes in the element stack.
       
   139     //
       
   140     //  fStack
       
   141     //  fStackCapacity
       
   142     //  fStackTop
       
   143     //      This the stack array. Its an array of pointers to StackElem
       
   144     //      structures. The capacity is the current high water mark of the
       
   145     //      stack. The top is the current top of stack (i.e. the part of it
       
   146     //      being used.)
       
   147     // -----------------------------------------------------------------------
       
   148     unsigned int  fEmptyNamespaceId;
       
   149     unsigned int  fStackCapacity;
       
   150     unsigned int  fStackTop;
       
   151     XMLStringPool fPrefixPool;
       
   152     StackElem**   fStack;
       
   153     MemoryManager* fMemoryManager;
       
   154 };
       
   155 
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 //  NamespaceScope: Stack access
       
   159 // ---------------------------------------------------------------------------
       
   160 inline unsigned int
       
   161 NamespaceScope::getNamespaceForPrefix(const XMLCh* const prefixToMap) const {
       
   162 
       
   163     return getNamespaceForPrefix(prefixToMap, (int)(fStackTop - 1));
       
   164 }
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 //  NamespaceScope: Miscellaneous methods
       
   168 // ---------------------------------------------------------------------------
       
   169 inline bool NamespaceScope::isEmpty() const
       
   170 {
       
   171     return (fStackTop == 0);
       
   172 }
       
   173 
       
   174 XERCES_CPP_NAMESPACE_END
       
   175 
       
   176 #endif
       
   177 
       
   178 /**
       
   179   * End of file NameSpaceScope.hpp
       
   180   */
       
   181