Improve customization point for clearing tag field
* Allow customizing clearing only the value * Use same naming scheme as in other places * Avoid having to add an empty reset() function in subclasses
This commit is contained in:
parent
cbd7e75972
commit
65d52b2d57
|
@ -64,6 +64,10 @@ public:
|
|||
std::vector<ImplementationType> &nestedFields();
|
||||
bool supportsNestedFields() const;
|
||||
|
||||
protected:
|
||||
void internallyClearValue();
|
||||
void internallyClearFurtherData();
|
||||
|
||||
private:
|
||||
IdentifierType m_id;
|
||||
TagValue m_value;
|
||||
|
@ -164,7 +168,7 @@ template <class ImplementationType> inline void TagField<ImplementationType>::se
|
|||
*/
|
||||
template <class ImplementationType> inline void TagField<ImplementationType>::clearValue()
|
||||
{
|
||||
m_value.clearDataAndMetadata();
|
||||
static_cast<ImplementationType *>(this)->internallyClearValue();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -224,10 +228,10 @@ template <class ImplementationType> void TagField<ImplementationType>::clear()
|
|||
{
|
||||
clearId();
|
||||
clearValue();
|
||||
static_cast<ImplementationType *>(this)->internallyClearFurtherData();
|
||||
m_typeInfo = TypeInfoType();
|
||||
m_typeInfoAssigned = false;
|
||||
m_default = true;
|
||||
static_cast<ImplementationType *>(this)->reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -267,6 +271,23 @@ template <class ImplementationType> inline bool TagField<ImplementationType>::su
|
|||
return static_cast<ImplementationType *>(this)->supportsNestedFields();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Clears the assigned value; called via clearValue() and clear().
|
||||
* \remarks Shadow when subclassing to customize clearning a value.
|
||||
*/
|
||||
template <class ImplementationType> void TagField<ImplementationType>::internallyClearValue()
|
||||
{
|
||||
m_value.clearDataAndMetadata();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Clears further data; called via clear().
|
||||
* \remarks Shadow when subclassing to clear further data the subclass has.
|
||||
*/
|
||||
template <class ImplementationType> void TagField<ImplementationType>::internallyClearFurtherData()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace TagParser
|
||||
|
||||
#endif // TAG_PARSER_TAGFIELD_H
|
||||
|
|
|
@ -398,9 +398,18 @@ void Id3v2Frame::make(BinaryWriter &writer, std::uint8_t version, Diagnostics &d
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets ID3v2-specific values. Called via clear().
|
||||
* \brief Clears ID3v2-specific values. Called via clear() and clearValue().
|
||||
*/
|
||||
void Id3v2Frame::reset()
|
||||
void Id3v2Frame::internallyClearValue()
|
||||
{
|
||||
value().clearDataAndMetadata();
|
||||
m_additionalValues.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Clears ID3v2-specific values. Called via clear().
|
||||
*/
|
||||
void Id3v2Frame::internallyClearFurtherData()
|
||||
{
|
||||
m_flag = 0;
|
||||
m_group = 0;
|
||||
|
@ -408,7 +417,6 @@ void Id3v2Frame::reset()
|
|||
m_dataSize = 0;
|
||||
m_totalSize = 0;
|
||||
m_padding = false;
|
||||
m_additionalValues.clear();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -144,7 +144,8 @@ public:
|
|||
static std::string fieldIdToString(IdentifierType id);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
void internallyClearValue();
|
||||
void internallyClearFurtherData();
|
||||
std::string ignoreAdditionalValuesDiagMsg() const;
|
||||
|
||||
std::vector<TagValue> m_additionalValues;
|
||||
|
|
|
@ -79,9 +79,6 @@ public:
|
|||
|
||||
static typename std::string fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos);
|
||||
static std::string fieldIdToString(const std::string &id);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -118,13 +115,6 @@ inline std::string MatroskaTagField::fieldIdToString(const std::string &id)
|
|||
return id;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets Matroska-specific values. Called via clear().
|
||||
*/
|
||||
inline void MatroskaTagField::reset()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace TagParser
|
||||
|
||||
#endif // TAG_PARSER_MATROSKATAGFIELD_H
|
||||
|
|
|
@ -464,15 +464,24 @@ std::uint32_t Mp4TagField::appropriateRawDataTypeForValue(const TagValue &value)
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets MP4-specific values. Called via clear().
|
||||
* \brief Clears MP4-specific values. Called via clear() and clearValue().
|
||||
*/
|
||||
void Mp4TagField::reset()
|
||||
void Mp4TagField::internallyClearValue()
|
||||
{
|
||||
value().clearDataAndMetadata();
|
||||
m_additionalData.clear();
|
||||
m_countryIndicator = 0;
|
||||
m_langIndicator = 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Clears MP4-specific values. Called via clear() and clearValue().
|
||||
*/
|
||||
void Mp4TagField::internallyClearFurtherData()
|
||||
{
|
||||
m_name.clear();
|
||||
m_mean.clear();
|
||||
m_parsedRawDataType = RawDataType::Reserved;
|
||||
m_countryIndicator = 0;
|
||||
m_langIndicator = 0;
|
||||
}
|
||||
|
||||
/// \cond
|
||||
|
|
|
@ -147,7 +147,8 @@ public:
|
|||
static std::string fieldIdToString(IdentifierType id);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
void internallyClearValue();
|
||||
void internallyClearFurtherData();
|
||||
std::string m_name;
|
||||
std::string m_mean;
|
||||
std::vector<AdditionalData> m_additionalData;
|
||||
|
|
|
@ -62,7 +62,6 @@ public:
|
|||
static std::string fieldIdToString(const std::string &id);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
template <class StreamType> void internalParse(StreamType &stream, std::uint64_t &maxSize, Diagnostics &diag);
|
||||
};
|
||||
|
||||
|
@ -100,13 +99,6 @@ inline std::string VorbisCommentField::fieldIdToString(const std::string &id)
|
|||
return id;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Resets Vorbis Comment-specific values. Called via clear().
|
||||
*/
|
||||
inline void VorbisCommentField::reset()
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace TagParser
|
||||
|
||||
#endif // TAG_PARSER_VORBISCOMMENTFIELD_H
|
||||
|
|
Loading…
Reference in New Issue