From: jiyong.min Date: Thu, 14 May 2020 04:17:12 +0000 (+0900) Subject: Use auto keyword X-Git-Tag: submit/tizen/20200602.021203~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc62524514ac08aacdb883e40379b3bfe47e9a55;p=platform%2Fcore%2Fapi%2Fmetadata-editor.git Use auto keyword Change-Id: Ieb7eb0f9e9fc80e5b37aae469a17d5822317450a --- diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index ce94fca..58d5fb9 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -271,11 +271,11 @@ static int __ID3_getLyricsFrame(metadata_editor_s *_metadata, ID3v2::Tag *tag2, metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further"); - ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag + auto lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_NONE, "The frame USLT does not exist"); metadata_editor_info("The frame USLT exists"); - ID3v2::FrameList::Iterator it = lst.begin(); + auto it = lst.begin(); auto frame = static_cast(*it); *value = g_strdup(frame->text().toCString(true)); @@ -328,7 +328,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s *_metadata, ID3v2::Tag *tag2, metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); - ID3v2::FrameList lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag + auto lst = tag2->frameListMap()["USLT"]; // link to unsynchronized lyric frames in tag // If the pointer is NULL or c-string is empty - handle as request for deletion if (!value || (*value == '\0')) { metadata_editor_info("Request for frame USLT deletion"); @@ -346,7 +346,7 @@ static int __ID3_setLyricsFrame(metadata_editor_s *_metadata, ID3v2::Tag *tag2, tag2->addFrame(frame); } else { // the lyrics frames exist - change the existing one metadata_editor_info("USLT frames exist in file. Changing"); - ID3v2::FrameList::Iterator it = lst.begin(); + auto it = lst.begin(); auto frame = static_cast(*it); frame->setTextEncoding(String::UTF8); frame->setText(String(value, String::UTF8)); @@ -366,8 +366,8 @@ static int __MP4_getStringItem(metadata_editor_s *_metadata, const char *itemnam auto tag = dynamic_cast(_metadata->file->tag()); metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); - MP4::ItemListMap& itemMap = tag->itemListMap(); - MP4::ItemListMap::ConstIterator it = itemMap.find(itemname); + auto itemMap = tag->itemListMap(); + auto it = itemMap.find(itemname); if (it != itemMap.end()) *value = g_strdup(it->second.toStringList()[0].toCString(true)); @@ -388,8 +388,8 @@ static int __MP4_getIntegerItem(metadata_editor_s *_metadata, const char *itemna auto tag = dynamic_cast(_metadata->file->tag()); metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); - MP4::ItemListMap& itemMap = tag->itemListMap(); - MP4::ItemListMap::ConstIterator it = itemMap.find(itemname); + auto itemMap = tag->itemListMap(); + auto it = itemMap.find(itemname); if (it != itemMap.end()) *value = g_strdup_printf("%u", it->second.toInt()); else @@ -410,11 +410,11 @@ static int __MP4_updateStringItem(metadata_editor_s *_metadata, const char *item metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item - MP4::ItemListMap& itemMap = tag->itemListMap(); + auto itemMap = tag->itemListMap(); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { metadata_editor_info("Request for deleting of item <%s>", itemname); - MP4::ItemListMap::Iterator it = itemMap.find(itemname); + auto it = itemMap.find(itemname); if (it != itemMap.end()) itemMap.erase(it); return METADATA_EDITOR_ERROR_NONE; @@ -437,7 +437,7 @@ static int __MP4_updateIntegerItem(metadata_editor_s *_metadata, const char *ite metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); // Get map of items directly from tag and launch a search of specific item - MP4::ItemListMap& itemMap = tag->itemListMap(); + auto itemMap = tag->itemListMap(); // Check if it is a request for deletion if ((value == NULL) || value[0] == '\0') { metadata_editor_info("Request for deleting of item <%s>", itemname); @@ -483,8 +483,8 @@ static int __xiph_getFieldValue(metadata_editor_s *_metadata, Ogg::XiphComment * metadata_editor_retvm_if(!fieldname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid fieldname"); metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); - const Ogg::FieldListMap& fieldMap = xtag->fieldListMap(); - Ogg::FieldListMap::ConstIterator it = fieldMap.find(fieldname); + auto fieldMap = xtag->fieldListMap(); + auto it = fieldMap.find(fieldname); if ((xtag->contains(fieldname)) && (it != fieldMap.end())) *value = g_strdup(it->second[0].toCString(true)); @@ -522,7 +522,7 @@ static int __FLAC_getNumberOfPictures(metadata_editor_s *_metadata, char **value ret = __check_metadata_get_parameter(_metadata, value); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); - FLAC::File *_file = dynamic_cast _metadata->file; + auto _file = dynamic_cast(_metadata->file); *value = g_strdup_printf("%u", _file->pictureList().size()); @@ -743,9 +743,9 @@ static int __metadata_editor_get_mp3_metadata(metadata_editor_s *metadata, metad metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); // Bring the pointer to actual file type and make tag pointers - MPEG::File *_file = dynamic_cast(metadata->file); - ID3v1::Tag *tag1 = _file->ID3v1Tag(); - ID3v2::Tag *tag2 = _file->ID3v2Tag(); + auto _file = dynamic_cast(metadata->file); + auto tag1 = _file->ID3v1Tag(); + auto tag2 = _file->ID3v2Tag(); switch (attribute) { // Check which one of frame types was given to the function for processing case METADATA_EDITOR_ATTR_ARTIST: return __ID3_getTwixFrameByName(metadata, tag1, tag2, "TPE1", value); @@ -801,8 +801,8 @@ static int __metadata_editor_get_flac_metadata(metadata_editor_s *metadata, meta metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - FLAC::File *_file = (FLAC::File*)metadata->file; - Ogg::XiphComment *xtag = _file->xiphComment(false); + auto _file = (FLAC::File*)metadata->file; + auto xtag = _file->xiphComment(false); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Tag does not exist"); *value = NULL; @@ -835,8 +835,8 @@ static int __metadata_editor_get_ogg_vorbis_metadata(metadata_editor_s *metadata metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - Ogg::Vorbis::File *_file = (Ogg::Vorbis::File*)metadata->file; - Ogg::XiphComment *xtag = _file->tag(); + auto _file = (Ogg::Vorbis::File*)metadata->file; + auto xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Tag does not exist"); *value = NULL; @@ -868,8 +868,8 @@ static int __metadata_editor_get_ogg_flac_metadata(metadata_editor_s *metadata, metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - Ogg::FLAC::File *_file = (Ogg::FLAC::File*)metadata->file; - Ogg::XiphComment *xtag = _file->tag(); + auto _file = (Ogg::FLAC::File*)metadata->file; + auto xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Tag does not exist"); *value = NULL; @@ -901,8 +901,8 @@ static int __metadata_editor_get_wav_metadata(metadata_editor_s *metadata, metad metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret); // Bring the pointer to actual file type and make tag pointers - RIFF::WAV::File *_file = (RIFF::WAV::File*)metadata->file; - ID3v2::Tag *tag2 = _file->tag(); + auto _file = (RIFF::WAV::File*)metadata->file; + auto tag2 = _file->tag(); if (tag2 == NULL) { // Check if we have a valid tag for processing metadata_editor_error("Error. ID3v2 tag does not exist. Can not proceed metadata extraction"); @@ -971,9 +971,9 @@ static int __metadata_editor_set_mp3_metadata(metadata_editor_s *metadata, metad metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - MPEG::File *_file = (MPEG::File*)metadata->file; - ID3v1::Tag *tag1 = _file->ID3v1Tag(); - ID3v2::Tag *tag2 = _file->ID3v2Tag(true); + auto _file = (MPEG::File*)metadata->file; + auto tag1 = _file->ID3v1Tag(); + auto tag2 = _file->ID3v2Tag(true); metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); @@ -1029,8 +1029,8 @@ static int __metadata_editor_set_flac_metadata(metadata_editor_s *metadata, meta metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - FLAC::File *_file = (FLAC::File*)metadata->file; - Ogg::XiphComment *xtag = _file->xiphComment(true); + auto _file = (FLAC::File*)metadata->file; + auto xtag = _file->xiphComment(true); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; @@ -1061,8 +1061,8 @@ static int __metadata_editor_set_ogg_vorbis_metadata(metadata_editor_s *metadata metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - Ogg::Vorbis::File *_file = (Ogg::Vorbis::File*)metadata->file; - Ogg::XiphComment *xtag = _file->tag(); + auto _file = (Ogg::Vorbis::File*)metadata->file; + auto xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; @@ -1093,8 +1093,8 @@ static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s *metadata, metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - Ogg::FLAC::File *_file = (Ogg::FLAC::File*)metadata->file; - Ogg::XiphComment *xtag = _file->tag(); + auto _file = (Ogg::FLAC::File*)metadata->file; + auto xtag = _file->tag(); if (!xtag) { // Check if we have a valid tag for processing metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; @@ -1125,10 +1125,10 @@ static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metad metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); // Bring the pointer to actual file type and make tags pointers - RIFF::WAV::File *_file = (RIFF::WAV::File*)metadata->file; - ID3v2::Tag *tag2 = _file->tag(); + auto _file = (RIFF::WAV::File*)metadata->file; + auto tag2 = _file->tag(); // Check if the valid tag pointer exist - if (tag2 == NULL) { + if (!tag2) { metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating"); return METADATA_EDITOR_ERROR_OPERATION_FAILED; } @@ -1195,8 +1195,8 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: { - MPEG::File *_file = (MPEG::File*)_metadata->file; - ID3v1::Tag *tag1 = _file->ID3v1Tag(); + auto _file = (MPEG::File*)_metadata->file; + auto tag1 = _file->ID3v1Tag(); if (!tag1 || tag1->isEmpty()) { // If no ID3v1 tag - prevent its creation if (_file->save(MPEG::File::ID3v2 | MPEG::File::APE)) @@ -1250,7 +1250,7 @@ static int __get_APIC(ID3v2::Tag *tag, int index, void **picture, int *size, cha { metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file."); - ID3v2::FrameList lst = tag->frameListMap()["APIC"]; + auto lst = tag->frameListMap()["APIC"]; // Check if there are pictures in the tag if (lst.isEmpty()) { @@ -1293,7 +1293,7 @@ static int __get_mp4_picture(metadata_editor_s *metadata, int index, void **pict return METADATA_EDITOR_ERROR_OPERATION_FAILED; } - MP4::CoverArtList lst = tag->item("covr").toCoverArtList(); + auto lst = tag->item("covr").toCoverArtList(); // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { @@ -1316,8 +1316,8 @@ static int __get_mp4_picture(metadata_editor_s *metadata, int index, void **pict #if 0 static int __get_flac_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type) { - FLAC::File *_file = (FLAC::File*) metadata->file; - List lst = _file->pictureList(); + auto _file = (FLAC::File*) metadata->file; + auto lst = _file->pictureList(); if (lst.isEmpty()) { metadata_editor_error("No pictures in FLAC file"); @@ -1344,7 +1344,7 @@ static int __get_flac_picture(metadata_editor_s *metadata, int index, void **pic static int __get_wav_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type) { - RIFF::WAV::File *_file = (RIFF::WAV::File*)metadata->file; + auto _file = (RIFF::WAV::File*)metadata->file; return __get_APIC(_file->tag(), index, picture, size, mime_type); } @@ -1408,7 +1408,7 @@ static int __append_mp4_picture(metadata_editor_s *metadata, const char *picture metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); MP4::CoverArtList lst; - MP4::CoverArt::Format format = MP4::CoverArt::Unknown; + auto format = MP4::CoverArt::Unknown; if (strncmp(mime_type, MIME_TYPE_JPEG, strlen(MIME_TYPE_JPEG)) == 0) format = MP4::CoverArt::JPEG; else if (strncmp(mime_type, MIME_TYPE_PNG, strlen(MIME_TYPE_PNG)) == 0) @@ -1428,7 +1428,7 @@ static int __append_mp4_picture(metadata_editor_s *metadata, const char *picture #if 0 static int __append_flac_picture(metadata_editor_s *metadata, const char *picture, size_t size, const char *mime_type) { - FLAC::File *_file = (FLAC::File*) metadata->file; + auto _file = (FLAC::File*) metadata->file; auto frontCover = new FLAC::Picture; metadata_editor_debug_fenter(); @@ -1498,7 +1498,7 @@ static int __remove_APIC(ID3v2::Tag *tag, int index) { metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); - ID3v2::FrameList lst = tag->frameListMap()["APIC"]; + auto lst = tag->frameListMap()["APIC"]; metadata_editor_retvm_if(lst.isEmpty(), METADATA_EDITOR_ERROR_OPERATION_FAILED, "No pictures in file"); if ((index < 0) || ((uint)index >= lst.size())) { @@ -1525,7 +1525,7 @@ static int __remove_mp4_picture(metadata_editor_s *metadata, int index) return METADATA_EDITOR_ERROR_OPERATION_FAILED; } - MP4::CoverArtList lst = tag->item("covr").toCoverArtList(); + auto lst = tag->item("covr").toCoverArtList(); // Check if the index is in range of CoverArtList Item if ((index < 0) || ((uint)index >= lst.size())) { @@ -1546,8 +1546,8 @@ static int __remove_mp4_picture(metadata_editor_s *metadata, int index) #if 0 static int __remove_flac_picture(metadata_editor_s *metadata, int index) { - FLAC::File *_file = dynamic_cast metadata->file; - List lst = _file->pictureList(); + auto _file = dynamic_cast(metadata->file); + auto lst = _file->pictureList(); if (lst.isEmpty()) { metadata_editor_error("No pictures in file. Nothing to delete");