// Copyright(c) 2023, NVIDIA CORPORATION. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "XMLHelper.hpp" #include #include #include class VideoHppGenerator { public: VideoHppGenerator( tinyxml2::XMLDocument const & document ); void generateHppFile() const; private: struct ConstantData { std::string value = {}; int xmlLine = {}; }; struct DefineData { std::string require = {}; int xmlLine = {}; }; struct EnumValueData { std::string name = {}; std::string value = {}; int xmlLine = {}; }; struct EnumData { std::vector values = {}; int xmlLine = {}; }; struct RequireData { std::map constants = {}; std::vector types = {}; int xmlLine = {}; }; struct ExtensionData { std::string depends = {}; std::string name = {}; RequireData requireData = {}; int xmlLine = 0; }; struct MemberData { TypeInfo type = {}; std::string name = {}; std::vector arraySizes = {}; std::string bitCount = {}; int xmlLine = {}; }; struct StructureData { std::vector members = {}; int xmlLine = {}; }; private: void addImplicitlyRequiredTypes(); std::vector::iterator addImplicitlyRequiredTypes( std::map::iterator typeIt, ExtensionData & extensionData, std::vector::iterator reqIt ); void checkCorrectness() const; std::string generateEnum( std::pair const & enumData ) const; std::string generateEnums() const; std::string generateEnums( RequireData const & requireData, std::string const & title ) const; std::string generateStruct( std::pair const & structData ) const; std::string generateStructCompareOperators( std::pair const & structData ) const; std::string generateStructMembers( std::pair const & structData ) const; std::string generateStructs() const; std::string generateStructs( RequireData const & requireData, std::string const & title ) const; bool isExtension( std::string const & name ) const; void readEnums( tinyxml2::XMLElement const * element ); void readEnumsEnum( tinyxml2::XMLElement const * element, std::map::iterator enumIt ); void readExtension( tinyxml2::XMLElement const * element ); void readExtensionRequire( tinyxml2::XMLElement const * element, ExtensionData & extensionData ); void readExtensions( tinyxml2::XMLElement const * element ); void readRegistry( tinyxml2::XMLElement const * element ); void readRequireEnum( tinyxml2::XMLElement const * element, std::map & constants ); void readRequireType( tinyxml2::XMLElement const * element, ExtensionData & extensionData ); void readStructMember( tinyxml2::XMLElement const * element, std::vector & members ); void readTypeDefine( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeEnum( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeInclude( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypeRequires( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypes( tinyxml2::XMLElement const * element ); void readTypeStruct( tinyxml2::XMLElement const * element, std::map const & attributes ); void readTypesType( tinyxml2::XMLElement const * element ); void sortStructs(); private: std::string m_copyrightMessage; std::map m_defines; std::map m_enums; std::vector m_extensions; std::map m_externalTypes; std::map m_includes; std::map m_structs; std::map m_types; };