common: implement clang-tidy's suggestions regarding modernization

This commit is contained in:
Moritz Bunkus 2019-01-02 21:14:21 +01:00
parent a0692c2743
commit ac38b8ec2a
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
59 changed files with 215 additions and 258 deletions

View File

@ -204,8 +204,7 @@ find_consecutive_headers(unsigned char const *buf,
return base;
++base;
offset = 0;
pos = find_header(&buf[base], size - base, header, false);
pos = find_header(&buf[base], size - base, header, false);
if (-1 == pos)
return -1;

View File

@ -18,7 +18,7 @@
#include "common/common_pch.h"
#include <FLAC/stream_decoder.h>
#include <stdarg.h>
#include <cstdarg>
#include "common/bit_reader.h"
#include "common/flac.h"
@ -85,12 +85,6 @@ flac_eof_cb(const FLAC__StreamDecoder *,
// ----------------------------------------------------------------------
decoder_c::decoder_c() {
}
decoder_c::~decoder_c() {
}
void
decoder_c::flac_metadata_cb(const FLAC__StreamMetadata *) {
}
@ -341,21 +335,18 @@ decode_headers(unsigned char const *mem,
int type;
type = va_arg(ap, int);
switch (type) {
case FLAC_HEADER_STREAM_INFO: {
FLAC__StreamMetadata_StreamInfo *stream_info;
if (type != FLAC_HEADER_STREAM_INFO)
continue;
stream_info = va_arg(ap, FLAC__StreamMetadata_StreamInfo *);
if (result & FLAC_HEADER_STREAM_INFO)
memcpy(stream_info, &fhe.stream_info, sizeof(FLAC__StreamMetadata_StreamInfo));
FLAC__StreamMetadata_StreamInfo *stream_info;
break;
}
stream_info = va_arg(ap, FLAC__StreamMetadata_StreamInfo *);
if (result & FLAC_HEADER_STREAM_INFO)
memcpy(stream_info, &fhe.stream_info, sizeof(FLAC__StreamMetadata_StreamInfo));
default:
type = va_arg(ap, int);
}
break;
}
va_end(ap);
FLAC__stream_decoder_delete(decoder);

View File

@ -44,8 +44,8 @@ protected:
stream_decoder_uptr m_flac_decoder;
protected:
decoder_c();
virtual ~decoder_c();
decoder_c() = default;
virtual ~decoder_c() = default;
public:
virtual void flac_metadata_cb(const FLAC__StreamMetadata *metadata);

View File

@ -123,8 +123,8 @@ fourcc_c::str()
const {
char buffer[4];
put_uint32_be(buffer, m_value);
for (auto idx = 0; 4 > idx; ++idx)
buffer[idx] = 32 <= buffer[idx] ? buffer[idx] : '?';
for (auto &c : buffer)
c = 32 <= c ? c : '?';
return std::string{buffer, 4};
}

View File

@ -408,7 +408,7 @@ vui_parameters_copy(mtx::bits::reader_c &r,
w.copy_unsigned_golomb(r); // vui_num_ticks_poc_diff_one_minus1
}
if (w.copy_bits(1, r) == 1) { // vui_hrd_parameters_present_flag
hrd_parameters_copy(r, w, 1, max_sub_layers_minus1); // hrd_parameters
hrd_parameters_copy(r, w, true, max_sub_layers_minus1); // hrd_parameters
}
}

View File

@ -129,7 +129,7 @@ es_parser_c::add_bytes(unsigned char *buffer,
| (unsigned int)cursor.get_char() << 8
| (unsigned int)cursor.get_char();
while (1) {
while (true) {
if (NALU_START_CODE == marker)
marker_size = 4;
else if (NALU_START_CODE == (marker & 0x00ffffff))

View File

@ -46,10 +46,10 @@ hevcc_c::hevcc_c()
}
hevcc_c::hevcc_c(unsigned int nalu_size_length,
std::vector<memory_cptr> const &vps_list,
std::vector<memory_cptr> const &sps_list,
std::vector<memory_cptr> const &pps_list,
user_data_t const &user_data,
std::vector<memory_cptr> vps_list,
std::vector<memory_cptr> sps_list,
std::vector<memory_cptr> pps_list,
user_data_t user_data,
codec_private_t const &codec_private)
: m_configuration_version{}
, m_general_profile_space{}
@ -70,10 +70,10 @@ hevcc_c::hevcc_c(unsigned int nalu_size_length,
, m_temporal_id_nesting_flag{}
, m_size_nalu_minus_one{}
, m_nalu_size_length{nalu_size_length}
, m_vps_list{vps_list}
, m_sps_list{sps_list}
, m_pps_list{pps_list}
, m_user_data{user_data}
, m_vps_list{std::move(vps_list)}
, m_sps_list{std::move(sps_list)}
, m_pps_list{std::move(pps_list)}
, m_user_data{std::move(user_data)}
, m_codec_private{codec_private}
{
}

View File

@ -53,10 +53,10 @@ public:
public:
hevcc_c();
hevcc_c(unsigned int nalu_size_len,
std::vector<memory_cptr> const &vps_list,
std::vector<memory_cptr> const &sps_list,
std::vector<memory_cptr> const &pps_list,
user_data_t const &user_data,
std::vector<memory_cptr> vps_list,
std::vector<memory_cptr> sps_list,
std::vector<memory_cptr> pps_list,
user_data_t user_data,
codec_private_t const &codec_private);
explicit operator bool() const;

View File

@ -45,7 +45,7 @@ is_keyframe_vp9(memory_c const &buffer) {
auto profile = bc.get_bit() + (bc.get_bit() * 2);
if (3 == profile)
profile += bc.get_bit();
bc.get_bit(); // profile += …
if (bc.get_bit()) // show_existing_frame
return false;

View File

@ -13,7 +13,7 @@
#include "common/common_pch.h"
#include <locale.h>
#include <clocale>
#include "common/at_scope_exit.h"
#include "common/json.h"

View File

@ -200,7 +200,7 @@ kax_analyzer_c::verify_data_structures_against_file(const std::string &hook_name
bool row_is_identical = info_this.back() == info_actual.back();
ok &= row_is_identical;
info_markings.push_back(row_is_identical ? " " : "*");
info_markings.emplace_back(row_is_identical ? " " : "*");
}
if (ok)
@ -311,7 +311,7 @@ kax_analyzer_c::process_internal() {
l0 = nullptr;
}
while (1) {
while (true) {
// Next element must be a segment
l0 = m_stream->FindNextID(EBML_INFO(KaxSegment), 0xFFFFFFFFFFFFFFFFLL);
if (!l0)
@ -502,7 +502,7 @@ kax_analyzer_c::adjust_segment_size() {
if (!m_segment->IsFiniteSize())
return;
std::shared_ptr<KaxSegment> new_segment = std::shared_ptr<KaxSegment>(new KaxSegment);
auto new_segment = std::make_shared<KaxSegment>();
m_file->setFilePointer(m_segment->GetElementPosition());
new_segment->WriteHead(*m_file, m_segment->HeadSize() - 4);
@ -610,7 +610,7 @@ kax_analyzer_c::handle_void_elements(size_t data_idx) {
// the element's head can be moved up and false if we have to
// shrink it and fill the space with a new EBML void.
ebml_element_cptr e = read_element(m_data[data_idx + 1]);
auto e = read_element(m_data[data_idx + 1]);
if (!e) {
mxdebug_if(s_debug_void, fmt::format("handle_void_elements({0}): void_size == 1: could not read following element\n", data_idx));
@ -796,8 +796,8 @@ kax_analyzer_c::remove_from_meta_seeks(EbmlId id) {
// Read the element from the file. Remember its size so that a new
// EbmlVoid element can be constructed afterwards.
ebml_element_cptr element = read_element(data_idx);
KaxSeekHead *seek_head = dynamic_cast<KaxSeekHead *>(element.get());
auto element = read_element(data_idx);
auto seek_head = dynamic_cast<KaxSeekHead *>(element.get());
if (!seek_head)
throw uer_error_unknown;
@ -812,7 +812,7 @@ kax_analyzer_c::remove_from_meta_seeks(EbmlId id) {
continue;
}
KaxSeek *seek_entry = dynamic_cast<KaxSeek *>((*seek_head)[sh_idx]);
auto seek_entry = dynamic_cast<KaxSeek *>((*seek_head)[sh_idx]);
if (!seek_entry->IsEbmlId(id)) {
++sh_idx;
@ -1125,8 +1125,8 @@ kax_analyzer_c::try_adding_to_existing_meta_seek(EbmlElement *e) {
available_space += m_data[data_idx + 1]->m_size;
// Read the seek head, index the element and see how much space it needs.
ebml_element_cptr element = read_element(data_idx);
KaxSeekHead *seek_head = dynamic_cast<KaxSeekHead *>(element.get());
auto element = read_element(data_idx);
auto seek_head = dynamic_cast<KaxSeekHead *>(element.get());
if (!seek_head)
throw uer_error_unknown;
@ -1177,8 +1177,8 @@ void
kax_analyzer_c::move_seek_head_to_end_and_create_new_one_at_start(EbmlElement *e,
int first_seek_head_idx) {
// Read the first seek head…
ebml_element_cptr element = read_element(first_seek_head_idx);
KaxSeekHead *seek_head = dynamic_cast<KaxSeekHead *>(element.get());
auto element = read_element(first_seek_head_idx);
auto seek_head = dynamic_cast<KaxSeekHead *>(element.get());
if (!seek_head)
throw uer_error_unknown;
@ -1394,7 +1394,7 @@ kax_analyzer_c::read_all(const EbmlCallbacks &callbacks) {
if (!master)
master = ebml_master_cptr(static_cast<EbmlMaster *>(element));
else {
EbmlMaster *src = static_cast<EbmlMaster *>(element);
auto src = static_cast<EbmlMaster *>(element);
while (src->ListSize() > 0) {
master->PushElement(*(*src)[0]);
src->Remove(0);
@ -1447,8 +1447,8 @@ kax_analyzer_c::read_meta_seek(uint64_t pos,
return;
}
EbmlElement *l2 = nullptr;
EbmlMaster *master = static_cast<EbmlMaster *>(l1);
EbmlElement *l2 = nullptr;
auto master = static_cast<EbmlMaster *>(l1);
master->Read(*m_stream, EBML_CONTEXT(l1), upper_lvl_el, l2, true);
unsigned int i;
@ -1456,9 +1456,9 @@ kax_analyzer_c::read_meta_seek(uint64_t pos,
if (!Is<KaxSeek>((*master)[i]))
continue;
KaxSeek *seek = static_cast<KaxSeek *>((*master)[i]);
KaxSeekID *seek_id = FindChild<KaxSeekID>(seek);
int64_t seek_pos = seek->Location() + m_segment->GetElementPosition() + m_segment->HeadSize();
auto seek = static_cast<KaxSeek *>((*master)[i]);
auto seek_id = FindChild<KaxSeekID>(seek);
int64_t seek_pos = seek->Location() + m_segment->GetElementPosition() + m_segment->HeadSize();
if ((0 == pos) || !seek_id)
continue;
@ -1619,9 +1619,6 @@ console_kax_analyzer_c::console_kax_analyzer_c(std::string file_name)
{
}
console_kax_analyzer_c::~console_kax_analyzer_c() {
}
void
console_kax_analyzer_c::set_show_progress(bool show_progress) {
if (-1 == m_previous_percentage)

View File

@ -225,7 +225,7 @@ private:
public:
console_kax_analyzer_c(std::string file_name);
virtual ~console_kax_analyzer_c();
virtual ~console_kax_analyzer_c() = default;
virtual void set_show_progress(bool show_progress);

View File

@ -41,9 +41,6 @@ kax_file_c::kax_file_c(mm_io_c &in)
{
}
kax_file_c::~kax_file_c() {
}
std::shared_ptr<EbmlElement>
kax_file_c::read_next_level1_element(uint32_t wanted_id,
bool report_cluster_timestamp) {

View File

@ -32,7 +32,7 @@ protected:
public:
kax_file_c(mm_io_c &in);
virtual ~kax_file_c();
virtual ~kax_file_c() = default;
virtual bool was_resynced() const;
virtual int64_t get_resync_start_pos() const;

View File

@ -88,9 +88,6 @@ using namespace mtx::kax_info;
namespace mtx {
kax_info::private_c::~private_c() {
}
kax_info_c::kax_info_c()
: p_ptr{new kax_info::private_c}
{
@ -103,7 +100,7 @@ kax_info_c::kax_info_c(kax_info::private_c &p)
init();
}
kax_info_c::~kax_info_c() {
kax_info_c::~kax_info_c() { // NOLINT(modernize-use-equals-default) due to pimpl idiom requiring explicit dtor declaration somewhere
}
void
@ -360,7 +357,7 @@ kax_info_c::create_codec_dependent_private_info(KaxCodecPrivate &c_priv,
return fmt::format(Y(" (FourCC: {0})"), fourcc_c{&bih->bi_compression}.description());
} else if ((codec_id == MKV_A_ACM) && ('a' == track_type) && (c_priv.GetSize() >= sizeof(alWAVEFORMATEX))) {
alWAVEFORMATEX *wfe = reinterpret_cast<alWAVEFORMATEX *>(c_priv.GetBuffer());
auto wfe = reinterpret_cast<alWAVEFORMATEX *>(c_priv.GetBuffer());
return fmt::format(Y(" (format tag: 0x{0:04x})"), get_uint16_le(&wfe->w_format_tag));
} else if ((codec_id == MKV_V_MPEG4_AVC) && ('v' == track_type) && (c_priv.GetSize() >= 4)) {
@ -714,13 +711,13 @@ kax_info_c::init_custom_element_value_formatters_and_processors() {
auto ce_scope = static_cast<KaxContentEncodingScope &>(e).GetValue();
if ((ce_scope & 0x01) == 0x01)
scope.push_back(Y("1: all frames"));
scope.emplace_back(Y("1: all frames"));
if ((ce_scope & 0x02) == 0x02)
scope.push_back(Y("2: codec private data"));
scope.emplace_back(Y("2: codec private data"));
if ((ce_scope & 0xfc) != 0x00)
scope.push_back(Y("rest: unknown"));
scope.emplace_back(Y("rest: unknown"));
if (scope.empty())
scope.push_back(Y("unknown"));
scope.emplace_back(Y("unknown"));
return fmt::format("{0} ({1})", ce_scope, boost::join(scope, ", "));
});
@ -1196,7 +1193,7 @@ kax_info_c::process_file() {
handle_elements_generic(*l0);
l0->SkipData(*p->m_es, EBML_CONTEXT(l0));
while (1) {
while (true) {
// NEXT element must be a segment
l0 = ebml_element_cptr{ p->m_es->FindNextID(EBML_INFO(KaxSegment), 0xFFFFFFFFFFFFFFFFLL) };
if (!l0)

View File

@ -63,7 +63,7 @@ public:
public:
private_c() = default;
~private_c();
~private_c() = default;
};
}}

View File

@ -13,13 +13,13 @@
#include "common/common_pch.h"
#include <errno.h>
#include <cerrno>
#include <clocale>
#if HAVE_NL_LANGINFO
# include <langinfo.h>
#elif HAVE_LOCALE_CHARSET
# include <libcharset.h>
#endif
#include <locale.h>
#if defined(SYS_WINDOWS)
# include <windows.h>
#endif
@ -39,20 +39,11 @@ charset_converter_cptr g_cc_local_utf8;
std::map<std::string, charset_converter_cptr> charset_converter_c::s_converters;
charset_converter_c::charset_converter_c()
: m_detect_byte_order_marker(false)
charset_converter_c::charset_converter_c(std::string charset)
: m_charset{std::move(charset)}
{
}
charset_converter_c::charset_converter_c(const std::string &charset)
: m_charset(charset)
, m_detect_byte_order_marker(false)
{
}
charset_converter_c::~charset_converter_c() {
}
std::string
charset_converter_c::utf8(const std::string &source) {
return source;
@ -74,7 +65,7 @@ charset_converter_c::init(const std::string &charset,
bool ignore_errors) {
std::string actual_charset = charset.empty() ? get_local_charset() : charset;
std::map<std::string, charset_converter_cptr>::iterator converter = s_converters.find(actual_charset);
auto converter = s_converters.find(actual_charset);
if (converter != s_converters.end())
return (*converter).second;
@ -177,7 +168,7 @@ iconv_charset_converter_c::convert(iconv_t handle,
char *destination = (char *)safemalloc(length + 1);
memset(destination, 0, length + 1);
iconv(handle, nullptr, 0, nullptr, 0); // Reset the iconv state.
iconv(handle, nullptr, nullptr, nullptr, nullptr); // Reset the iconv state.
size_t length_source = length / 4;
size_t length_destination = length;

View File

@ -23,12 +23,12 @@ using charset_converter_cptr = std::shared_ptr<charset_converter_c>;
class charset_converter_c {
protected:
std::string m_charset;
bool m_detect_byte_order_marker;
bool m_detect_byte_order_marker{};
public:
charset_converter_c();
charset_converter_c(const std::string &charset);
virtual ~charset_converter_c();
charset_converter_c() = default;
charset_converter_c(std::string charset);
virtual ~charset_converter_c() = default;
virtual std::string utf8(const std::string &source);
virtual std::string native(const std::string &source);

View File

@ -36,9 +36,6 @@ target_c::target_c()
{
}
target_c::~target_c() {
}
std::string
target_c::format_line(std::string const &message) {
auto now = std::chrono::system_clock::now();
@ -102,9 +99,9 @@ target_c::runtime() {
// ----------------------------------------------------------------------
file_target_c::file_target_c(bfs::path const &file_name)
file_target_c::file_target_c(bfs::path file_name)
: target_c() // Don't use initializer-list syntax due to a bug in gcc < 4.8
, m_file_name{file_name}
, m_file_name{std::move(file_name)}
{
if (!m_file_name.is_absolute())
m_file_name = bfs::temp_directory_path() / m_file_name;
@ -115,9 +112,6 @@ file_target_c::file_target_c(bfs::path const &file_name)
}
}
file_target_c::~file_target_c() {
}
void
file_target_c::log_line(std::string const &message) {
try {
@ -135,9 +129,6 @@ stderr_target_c::stderr_target_c()
{
}
stderr_target_c::~stderr_target_c() {
}
void
stderr_target_c::log_line(std::string const &message) {
std::cerr << message;

View File

@ -25,7 +25,7 @@ private:
public:
target_c();
virtual ~target_c();
virtual ~target_c() = default;
void log(std::string const &message) {
log_line(message);
@ -48,8 +48,8 @@ private:
bfs::path m_file_name;
public:
file_target_c(bfs::path const &file_name);
virtual ~file_target_c();
file_target_c(bfs::path file_name);
virtual ~file_target_c() = default;
protected:
virtual void log_line(std::string const &message) override;
@ -58,7 +58,7 @@ protected:
class stderr_target_c: public target_c {
public:
stderr_target_c();
virtual ~stderr_target_c();
virtual ~stderr_target_c() = default;
protected:
virtual void log_line(std::string const &message) override;

View File

@ -18,7 +18,7 @@
void
memory_c::resize(size_t new_size)
throw()
noexcept
{
if (new_size == m_size)
return;
@ -145,10 +145,10 @@ _safememdup(const void *s,
if (!s)
return nullptr;
unsigned char *copy = reinterpret_cast<unsigned char *>(malloc(size));
auto copy = reinterpret_cast<unsigned char *>(malloc(size));
if (!copy)
mxerror(fmt::format(Y("memory.cpp/safememdup() called from file {0}, line {1}: malloc() returned nullptr for a size of {2} bytes.\n"), file, line, size));
memcpy(copy, s, size);
memcpy(copy, s, size); // NOLINT(clang-analyzer-core.NonNullParamChecker) as mxerror() terminates the program
return copy;
}
@ -157,7 +157,7 @@ unsigned char *
_safemalloc(size_t size,
const char *file,
int line) {
unsigned char *mem = reinterpret_cast<unsigned char *>(malloc(size));
auto mem = reinterpret_cast<unsigned char *>(malloc(size));
if (!mem)
mxerror(fmt::format(Y("memory.cpp/safemalloc() called from file {0}, line {1}: malloc() returned nullptr for a size of {2} bytes.\n"), file, line, size));

View File

@ -149,7 +149,7 @@ public:
m_is_owned = false;
}
void resize(std::size_t new_size) throw();
void resize(std::size_t new_size) noexcept;
void add(unsigned char const *new_buffer, std::size_t new_size);
void add(memory_c const &new_buffer) {
add(new_buffer.get_buffer(), new_buffer.get_size());

View File

@ -42,7 +42,7 @@ mm_io_c::mm_io_c(mm_io_private_c &p)
{
}
mm_io_c::~mm_io_c() {
mm_io_c::~mm_io_c() { // NOLINT(modernize-use-equals-default) due to pimpl idiom requiring explicit dtor declaration somewhere
}
std::string

View File

@ -26,15 +26,15 @@ namespace mtx { namespace mm_io {
std::error_code
make_error_code() {
#ifdef SYS_WINDOWS
return std::error_code(::GetLastError(), std::system_category());
return { static_cast<int>(::GetLastError()), std::system_category() };
#else
return std::error_code(errno, std::generic_category());
return { errno, std::generic_category() };
#endif
}
std::string
exception::error()
const throw() {
const noexcept {
return std::errc::no_such_file_or_directory == code() ? Y("The file or directory was not found")
: std::errc::no_space_on_device == code() ? Y("No space left to write to")
: std::errc::permission_denied == code() ? Y("No permission to read from, to write to or to create")

View File

@ -32,7 +32,7 @@ public:
{
}
virtual const char *what() const throw() {
virtual const char *what() const noexcept {
return "unspecified I/O error";
}
@ -40,14 +40,14 @@ public:
return m_error_code;
}
virtual std::string error() const throw();
virtual std::string error() const noexcept;
};
class end_of_file_x: public exception {
public:
end_of_file_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "end of file error";
}
};
@ -56,7 +56,7 @@ class seek_x: public exception {
public:
seek_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "seek in file error";
}
};
@ -65,7 +65,7 @@ class read_write_x: public exception {
public:
read_write_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "reading from/writing to the file error";
}
};
@ -74,7 +74,7 @@ class open_x: public exception {
public:
open_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "open file error";
}
};
@ -83,7 +83,7 @@ class wrong_read_write_access_x: public exception {
public:
wrong_read_write_access_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "write operation to read-only file or vice versa";
}
};
@ -92,7 +92,7 @@ class insufficient_space_x: public exception {
public:
insufficient_space_x(std::error_code const &error_code = std::error_code()) : exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "insufficient space for write operation";
}
};
@ -108,12 +108,12 @@ public:
{
}
virtual ~create_directory_x() throw() { }
virtual ~create_directory_x() noexcept { }
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "create_directory() failed";
}
virtual std::string error() const throw() {
virtual std::string error() const noexcept {
return fmt::format(Y("Creating directory '{0}' failed: {1}"), m_path, code().message());
}
};
@ -123,7 +123,7 @@ class exception: public mtx::mm_io::exception {
public:
exception(std::error_code const &error_code = std::error_code()) : mtx::mm_io::exception(error_code) {}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "unspecified text I/O error";
}
};
@ -138,11 +138,11 @@ public:
{
}
virtual char const *what() const throw() {
virtual char const *what() const noexcept {
return "invalid UTF-8 char";
}
virtual std::string error() const throw() {
virtual std::string error() const noexcept {
return fmt::format(Y("Invalid UTF-8 char. First byte: 0x{0:02x}"), static_cast<unsigned int>(m_first_char));
}
};

View File

@ -45,7 +45,7 @@ mm_mem_io_c::mm_mem_io_c(mm_mem_io_private_c &p)
}
mm_mem_io_c::~mm_mem_io_c() {
close();
close_mem_io();
}
uint64
@ -120,6 +120,11 @@ mm_mem_io_c::_write(const void *buffer,
void
mm_mem_io_c::close() {
close_mem_io();
}
void
mm_mem_io_c::close_mem_io() {
auto p = p_func();
if (p->free_mem)

View File

@ -43,4 +43,5 @@ public:
protected:
virtual uint32 _read(void *buffer, size_t size);
virtual size_t _write(const void *buffer, size_t size);
void close_mem_io();
};

View File

@ -26,7 +26,7 @@ mm_mpls_multi_file_io_c::mm_mpls_multi_file_io_c(mm_mpls_multi_file_io_private_c
{
}
mm_mpls_multi_file_io_c::~mm_mpls_multi_file_io_c() {
mm_mpls_multi_file_io_c::~mm_mpls_multi_file_io_c() { // NOLINT(modernize-use-equals-default) due to pimpl idiom requiring explicit dtor declaration somewhere
}
std::vector<timestamp_c> const &

View File

@ -36,7 +36,7 @@ mm_multi_file_io_c::mm_multi_file_io_c(mm_multi_file_io_private_c &p)
}
mm_multi_file_io_c::~mm_multi_file_io_c() {
close();
close_multi_file_io();
}
uint64
@ -74,10 +74,10 @@ mm_multi_file_io_c::setFilePointer(int64 offset,
uint32
mm_multi_file_io_c::_read(void *buffer,
size_t size) {
auto p = p_func();
auto p = p_func();
size_t num_read_total = 0;
unsigned char *buffer_ptr = static_cast<unsigned char *>(buffer);
size_t num_read_total = 0;
auto buffer_ptr = static_cast<unsigned char *>(buffer);
while (!eof() && (num_read_total < size)) {
auto &file = p->files[p->current_file];
@ -112,6 +112,11 @@ mm_multi_file_io_c::_write(const void *,
void
mm_multi_file_io_c::close() {
close_multi_file_io();
}
void
mm_multi_file_io_c::close_multi_file_io() {
auto p = p_func();
for (auto &file : p->files)

View File

@ -48,4 +48,6 @@ public:
protected:
virtual uint32 _read(void *buffer, size_t size);
virtual size_t _write(const void *buffer, size_t size);
void close_multi_file_io();
};

View File

@ -33,7 +33,7 @@ mm_proxy_io_c::mm_proxy_io_c(mm_proxy_io_private_c &p)
}
mm_proxy_io_c::~mm_proxy_io_c() {
close();
close_proxy_io();
}
void
@ -71,6 +71,11 @@ mm_proxy_io_c::get_proxied()
void
mm_proxy_io_c::close() {
close_proxy_io();
}
void
mm_proxy_io_c::close_proxy_io() {
p_func()->proxy_io.reset();
}

View File

@ -37,4 +37,6 @@ public:
protected:
virtual uint32 _read(void *buffer, size_t size);
virtual size_t _write(const void *buffer, size_t size);
void close_proxy_io();
};

View File

@ -27,13 +27,11 @@ mm_read_buffer_io_c::mm_read_buffer_io_c(mm_io_cptr const &in,
std::size_t buffer_size)
: mm_proxy_io_c{*new mm_read_buffer_io_private_c{in, buffer_size}}
{
setFilePointer(in->getFilePointer());
}
mm_read_buffer_io_c::mm_read_buffer_io_c(mm_read_buffer_io_private_c &p)
: mm_proxy_io_c{p}
{
setFilePointer(p.proxy_io->getFilePointer());
}
mm_read_buffer_io_c::~mm_read_buffer_io_c() {

View File

@ -32,6 +32,7 @@ public:
: mm_proxy_io_private_c{proxy_io}
, af_buffer{memory_c::alloc(buffer_size)}
, buffer{af_buffer->get_buffer()}
, offset{static_cast<int64_t>(proxy_io->getFilePointer())}
{
}
};

View File

@ -21,9 +21,6 @@
Class for reading from stdin & writing to stdout.
*/
mm_stdio_c::mm_stdio_c() {
}
uint64
mm_stdio_c::getFilePointer() {
return 0;

View File

@ -17,7 +17,7 @@
class mm_stdio_c: public mm_io_c {
public:
mm_stdio_c();
mm_stdio_c() = default;
virtual uint64 getFilePointer();
virtual void setFilePointer(int64 offset, libebml::seek_mode mode=libebml::seek_beginning);

View File

@ -64,7 +64,7 @@ mm_text_io_c::detect_eol_style() {
auto num_chars_read = 0u;
while (1) {
while (true) {
auto utf8char = read_next_codepoint();
auto len = utf8char.length();
@ -228,7 +228,7 @@ mm_text_io_c::getline(boost::optional<std::size_t> max_chars) {
bool previous_was_carriage_return = false;
std::size_t num_chars_read{};
while (1) {
while (true) {
auto previous_pos = getFilePointer();
auto utf8char = read_next_codepoint();
auto len = utf8char.length();

View File

@ -36,7 +36,7 @@ mm_write_buffer_io_c::mm_write_buffer_io_c(mm_write_buffer_io_private_c &p)
}
mm_write_buffer_io_c::~mm_write_buffer_io_c() {
close();
close_write_buffer_io();
}
mm_io_cptr
@ -79,6 +79,11 @@ mm_write_buffer_io_c::flush() {
void
mm_write_buffer_io_c::close() {
close_write_buffer_io();
}
void
mm_write_buffer_io_c::close_write_buffer_io() {
flush_buffer();
mm_proxy_io_c::close();
}

View File

@ -40,5 +40,6 @@ public:
protected:
virtual uint32 _read(void *buffer, size_t size);
virtual size_t _write(const void *buffer, size_t size);
virtual void flush_buffer();
void flush_buffer();
void close_write_buffer_io();
};

View File

@ -300,8 +300,7 @@ find_consecutive_mp3_headers(const unsigned char *buf,
return base;
}
base++;
offset = 0;
pos = find_mp3_header(&buf[base], size - base);
pos = find_mp3_header(&buf[base], size - base);
if (pos == -1)
return -1;
decode_mp3_header(&buf[base + pos], &mp3header);

View File

@ -185,9 +185,6 @@ parser_c::parser_c()
{
}
parser_c::~parser_c() {
}
void
parser_c::enable_dropping_last_entry_if_at_end(bool enable) {
m_drop_last_entry_if_at_end = enable;

View File

@ -153,7 +153,7 @@ protected:
public:
parser_c();
virtual ~parser_c();
virtual ~parser_c() = default;
virtual bool parse(mm_io_c &in);
virtual bool is_ok() const {

View File

@ -35,7 +35,7 @@ bool g_warning_issued = false;
std::string g_stdio_charset;
static bool s_mm_stdio_redirected = false;
charset_converter_cptr g_cc_stdio = charset_converter_cptr(new charset_converter_c);
charset_converter_cptr g_cc_stdio = std::make_shared<charset_converter_c>();
std::shared_ptr<mm_io_c> g_mm_stdio = std::shared_ptr<mm_io_c>(new mm_stdio_c);
static mxmsg_handler_t s_mxmsg_info_handler, s_mxmsg_warning_handler, s_mxmsg_error_handler;

View File

@ -38,16 +38,16 @@ using namespace libmatroska;
std::map<uint32_t, std::vector<property_element_c> > property_element_c::s_properties;
std::map<uint32_t, std::vector<property_element_c> > property_element_c::s_composed_properties;
property_element_c::property_element_c(std::string const &name,
property_element_c::property_element_c(std::string name,
EbmlCallbacks const &callbacks,
translatable_string_c const &title,
translatable_string_c const &description,
translatable_string_c title,
translatable_string_c description,
EbmlCallbacks const &sub_master_callbacks,
EbmlCallbacks const *sub_sub_master_callbacks,
EbmlCallbacks const *sub_sub_sub_master_callbacks)
: m_name{name}
, m_title{title}
, m_description{description}
: m_name{std::move(name)}
, m_title{std::move(title)}
, m_description{std::move(description)}
, m_callbacks{&callbacks}
, m_sub_master_callbacks{&sub_master_callbacks}
, m_sub_sub_master_callbacks{sub_sub_master_callbacks}
@ -222,15 +222,15 @@ property_element_c::get_table_for(const EbmlCallbacks &master_callbacks,
if (s_properties.empty())
init_tables();
std::map<uint32_t, std::vector<property_element_c> >::iterator src_map_it = s_properties.find(master_callbacks.GlobalId.Value);
auto src_map_it = s_properties.find(master_callbacks.GlobalId.Value);
if (s_properties.end() == src_map_it)
mxerror(fmt::format("property_element_c::get_table_for(): programming error: no table found for EBML ID {0:08x}\n", master_callbacks.GlobalId.Value));
if (full_table)
return src_map_it->second;
uint32_t element_id = !sub_master_callbacks ? master_callbacks.GlobalId.Value : sub_master_callbacks->GlobalId.Value;
std::map<uint32_t, std::vector<property_element_c> >::iterator composed_map_it = s_composed_properties.find(element_id);
uint32_t element_id = !sub_master_callbacks ? master_callbacks.GlobalId.Value : sub_master_callbacks->GlobalId.Value;
auto composed_map_it = s_composed_properties.find(element_id);
if (s_composed_properties.end() != composed_map_it)
return composed_map_it->second;

View File

@ -40,7 +40,7 @@ public:
ebml_type_e m_type;
property_element_c();
property_element_c(std::string const &name, EbmlCallbacks const &callbacks, translatable_string_c const &title, translatable_string_c const &description,
property_element_c(std::string name, EbmlCallbacks const &callbacks, translatable_string_c title, translatable_string_c description,
EbmlCallbacks const &sub_master_callbacks, EbmlCallbacks const *sub_sub_master_callbacks = nullptr, EbmlCallbacks const *sub_sub_sub_master_callbacks = nullptr);
bool is_valid() const;

View File

@ -28,9 +28,6 @@ QtKaxAnalyzer::QtKaxAnalyzer(QWidget *parent,
{
}
QtKaxAnalyzer::~QtKaxAnalyzer() {
}
void
QtKaxAnalyzer::show_progress_start(int64_t size) {
m_size = size;

View File

@ -29,7 +29,7 @@ private:
public:
QtKaxAnalyzer(QWidget *parent, QString const &fileName);
virtual ~QtKaxAnalyzer();
virtual ~QtKaxAnalyzer() = default;
virtual void show_progress_start(int64_t size) override;
virtual bool show_progress_running(int percentage) override;

View File

@ -79,7 +79,7 @@ parse_split_parts(const std::string &arg,
throw format_x{fmt::format(Y("Invalid start time for '--split' in '--split {0}' (current part: {1}). The start time must be bigger than or equal to the previous part's end time.\n"), arg, part_spec)};
}
requested_split_points.push_back(std::make_tuple(start, end, create_new_file));
requested_split_points.emplace_back(start, end, create_new_file);
}
std::vector<split_point_c> split_points;
@ -88,13 +88,13 @@ parse_split_parts(const std::string &arg,
for (auto &split_point : requested_split_points) {
if (previous_end < std::get<0>(split_point))
split_points.push_back(split_point_c{ previous_end, sp_type, true, true, std::get<2>(split_point) });
split_points.push_back(split_point_c{ std::get<0>(split_point), sp_type, true, false, std::get<2>(split_point) });
split_points.emplace_back(previous_end, sp_type, true, true, std::get<2>(split_point));
split_points.emplace_back(std::get<0>(split_point), sp_type, true, false, std::get<2>(split_point));
previous_end = std::get<1>(split_point);
}
if (std::get<1>(requested_split_points.back()) < std::numeric_limits<int64_t>::max())
split_points.push_back(split_point_c{ std::get<1>(requested_split_points.back()), sp_type, true, true });
split_points.emplace_back(std::get<1>(requested_split_points.back()), sp_type, true, true);
return split_points;
}

View File

@ -24,21 +24,21 @@ std::vector<translatable_string_c> stereo_mode_c::s_translations;
void
stereo_mode_c::init() {
s_modes.push_back("mono");
s_modes.push_back("side_by_side_left_first");
s_modes.push_back("top_bottom_right_first");
s_modes.push_back("top_bottom_left_first");
s_modes.push_back("checkerboard_right_first");
s_modes.push_back("checkerboard_left_first");
s_modes.push_back("row_interleaved_right_first");
s_modes.push_back("row_interleaved_left_first");
s_modes.push_back("column_interleaved_right_first");
s_modes.push_back("column_interleaved_left_first");
s_modes.push_back("anaglyph_cyan_red");
s_modes.push_back("side_by_side_right_first");
s_modes.push_back("anaglyph_green_magenta");
s_modes.push_back("both_eyes_laced_left_first");
s_modes.push_back("both_eyes_laced_right_first");
s_modes.emplace_back("mono");
s_modes.emplace_back("side_by_side_left_first");
s_modes.emplace_back("top_bottom_right_first");
s_modes.emplace_back("top_bottom_left_first");
s_modes.emplace_back("checkerboard_right_first");
s_modes.emplace_back("checkerboard_left_first");
s_modes.emplace_back("row_interleaved_right_first");
s_modes.emplace_back("row_interleaved_left_first");
s_modes.emplace_back("column_interleaved_right_first");
s_modes.emplace_back("column_interleaved_left_first");
s_modes.emplace_back("anaglyph_cyan_red");
s_modes.emplace_back("side_by_side_right_first");
s_modes.emplace_back("anaglyph_green_magenta");
s_modes.emplace_back("both_eyes_laced_left_first");
s_modes.emplace_back("both_eyes_laced_right_first");
}
void
@ -46,21 +46,21 @@ stereo_mode_c::init_translations() {
if (!s_translations.empty())
return;
s_translations.push_back(YT("mono"));
s_translations.push_back(YT("side by side (left first)"));
s_translations.push_back(YT("top bottom (right first)"));
s_translations.push_back(YT("top bottom (left first)"));
s_translations.push_back(YT("checkerboard (right first)"));
s_translations.push_back(YT("checkerboard (left first)"));
s_translations.push_back(YT("row interleaved (right first)"));
s_translations.push_back(YT("row interleaved (left first)"));
s_translations.push_back(YT("column interleaved (right first)"));
s_translations.push_back(YT("column interleaved (left first)"));
s_translations.push_back(YT("anaglyph (cyan/red)"));
s_translations.push_back(YT("side by side (right first)"));
s_translations.push_back(YT("anaglyph (green/magenta)"));
s_translations.push_back(YT("both eyes laced in one block (left first)"));
s_translations.push_back(YT("both eyes laced in one block (right first)"));
s_translations.emplace_back(YT("mono"));
s_translations.emplace_back(YT("side by side (left first)"));
s_translations.emplace_back(YT("top bottom (right first)"));
s_translations.emplace_back(YT("top bottom (left first)"));
s_translations.emplace_back(YT("checkerboard (right first)"));
s_translations.emplace_back(YT("checkerboard (left first)"));
s_translations.emplace_back(YT("row interleaved (right first)"));
s_translations.emplace_back(YT("row interleaved (left first)"));
s_translations.emplace_back(YT("column interleaved (right first)"));
s_translations.emplace_back(YT("column interleaved (left first)"));
s_translations.emplace_back(YT("anaglyph (cyan/red)"));
s_translations.emplace_back(YT("side by side (right first)"));
s_translations.emplace_back(YT("anaglyph (green/magenta)"));
s_translations.emplace_back(YT("both eyes laced in one block (left first)"));
s_translations.emplace_back(YT("both eyes laced in one block (right first)"));
}
const std::string

View File

@ -13,14 +13,14 @@
#include "common/common_pch.h"
#include <clocale>
#include <cstdlib>
#if HAVE_NL_LANGINFO
# include <langinfo.h>
#elif HAVE_LOCALE_CHARSET
# include <libcharset.h>
#endif
#include <locale>
#include <locale.h>
#include <stdlib.h>
#include "common/fs_sys_helpers.h"
#include "common/locale_string.h"
@ -38,21 +38,21 @@
std::vector<translation_c> translation_c::ms_available_translations;
int translation_c::ms_active_translation_idx = 0;
translation_c::translation_c(std::string const &iso639_2_code,
std::string const &unix_locale,
std::string const &windows_locale,
std::string const &windows_locale_sysname,
std::string const &english_name,
std::string const &translated_name,
translation_c::translation_c(std::string iso639_2_code,
std::string unix_locale,
std::string windows_locale,
std::string windows_locale_sysname,
std::string english_name,
std::string translated_name,
bool line_breaks_anywhere,
int language_id,
int sub_language_id)
: m_iso639_2_code{iso639_2_code}
, m_unix_locale{unix_locale}
, m_windows_locale{windows_locale}
, m_windows_locale_sysname{windows_locale_sysname}
, m_english_name{english_name}
, m_translated_name{translated_name}
: m_iso639_2_code{std::move(iso639_2_code)}
, m_unix_locale{std::move(unix_locale)}
, m_windows_locale{std::move(windows_locale)}
, m_windows_locale_sysname{std::move(windows_locale_sysname)}
, m_english_name{std::move(english_name)}
, m_translated_name{std::move(translated_name)}
, m_line_breaks_anywhere{line_breaks_anywhere}
, m_language_id{language_id}
, m_sub_language_id{sub_language_id}
@ -218,10 +218,6 @@ translation_c::set_active_translation(const std::string &locale) {
// ------------------------------------------------------------
translatable_string_c::translatable_string_c()
{
}
translatable_string_c::translatable_string_c(const std::string &untranslated_string)
: m_untranslated_strings{untranslated_string}
{

View File

@ -27,12 +27,12 @@ public:
bool m_line_breaks_anywhere;
int m_language_id, m_sub_language_id;
translation_c(std::string const &iso639_2_code,
std::string const &unix_locale,
std::string const &windows_locale,
std::string const &windows_locale_sysname,
std::string const &english_name,
std::string const &translated_name,
translation_c(std::string iso639_2_code,
std::string unix_locale,
std::string windows_locale,
std::string windows_locale_sysname,
std::string english_name,
std::string translated_name,
bool line_breaks_anywhere,
int language_id,
int sub_language_id);
@ -54,7 +54,7 @@ protected:
boost::optional<std::string> m_overridden_by;
public:
translatable_string_c();
translatable_string_c() = default;
translatable_string_c(const std::string &untranslated_string);
translatable_string_c(const char *untranslated_string);
translatable_string_c(std::vector<translatable_string_c> const &untranslated_strings);

View File

@ -176,15 +176,6 @@ frame_t::decode_channel_map(int channel_map) {
// ----------------------------------------------------------------------
parser_c::parser_c()
: m_sync_state(state_unsynced)
{
}
parser_c::~parser_c()
{
}
void
parser_c::add_data(unsigned char const *new_data,
unsigned int new_size) {

View File

@ -101,15 +101,15 @@ protected:
enum {
state_unsynced,
state_synced,
} m_sync_state;
} m_sync_state{state_unsynced};
mtx::bytes::buffer_c m_buffer;
std::deque<frame_cptr> m_frames;
frame_t::codec_e m_sync_codec{frame_t::truehd};
public:
parser_c();
virtual ~parser_c();
parser_c() = default;
virtual ~parser_c() = default;
virtual void add_data(const unsigned char *new_data, unsigned int new_size);
virtual void parse(bool end_of_stream = false);

View File

@ -296,9 +296,6 @@ es_parser_c::es_parser_c()
{
}
es_parser_c::~es_parser_c() {
}
void
es_parser_c::add_bytes(unsigned char *buffer,
int size) {
@ -314,7 +311,7 @@ es_parser_c::add_bytes(unsigned char *buffer,
if (3 <= cursor.get_remaining_size()) {
uint32_t marker = (1 << 24) | ((unsigned int)cursor.get_char() << 16) | ((unsigned int)cursor.get_char() << 8) | (unsigned int)cursor.get_char();
while (1) {
while (true) {
if (is_marker(marker)) {
if (-1 != previous_pos) {
int new_size = cursor.get_position() - 4 - previous_pos;

View File

@ -175,7 +175,7 @@ protected:
public:
es_parser_c();
virtual ~es_parser_c();
virtual ~es_parser_c() = default;
virtual void add_bytes(unsigned char *buf, int size);
virtual void add_bytes(memory_cptr &buf) {

View File

@ -24,10 +24,6 @@
#define VERSIONNAME "Like It Or Not"
version_number_t::version_number_t()
{
}
version_number_t::version_number_t(const std::string &s)
: valid{}
{
@ -114,10 +110,10 @@ version_number_t::to_string()
std::string v;
for (auto idx = 0u; idx < parts.size(); ++idx) {
for (auto const &part : parts) {
if (!v.empty())
v += ".";
v += ::to_string(parts[idx]);
v += ::to_string(part);
}
if (0 != build)

View File

@ -29,7 +29,7 @@ struct version_number_t {
unsigned int build{};
bool valid{};
version_number_t();
version_number_t() = default;
version_number_t(const std::string &s);
bool operator <(const version_number_t &cmp) const;

View File

@ -34,7 +34,7 @@ wavpack_meta_t::wavpack_meta_t()
static void
little_endian_to_native(void *data,
const char *format) {
uint8_t *cp = (uint8_t *)data;
auto cp = static_cast<uint8_t *>(data);
uint32_t temp;
while (*format) {
@ -70,7 +70,7 @@ read_next_header(mm_io_c &in,
uint32_t bytes_skipped = 0;
int bleft;
while (1) {
while (true) {
if (sp < ep) {
bleft = ep - sp;
memmove(buffer, sp, bleft);
@ -165,4 +165,3 @@ wv_parse_frame(mm_io_c &in,
return wphdr.ck_size - sizeof(wavpack_header_t) + 8;
}

View File

@ -35,7 +35,7 @@ webvtt_parser_c::webvtt_parser_c()
{
}
webvtt_parser_c::~webvtt_parser_c() {
webvtt_parser_c::~webvtt_parser_c() { // NOLINT(modernize-use-equals-default) due to pimpl idiom requiring explicit dtor declaration somewhere
}
void