-
Notifications
You must be signed in to change notification settings - Fork 1
/
list-human.cpp
68 lines (59 loc) · 1.65 KB
/
list-human.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (c) 2013-2019 amded workers, All rights reserved.
* Terms for redistribution and use can be found in LICENCE.
*/
/**
* @file list-human.cpp
* @brief Tag reader frontend for humans
*/
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <fileref.h>
#include <tpropertymap.h>
#include "amded.h"
#include "list-human.h"
#include "list.h"
#include "value.h"
static void
print_iter(const std::pair< const std::string, Value > &iter, bool symbol=false)
{
std::cout << std::setw(AMDED_TAG_MAXLENGTH)
<< std::left
<< iter.first
<< " | ";
if (iter.second.get_type() == TAG_INTEGER) {
std::cout << iter.second.get_int();
} else if (iter.second.get_type() == TAG_BOOLEAN) {
std::cout << (iter.second.get_bool() ? "true" : "false");
} else if (iter.second.get_type() == TAG_STRING) {
if (symbol) {
std::cout << iter.second.get_str().toCString(true);
} else {
std::cout << '"'
<< iter.second.get_str().toCString(true)
<< '"';
}
} else {
std::cout << "<INVALID DATA>";
}
std::cout << std::endl;
}
void
amded_list_human(const struct amded_file &file)
{
std::cout << '<' << file.name << '>' << std::endl;
std::map< std::string, Value > data = amded_list_amded(file);
for (auto &iter : data) {
print_iter(iter, true);
}
data = amded_list_tags(file);
for (auto &iter : data) {
print_iter(iter);
}
data = amded_list_audioprops(file.fh->audioProperties());
for (auto &iter : data) {
print_iter(iter);
}
}