77 const std::vector<ResourceDeclaration>& resourceDeclarations,
78 std::ostream& outputStream,
79 const SGPath& outputCppFile,
80 const std::string& initFuncName,
81 const SGPath& outputHeaderFile,
82 const std::string& headerIdentifier,
83 std::size_t inBufSize = 262144,
84 std::size_t outBufSize = 242144);
91 static std::string resourceClass(
92 simgear::AbstractEmbeddedResource::CompressionType compressionType);
96 static std::string encodeResourceIndex(std::size_t index);
100 const std::vector<ResourceDeclaration>& _resDecl;
101 std::ostream& _outputStream;
102 const SGPath _outputCppFile;
103 const std::string _initFuncName;
104 const SGPath _outputHeaderFile;
105 const std::string _headerIdentifier;
107 const std::size_t _compInBufSize;
108 const std::size_t _compOutBufSize;
109 std::unique_ptr<char[]> _compressionInBuf;
110 std::unique_ptr<char[]> _compressionOutBuf;
125 void data(
const char *s,
int len)
override;
126 void warning(
const char *message,
int line,
int column)
override;
129 void startQResourceElement(
const XMLAttributes &atts);
130 void startFileElement(
const XMLAttributes &atts);
131 void error(
const char *message,
int line,
int column);
133 enum class XMLTagType {
138 static const std::array<std::string, 2> _tagTypeStr;
140 enum class ParserState {
143 INSIDE_QRESOURCE_ELT,
148 static const std::array<std::string, 5> _parserStateStr;
150 static bool readBoolean(
const std::string& s);
152 static simgear::AbstractEmbeddedResource::CompressionType
153 determineCompressionType(
const SGPath& resourceFilePath,
154 const std::string& compression);
156 [[ noreturn ]]
void unexpectedTagError(
157 XMLTagType tagType,
const std::string& found,
158 const std::string& expected = std::string());
160 ParserState _parserState = ParserState::START;
162 const SGPath _rootDir;
165 std::string _currentPrefix;
167 std::string _currentLanguage;
169 std::string _currentAlias;
173 std::string _currentCompressionTypeStr;
177 std::string _resourceFile;
180 std::vector<ResourceDeclaration> _resourceDeclarations;
ResourceCodeGenerator(const std::vector< ResourceDeclaration > &resourceDeclarations, std::ostream &outputStream, const SGPath &outputCppFile, const std::string &initFuncName, const SGPath &outputHeaderFile, const std::string &headerIdentifier, std::size_t inBufSize=262144, std::size_t outBufSize=242144)