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