1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14copyright notice, this list of conditions and the
15following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18copyright notice, this list of conditions and the
19following disclaimer in the documentation and/or other
20materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23contributors may be used to endorse or promote products
24derived from this software without specific prior
25written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41/// \file FIReader.hpp
42/// \brief Reader for Fast Infoset encoded binary XML files.
43/// \date 2017
44/// \author Patrick Daehne
45
46#ifndef INCLUDED_AI_FI_READER_H
47#define INCLUDED_AI_FI_READER_H
48
49#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
50
51//#include <wchar.h>
52#include <string>
53#include <memory>
54#include <cerrno>
55#include <cwchar>
56#include <vector>
57//#include <stdio.h>
58//#include <cstdint>
59#include <irrXML.h>
60
61namespace Assimp {
62
63struct FIValue {
64 virtual const std::string &toString() const = 0;
65};
66
67struct FIStringValue: public FIValue {
68 std::string value;
69 static std::shared_ptr<FIStringValue> create(std::string &&value);
70};
71
72struct FIByteValue: public FIValue {
73 std::vector<uint8_t> value;
74};
75
76struct FIHexValue: public FIByteValue {
77 static std::shared_ptr<FIHexValue> create(std::vector<uint8_t> &&value);
78};
79
80struct FIBase64Value: public FIByteValue {
81 static std::shared_ptr<FIBase64Value> create(std::vector<uint8_t> &&value);
82};
83
84struct FIShortValue: public FIValue {
85 std::vector<int16_t> value;
86 static std::shared_ptr<FIShortValue> create(std::vector<int16_t> &&value);
87};
88
89struct FIIntValue: public FIValue {
90 std::vector<int32_t> value;
91 static std::shared_ptr<FIIntValue> create(std::vector<int32_t> &&value);
92};
93
94struct FILongValue: public FIValue {
95 std::vector<int64_t> value;
96 static std::shared_ptr<FILongValue> create(std::vector<int64_t> &&value);
97};
98
99struct FIBoolValue: public FIValue {
100 std::vector<bool> value;
101 static std::shared_ptr<FIBoolValue> create(std::vector<bool> &&value);
102};
103
104struct FIFloatValue: public FIValue {
105 std::vector<float> value;
106 static std::shared_ptr<FIFloatValue> create(std::vector<float> &&value);
107};
108
109struct FIDoubleValue: public FIValue {
110 std::vector<double> value;
111 static std::shared_ptr<FIDoubleValue> create(std::vector<double> &&value);
112};
113
114struct FIUUIDValue: public FIByteValue {
115 static std::shared_ptr<FIUUIDValue> create(std::vector<uint8_t> &&value);
116};
117
118struct FICDATAValue: public FIStringValue {
119 static std::shared_ptr<FICDATAValue> create(std::string &&value);
120};
121
122struct FIDecoder {
123 virtual std::shared_ptr<const FIValue> decode(const uint8_t *data, size_t len) = 0;
124};
125
126struct FIQName {
127 const char *name;
128 const char *prefix;
129 const char *uri;
130};
131
132struct FIVocabulary {
133 const char **restrictedAlphabetTable;
134 size_t restrictedAlphabetTableSize;
135 const char **encodingAlgorithmTable;
136 size_t encodingAlgorithmTableSize;
137 const char **prefixTable;
138 size_t prefixTableSize;
139 const char **namespaceNameTable;
140 size_t namespaceNameTableSize;
141 const char **localNameTable;
142 size_t localNameTableSize;
143 const char **otherNCNameTable;
144 size_t otherNCNameTableSize;
145 const char **otherURITable;
146 size_t otherURITableSize;
147 const std::shared_ptr<const FIValue> *attributeValueTable;
148 size_t attributeValueTableSize;
149 const std::shared_ptr<const FIValue> *charactersTable;
150 size_t charactersTableSize;
151 const std::shared_ptr<const FIValue> *otherStringTable;
152 size_t otherStringTableSize;
153 const FIQName *elementNameTable;
154 size_t elementNameTableSize;
155 const FIQName *attributeNameTable;
156 size_t attributeNameTableSize;
157};
158
159class IOStream;
160
161class FIReader: public irr::io::IIrrXMLReader<char, irr::io::IXMLBase> {
162public:
163 virtual ~FIReader();
164 virtual std::shared_ptr<const FIValue> getAttributeEncodedValue(int idx) const = 0;
165
166 virtual std::shared_ptr<const FIValue> getAttributeEncodedValue(const char *name) const = 0;
167
168 virtual void registerDecoder(const std::string &algorithmUri, std::unique_ptr<FIDecoder> decoder) = 0;
169
170 virtual void registerVocabulary(const std::string &vocabularyUri, const FIVocabulary *vocabulary) = 0;
171
172 static std::unique_ptr<FIReader> create(IOStream *stream);
173
174};// class IFIReader
175
176inline
177FIReader::~FIReader() {
178 // empty
179}
180
181}// namespace Assimp
182
183#endif // #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
184
185#endif // INCLUDED_AI_FI_READER_H
186