Make many constructors explicit to avoid unintended implicit conversions
This commit is contained in:
parent
ed37b6c5e5
commit
aa23750307
|
@ -8,8 +8,8 @@ set(META_APP_NAME "Tag Parser")
|
||||||
set(META_APP_AUTHOR "Martchus")
|
set(META_APP_AUTHOR "Martchus")
|
||||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||||
set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags")
|
set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags")
|
||||||
set(META_VERSION_MAJOR 9)
|
set(META_VERSION_MAJOR 10)
|
||||||
set(META_VERSION_MINOR 4)
|
set(META_VERSION_MINOR 0)
|
||||||
set(META_VERSION_PATCH 0)
|
set(META_VERSION_PATCH 0)
|
||||||
set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0)
|
set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0)
|
||||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
namespace TagParser {
|
namespace TagParser {
|
||||||
|
|
||||||
struct TAG_PARSER_EXPORT AspectRatio {
|
struct TAG_PARSER_EXPORT AspectRatio {
|
||||||
constexpr AspectRatio();
|
constexpr explicit AspectRatio();
|
||||||
AspectRatio(std::uint8_t aspectRatioType);
|
explicit AspectRatio(std::uint8_t aspectRatioType);
|
||||||
constexpr AspectRatio(std::uint16_t numerator, std::uint16_t denominator);
|
constexpr explicit AspectRatio(std::uint16_t numerator, std::uint16_t denominator);
|
||||||
constexpr bool isValid() const;
|
constexpr bool isValid() const;
|
||||||
constexpr bool isExtended() const;
|
constexpr bool isExtended() const;
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace TagParser {
|
||||||
class TAG_PARSER_EXPORT BasicFileInfo {
|
class TAG_PARSER_EXPORT BasicFileInfo {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
BasicFileInfo(const std::string &path = std::string());
|
explicit BasicFileInfo(const std::string &path = std::string());
|
||||||
BasicFileInfo(const BasicFileInfo &) = delete;
|
BasicFileInfo(const BasicFileInfo &) = delete;
|
||||||
BasicFileInfo &operator=(const BasicFileInfo &) = delete;
|
BasicFileInfo &operator=(const BasicFileInfo &) = delete;
|
||||||
virtual ~BasicFileInfo();
|
virtual ~BasicFileInfo();
|
||||||
|
|
|
@ -237,8 +237,8 @@ void Id3v1Tag::removeAllFields()
|
||||||
unsigned int Id3v1Tag::fieldCount() const
|
unsigned int Id3v1Tag::fieldCount() const
|
||||||
{
|
{
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
for (const auto &value : { m_title, m_artist, m_album, m_year, m_comment, m_trackPos, m_genre }) {
|
for (const auto &value : std::initializer_list<const TagValue *>{ &m_title, &m_artist, &m_album, &m_year, &m_comment, &m_trackPos, &m_genre }) {
|
||||||
if (!value.isEmpty()) {
|
if (!value->isEmpty()) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,11 +404,11 @@ void Id3v2Tag::convertOldRecordDateFields(const std::string &diagContext, Diagno
|
||||||
|
|
||||||
// set the field values as DateTime
|
// set the field values as DateTime
|
||||||
try {
|
try {
|
||||||
setValue(Id3v2FrameIds::lRecordingTime, DateTime::fromDateAndTime(year, month, day, hour, minute));
|
setValue(Id3v2FrameIds::lRecordingTime, TagValue(DateTime::fromDateAndTime(year, month, day, hour, minute)));
|
||||||
} catch (const ConversionException &e) {
|
} catch (const ConversionException &e) {
|
||||||
try {
|
try {
|
||||||
// try to set at least the year
|
// try to set at least the year
|
||||||
setValue(Id3v2FrameIds::lRecordingTime, DateTime::fromDate(year));
|
setValue(Id3v2FrameIds::lRecordingTime, TagValue(DateTime::fromDate(year)));
|
||||||
diag.emplace_back(DiagLevel::Critical,
|
diag.emplace_back(DiagLevel::Critical,
|
||||||
argsToString(
|
argsToString(
|
||||||
"Unable to parse the full date of the recording. Only the 'Year' frame could be parsed; related frames failed: ", e.what()),
|
"Unable to parse the full date of the recording. Only the 'Year' frame could be parsed; related frames failed: ", e.what()),
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace TagParser {
|
||||||
*/
|
*/
|
||||||
class TAG_PARSER_EXPORT LocaleAwareString : public std::string {
|
class TAG_PARSER_EXPORT LocaleAwareString : public std::string {
|
||||||
public:
|
public:
|
||||||
LocaleAwareString(const std::string &value = std::string());
|
explicit LocaleAwareString(const std::string &value = std::string());
|
||||||
LocaleAwareString(std::string &&value);
|
explicit LocaleAwareString(std::string &&value);
|
||||||
~LocaleAwareString();
|
~LocaleAwareString();
|
||||||
|
|
||||||
const std::vector<std::string> &languages() const;
|
const std::vector<std::string> &languages() const;
|
||||||
|
|
2
margin.h
2
margin.h
|
@ -15,7 +15,7 @@ namespace TagParser {
|
||||||
*/
|
*/
|
||||||
class TAG_PARSER_EXPORT Margin {
|
class TAG_PARSER_EXPORT Margin {
|
||||||
public:
|
public:
|
||||||
constexpr Margin(std::uint32_t top = 0, std::uint32_t left = 0, std::uint32_t bottom = 0, std::uint32_t right = 0);
|
constexpr explicit Margin(std::uint32_t top = 0, std::uint32_t left = 0, std::uint32_t bottom = 0, std::uint32_t right = 0);
|
||||||
constexpr std::uint32_t top() const;
|
constexpr std::uint32_t top() const;
|
||||||
void setTop(std::uint32_t top);
|
void setTop(std::uint32_t top);
|
||||||
constexpr std::uint32_t left() const;
|
constexpr std::uint32_t left() const;
|
||||||
|
|
|
@ -45,8 +45,8 @@ enum class ParsingStatus : std::uint8_t {
|
||||||
class TAG_PARSER_EXPORT MediaFileInfo : public BasicFileInfo {
|
class TAG_PARSER_EXPORT MediaFileInfo : public BasicFileInfo {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
MediaFileInfo();
|
explicit MediaFileInfo();
|
||||||
MediaFileInfo(const std::string &path);
|
explicit MediaFileInfo(const std::string &path);
|
||||||
MediaFileInfo(const MediaFileInfo &) = delete;
|
MediaFileInfo(const MediaFileInfo &) = delete;
|
||||||
MediaFileInfo &operator=(const MediaFileInfo &) = delete;
|
MediaFileInfo &operator=(const MediaFileInfo &) = delete;
|
||||||
~MediaFileInfo() override;
|
~MediaFileInfo() override;
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace TagParser {
|
||||||
*/
|
*/
|
||||||
class TAG_PARSER_EXPORT PositionInSet {
|
class TAG_PARSER_EXPORT PositionInSet {
|
||||||
public:
|
public:
|
||||||
constexpr PositionInSet(std::int32_t position = 0, std::int32_t total = 0);
|
constexpr explicit PositionInSet(std::int32_t position = 0, std::int32_t total = 0);
|
||||||
template <typename StringType = std::string,
|
template <typename StringType = std::string,
|
||||||
CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_string>> * = nullptr>
|
CppUtilities::Traits::EnableIfAny<CppUtilities::Traits::IsSpecializationOf<StringType, std::basic_string>> * = nullptr>
|
||||||
PositionInSet(const StringType &numericString);
|
PositionInSet(const StringType &numericString);
|
||||||
|
|
|
@ -14,8 +14,8 @@ template <typename ActualProgressFeedback> class BasicProgressFeedback {
|
||||||
public:
|
public:
|
||||||
using Callback = std::function<void(ActualProgressFeedback &feedback)>;
|
using Callback = std::function<void(ActualProgressFeedback &feedback)>;
|
||||||
|
|
||||||
BasicProgressFeedback(const Callback &callback, const Callback &percentageOnlyCallback = Callback());
|
explicit BasicProgressFeedback(const Callback &callback, const Callback &percentageOnlyCallback = Callback());
|
||||||
BasicProgressFeedback(Callback &&callback, Callback &&percentageOnlyCallback = Callback());
|
explicit BasicProgressFeedback(Callback &&callback, Callback &&percentageOnlyCallback = Callback());
|
||||||
|
|
||||||
const std::string &step() const;
|
const std::string &step() const;
|
||||||
std::uint8_t stepPercentage() const;
|
std::uint8_t stepPercentage() const;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
using IdType = std::uint64_t;
|
using IdType = std::uint64_t;
|
||||||
using IdContainerType = std::vector<IdType>;
|
using IdContainerType = std::vector<IdType>;
|
||||||
|
|
||||||
TagTarget(std::uint64_t level = 0, IdContainerType tracks = IdContainerType(), IdContainerType chapters = IdContainerType(),
|
explicit TagTarget(std::uint64_t level = 0, IdContainerType tracks = IdContainerType(), IdContainerType chapters = IdContainerType(),
|
||||||
IdContainerType editions = IdContainerType(), IdContainerType attachments = IdContainerType());
|
IdContainerType editions = IdContainerType(), IdContainerType attachments = IdContainerType());
|
||||||
|
|
||||||
std::uint64_t level() const;
|
std::uint64_t level() const;
|
||||||
|
|
22
tagvalue.h
22
tagvalue.h
|
@ -75,19 +75,21 @@ enum class TagValueComparisionFlags : unsigned int {
|
||||||
class TAG_PARSER_EXPORT TagValue {
|
class TAG_PARSER_EXPORT TagValue {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor
|
// constructor, destructor
|
||||||
TagValue();
|
explicit TagValue();
|
||||||
TagValue(const char *text, std::size_t textSize, TagTextEncoding textEncoding = TagTextEncoding::Latin1,
|
explicit TagValue(const char *text, std::size_t textSize, TagTextEncoding textEncoding = TagTextEncoding::Latin1,
|
||||||
TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
||||||
TagValue(const char *text, TagTextEncoding textEncoding = TagTextEncoding::Latin1, TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
explicit TagValue(
|
||||||
TagValue(
|
const char *text, TagTextEncoding textEncoding = TagTextEncoding::Latin1, TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
||||||
|
explicit TagValue(
|
||||||
const std::string &text, TagTextEncoding textEncoding = TagTextEncoding::Latin1, TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
const std::string &text, TagTextEncoding textEncoding = TagTextEncoding::Latin1, TagTextEncoding convertTo = TagTextEncoding::Unspecified);
|
||||||
TagValue(int value);
|
explicit TagValue(int value);
|
||||||
TagValue(const char *data, std::size_t length, TagDataType type = TagDataType::Undefined, TagTextEncoding encoding = TagTextEncoding::Latin1);
|
explicit TagValue(
|
||||||
TagValue(std::unique_ptr<char[]> &&data, std::size_t length, TagDataType type = TagDataType::Binary,
|
const char *data, std::size_t length, TagDataType type = TagDataType::Undefined, TagTextEncoding encoding = TagTextEncoding::Latin1);
|
||||||
|
explicit TagValue(std::unique_ptr<char[]> &&data, std::size_t length, TagDataType type = TagDataType::Binary,
|
||||||
TagTextEncoding encoding = TagTextEncoding::Latin1);
|
TagTextEncoding encoding = TagTextEncoding::Latin1);
|
||||||
TagValue(PositionInSet value);
|
explicit TagValue(PositionInSet value);
|
||||||
TagValue(CppUtilities::DateTime value);
|
explicit TagValue(CppUtilities::DateTime value);
|
||||||
TagValue(CppUtilities::TimeSpan value);
|
explicit TagValue(CppUtilities::TimeSpan value);
|
||||||
TagValue(const TagValue &other);
|
TagValue(const TagValue &other);
|
||||||
TagValue(TagValue &&other) = default;
|
TagValue(TagValue &&other) = default;
|
||||||
~TagValue();
|
~TagValue();
|
||||||
|
|
Loading…
Reference in New Issue