source: icXML/icXML-0.95/src/icxmlc/XMLGrammarResolver.hpp @ 3602

Last change on this file since 3602 was 3602, checked in by cameron, 5 years ago

Namespace bug fix for icXML-0.95

File size: 1.6 KB
Line 
1/*
2 *  Copyright © 2012 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icXML is a trademark of International Characters.
5 */
6
7/*
8 * @author Nigel Medforth, nigelm -at- interational-characters.com
9 * @version $Id: XMLGrammarResolver.hpp 388 2013-10-29 21:25:27Z nigelm $
10 *
11 */
12
13#ifndef XMLGRAMMARRESOLVER_HPP
14#define XMLGRAMMARRESOLVER_HPP
15
16
17#include <icxmlc/XMLConfig.hpp>
18#include <icxercesc/validators/common/Grammar.hpp>
19#include <icxmlc/Array.hpp>
20#include <icxmlc/XMLNamespaceResolver.hpp>
21
22XERCES_CPP_NAMESPACE_BEGIN
23
24class XMLGrammarResolver
25{
26        enum
27        {
28                kDefaultGrammarListSize = 16
29        };
30
31        public:
32
33        XMLGrammarResolver()
34                {
35                }
36
37                IDISA_ALWAYS_INLINE
38                Grammar * getGrammar(const unsigned int uriId) const;
39
40                IDISA_ALWAYS_INLINE
41                void setGrammar(const unsigned int uriId, Grammar * grammar);
42
43        private:
44
45                DynamicArray<Grammar*, kDefaultGrammarListSize> fList;
46};
47
48Grammar * XMLGrammarResolver::getGrammar(const unsigned int uriId) const
49{
50    DEBUG_GRAMMAR_MESSAGE("XMLGrammarResolver::getGrammar(" << uriId << ')')
51        if (likely(uriId < fList.capacity()))
52        {
53                return fList[uriId];
54        }
55        return NULL;
56}
57
58void XMLGrammarResolver::setGrammar(const unsigned int uriId, Grammar * grammar)
59{
60    DEBUG_GRAMMAR_MESSAGE("XMLGrammarResolver::setGrammar(" << uriId << ',' << grammar << ") cap=" << fList.capacity())
61        if (unlikely(uriId >= fList.capacity()))
62        {       
63        fList.resizeToFit(max<size_t>(uriId + 1, fList.capacity() * 2));
64        }
65        fList[uriId] = grammar;
66}
67
68XERCES_CPP_NAMESPACE_END
69
70#endif // XMLGRAMMARRESOLVER_HPP
Note: See TracBrowser for help on using the repository browser.