constexpr/std::array conversions
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
46600931e4
commit
30e3ef4c8e
@ -27,7 +27,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
static const char *const idle_names[] = {
|
||||
static constexpr const char * idle_names[] = {
|
||||
"database",
|
||||
"stored_playlist",
|
||||
"playlist",
|
||||
@ -42,7 +42,7 @@ static const char *const idle_names[] = {
|
||||
"neighbor",
|
||||
"mount",
|
||||
"partition",
|
||||
nullptr
|
||||
nullptr,
|
||||
};
|
||||
|
||||
const char*const*
|
||||
|
@ -180,7 +180,7 @@ Bzip2InputStream::IsEOF() const noexcept
|
||||
|
||||
/* exported structures */
|
||||
|
||||
static const char *const bz2_extensions[] = {
|
||||
static constexpr const char *bz2_extensions[] = {
|
||||
"bz2",
|
||||
nullptr
|
||||
};
|
||||
|
@ -319,7 +319,7 @@ Iso9660InputStream::IsEOF() const noexcept
|
||||
|
||||
/* exported structures */
|
||||
|
||||
static const char *const iso9660_archive_extensions[] = {
|
||||
static constexpr const char * iso9660_archive_extensions[] = {
|
||||
"iso",
|
||||
nullptr
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ ZzipInputStream::Seek(std::unique_lock<Mutex> &, offset_type new_offset)
|
||||
|
||||
/* exported structures */
|
||||
|
||||
static const char *const zzip_archive_extensions[] = {
|
||||
static constexpr const char *zzip_archive_extensions[] = {
|
||||
"zip",
|
||||
nullptr
|
||||
};
|
||||
|
@ -156,14 +156,14 @@ handle_read_comments(Client &client, Request args, Response &r)
|
||||
static InputStreamPtr
|
||||
find_stream_art(std::string_view directory, Mutex &mutex)
|
||||
{
|
||||
static constexpr char const * art_names[] = {
|
||||
static constexpr auto art_names = std::array {
|
||||
"cover.png",
|
||||
"cover.jpg",
|
||||
"cover.tiff",
|
||||
"cover.bmp"
|
||||
"cover.bmp",
|
||||
};
|
||||
|
||||
for(const auto name: art_names) {
|
||||
for(const auto name : art_names) {
|
||||
std::string art_file = PathTraitsUTF8::Build(directory, name);
|
||||
|
||||
try {
|
||||
|
@ -632,12 +632,12 @@ wavpack_scan_stream(InputStream &is, TagHandler &handler)
|
||||
return true;
|
||||
}
|
||||
|
||||
static char const *const wavpack_suffixes[] = {
|
||||
static constexpr const char *wavpack_suffixes[] = {
|
||||
"wv",
|
||||
nullptr
|
||||
};
|
||||
|
||||
static char const *const wavpack_mime_types[] = {
|
||||
static constexpr const char *wavpack_mime_types[] = {
|
||||
"audio/x-wavpack",
|
||||
nullptr
|
||||
};
|
||||
|
@ -98,7 +98,7 @@ flac_playlist_open_stream(InputStreamPtr &&is)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char *const flac_playlist_suffixes[] = {
|
||||
static constexpr const char *flac_playlist_suffixes[] = {
|
||||
"flac",
|
||||
nullptr
|
||||
};
|
||||
|
@ -162,12 +162,12 @@ pls_open_stream(InputStreamPtr &&is)
|
||||
return std::make_unique<MemorySongEnumerator>(std::move(songs));
|
||||
}
|
||||
|
||||
static const char *const pls_suffixes[] = {
|
||||
static constexpr const char *pls_suffixes[] = {
|
||||
"pls",
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const char *const pls_mime_types[] = {
|
||||
static constexpr const char *pls_mime_types[] = {
|
||||
"audio/x-scpls",
|
||||
nullptr
|
||||
};
|
||||
|
@ -153,12 +153,12 @@ rss_open_stream(InputStreamPtr &&is)
|
||||
return std::make_unique<MemorySongEnumerator>(std::move(parser.songs));
|
||||
}
|
||||
|
||||
static const char *const rss_suffixes[] = {
|
||||
static constexpr const char *rss_suffixes[] = {
|
||||
"rss",
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const char *const rss_mime_types[] = {
|
||||
static constexpr const char *rss_mime_types[] = {
|
||||
"application/rss+xml",
|
||||
"application/xml",
|
||||
"text/xml",
|
||||
|
@ -213,12 +213,12 @@ xspf_open_stream(InputStreamPtr &&is)
|
||||
return std::make_unique<MemorySongEnumerator>(std::move(parser.songs));
|
||||
}
|
||||
|
||||
static const char *const xspf_suffixes[] = {
|
||||
static constexpr const char *xspf_suffixes[] = {
|
||||
"xspf",
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const char *const xspf_mime_types[] = {
|
||||
static constexpr const char *xspf_mime_types[] = {
|
||||
"application/xspf+xml",
|
||||
nullptr
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ enum sticker_sql {
|
||||
STICKER_SQL_COUNT
|
||||
};
|
||||
|
||||
static const char *const sticker_sql[] = {
|
||||
static constexpr auto sticker_sql = std::array {
|
||||
//[STICKER_SQL_GET] =
|
||||
"SELECT value FROM sticker WHERE type=? AND uri=? AND name=?",
|
||||
//[STICKER_SQL_LIST] =
|
||||
@ -71,7 +71,7 @@ static const char *const sticker_sql[] = {
|
||||
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=? AND value>?",
|
||||
};
|
||||
|
||||
static const char sticker_sql_create[] =
|
||||
static constexpr const char sticker_sql_create[] =
|
||||
"CREATE TABLE IF NOT EXISTS sticker("
|
||||
" type VARCHAR NOT NULL, "
|
||||
" uri VARCHAR NOT NULL, "
|
||||
@ -99,7 +99,7 @@ StickerDatabase::StickerDatabase(Path path)
|
||||
|
||||
/* prepare the statements we're going to use */
|
||||
|
||||
for (unsigned i = 0; i < std::size(sticker_sql); ++i) {
|
||||
for (size_t i = 0; i < sticker_sql.size(); ++i) {
|
||||
assert(sticker_sql[i] != nullptr);
|
||||
|
||||
stmt[i] = Prepare(db, sticker_sql[i]);
|
||||
@ -110,10 +110,10 @@ StickerDatabase::~StickerDatabase() noexcept
|
||||
{
|
||||
assert(db != nullptr);
|
||||
|
||||
for (unsigned i = 0; i < std::size(stmt); ++i) {
|
||||
assert(stmt[i] != nullptr);
|
||||
for (const auto &sticker : stmt) {
|
||||
assert(sticker != nullptr);
|
||||
|
||||
sqlite3_finalize(stmt[i]);
|
||||
sqlite3_finalize(sticker);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user