//------------------------------------------// // AssetMetaDataParser::WriteMetaData //------------------------------------------// bool AssetMetaDataParser::WriteMetaDataToFile( class File& metaDataFile, const struct AssetMetaData& metaData) { if (!CheckMetaDataFileIsValid(metaDataFile)) { return false; } // Check if the file is new and cleared if (metaDataFile.GetFilemode() != File::READ_WRITE_NEW) { Log::GetLog().LogHighMsg("MetaDataFile is not empty."); return false; } //Begin the XML parsing XMLParser parser; if (!parser.Parse(metaDataFile)) { return false; } XMLElement baseElement = parser.CreateNewElement(ASSET_TAG); baseElement.CreateChildElement(ASSET_NAME_TAG, metaData.AssetName); //Determine readable name from TypeHash std::string assetType = "Invalid"; if (!mAssetFileTypeExtensions->HashIsOfAssetTypeName(metaData.AssetTypeHash, assetType)) { //Log that we cant determine type } baseElement.CreateChildElement(ASSET_TYPE_TAG, assetType); baseElement.CreateChildElement(ASSET_PATH_TAG, metaData.AssetFilePath); XMLElement attrElement = baseElement.CreateChildElement(ASSET_ATTRIBUTE_TAG); XMLElement scalarAttrElement = attrElement.CreateChildElement(ASSET_SCALAR_ATTRIBUTE_TAG); XMLElement vectorAttrElement = attrElement.CreateChildElement(ASSET_VECTOR_ATTRIBUTE_TAG); AssetScalarAttributeContainer& container = AssetDefaultAttributes<Texture2D>::DefaultScalarAttributes; for each (AssetScalarAttribute scalarAttr in container) { scalarAttrElement.CreateChildElement(scalarAttr.AttributeName, ToString(scalarAttr.AttributeValue)); }