summaryrefslogtreecommitdiff
path: root/drumgizmo/dgvalidator.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2019-06-29 12:10:16 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2019-06-29 12:10:16 +0200
commit5eaf7c676d5d5a76ac10d2569aaba7c22ec3e6d3 (patch)
tree6242e5ba8c6bd1314287e302357dee22da49374f /drumgizmo/dgvalidator.cc
parent852c9d13e51ea60230dd18c9a29c614973fda963 (diff)
Improve dgvalidator usage and add man page for it.
Diffstat (limited to 'drumgizmo/dgvalidator.cc')
-rw-r--r--drumgizmo/dgvalidator.cc41
1 files changed, 40 insertions, 1 deletions
diff --git a/drumgizmo/dgvalidator.cc b/drumgizmo/dgvalidator.cc
index d0cef8d..d7557aa 100644
--- a/drumgizmo/dgvalidator.cc
+++ b/drumgizmo/dgvalidator.cc
@@ -34,8 +34,32 @@
#include <string>
#include <hugin.hpp>
+void printUsage(const char* prog, bool full = true)
+{
+ printf("Usage: %s <drumkit>|-h|--help\n", prog);
+ if(!full)
+ {
+ return;
+ }
+ printf("Validates the xml and semantics of the drumkit file and prints "
+ "any found errors to the console.\n");
+ printf("Returns 0 on success or 1 if errors were found.\n");
+}
+
int main(int argc, char* argv[])
{
+ if(argc != 2)
+ {
+ printUsage(argv[0], false);
+ return 1;
+ }
+
+ if(std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help")
+ {
+ printUsage(argv[0]);
+ return 1;
+ }
+
std::string edited_filename = argv[1];
DrumkitDOM drumkitdom;
std::vector<InstrumentDOM> instrumentdoms;
@@ -86,5 +110,20 @@ int main(int argc, char* argv[])
return 1;
}
- return 0;
+ // Verify all referred audiofiles
+ for(const auto& instrument: kit.instruments)
+ {
+ for(auto& audiofile: instrument->audiofiles)
+ {
+ audiofile->load(1);
+ if(!audiofile->isLoaded())
+ {
+ WARN(drumkitloader, "Instrument file load error: '%s'",
+ audiofile->filename.data());
+ parseerror = true;
+ }
+ }
+ }
+
+ return parseerror ? 1 : 0;
}