source: icXML/icXML-devel/src/icxmlc/XMLGrammarResolver.hpp @ 2720

Last change on this file since 2720 was 2720, checked in by cameron, 6 years ago

Initial check-in of icXML 0.8 source files

File size: 1.4 KB
RevLine 
[2720]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 207 2012-12-02 20:38:22Z robc $
10 *
11 */
12
13#ifndef XMLGRAMMARRESOLVER_HPP
14#define XMLGRAMMARRESOLVER_HPP
15
16
17#include <icxmlc/XMLConfig.hpp>
18#include <xercesc/validators/common/Grammar.hpp>
19#include <icxmlc/Array.hpp>
20#include <icxmlc/XMLNamespaceResolver.hpp>
21
22XERCES_CPP_NAMESPACE_BEGIN
23
24class XMLGrammerResolver
25{
26        enum
27        {
28                kDefaultGrammarListSize = 16
29        };
30
31        public:
32
33                XMLGrammerResolver()
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 * XMLGrammerResolver::getGrammar(const unsigned int uriId) const
49{
50        if (likely(uriId < fList.capacity()))
51        {
52                return fList[uriId];
53        }
54        return NULL;
55}
56
57void XMLGrammerResolver::setGrammar(const unsigned int uriId, Grammar * grammar)
58{
59        if (unlikely(uriId >= fList.capacity()))
60        {
61                fList.resizeToFit(uriId);
62
63                DEBUG_MESSAGE("fList.capacity()=" << fList.capacity())
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.