ID result: use constexpr instead of #defines

This commit is contained in:
Moritz Bunkus 2021-02-21 13:16:24 +01:00
parent 2e142d2d8a
commit f0243659d2
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 10 additions and 10 deletions

View File

@ -17,14 +17,14 @@
#include "common/id_info.h"
#define ID_RESULT_TRACK_AUDIO "audio"
#define ID_RESULT_TRACK_VIDEO "video"
#define ID_RESULT_TRACK_SUBTITLES "subtitles"
#define ID_RESULT_TRACK_BUTTONS "buttons"
#define ID_RESULT_TRACK_UNKNOWN "unknown"
#define ID_RESULT_CHAPTERS "chapters"
#define ID_RESULT_TAGS "tags"
#define ID_RESULT_GLOBAL_TAGS_ID -1
constexpr auto ID_RESULT_TRACK_AUDIO = "audio";
constexpr auto ID_RESULT_TRACK_VIDEO = "video";
constexpr auto ID_RESULT_TRACK_SUBTITLES = "subtitles";
constexpr auto ID_RESULT_TRACK_BUTTONS = "buttons";
constexpr auto ID_RESULT_TRACK_UNKNOWN = "unknown";
constexpr auto ID_RESULT_CHAPTERS = "chapters";
constexpr auto ID_RESULT_TAGS = "tags";
constexpr auto ID_RESULT_GLOBAL_TAGS_ID = -1;
// When bumping the schema version:
// • increase `ID_JSON_FORMAT_VERSION` here
@ -33,7 +33,7 @@
// 1. `id`
// 2. `properties` → `identification_format_version` → `minimum` and `maximum`
// • adjust the link in `doc/man/mkvmerge.xml`
#define ID_JSON_FORMAT_VERSION 14
constexpr auto ID_JSON_FORMAT_VERSION = 14;
struct id_result_t {
int64_t id;

View File

@ -342,7 +342,7 @@ class SimpleTest
json_store = JsonSchema::DocumentStore.new
parser = JsonSchema::Parser.new
expander = JsonSchema::ReferenceExpander.new
version = IO.readlines("../src/merge/id_result.h").detect { |line| /#define +ID_JSON_FORMAT_VERSION\b/.match line }.gsub(/.* .* /, '').chop
version = IO.readlines("../src/merge/id_result.h").detect { |line| /^constexpr.*\bID_JSON_FORMAT_VERSION\b/.match line }.gsub(/.*= *|;/, '').chop
schema = parser.parse JSON.load(File.read("../doc/json-schema/mkvmerge-identification-output-schema-v#{version}.json"))
expander.expand(schema, store: json_store)