mirror of
https://github.com/fmang/opustags.git
synced 2025-03-14 08:30:08 +01:00
Fix brace style
Breaking habits is difficult
This commit is contained in:
parent
159340926a
commit
7b616aa671
@ -61,15 +61,12 @@ int main(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (options.path_out.empty())
|
||||
{
|
||||
if (options.path_out.empty()) {
|
||||
std::ifstream in(options.path_in);
|
||||
opustags::ogg::Decoder dec(in);
|
||||
list_tags(dec, options.tags_handler);
|
||||
// TODO: report errors if user tries to edit the stream
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
std::ifstream in(options.path_in);
|
||||
std::ofstream out(options.path_out);
|
||||
opustags::ogg::Decoder dec(in);
|
||||
|
@ -95,8 +95,7 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
case 'd':
|
||||
if (arg.find('=') != std::string::npos)
|
||||
throw ArgumentError("Invalid field: '" + arg + "'");
|
||||
for (const auto streamno : current_streamnos)
|
||||
{
|
||||
for (const auto streamno : current_streamnos) {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<RemovalTagsHandler>(streamno, arg));
|
||||
}
|
||||
@ -109,16 +108,12 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
std::regex regex("^(\\w+)=(.*)$");
|
||||
if (!std::regex_match(arg, match, regex))
|
||||
throw ArgumentError("Invalid field: '" + arg + "'");
|
||||
for (const auto streamno : current_streamnos)
|
||||
{
|
||||
if (c == 's')
|
||||
{
|
||||
for (const auto streamno : current_streamnos) {
|
||||
if (c == 's') {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<ModificationTagsHandler>(
|
||||
streamno, match[1], match[2]));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<InsertionTagsHandler>(
|
||||
streamno, match[1], match[2]));
|
||||
@ -128,8 +123,7 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
}
|
||||
|
||||
case 'l':
|
||||
for (const auto streamno : current_streamnos)
|
||||
{
|
||||
for (const auto streamno : current_streamnos) {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<ListingTagsHandler>(
|
||||
streamno, std::cout));
|
||||
@ -142,8 +136,7 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
for (const auto streamno : current_streamnos)
|
||||
{
|
||||
for (const auto streamno : current_streamnos) {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<RemovalTagsHandler>(streamno));
|
||||
}
|
||||
@ -152,13 +145,11 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
case 0:
|
||||
{
|
||||
std::string long_arg = long_def[option_index].name;
|
||||
if (long_arg == "stream")
|
||||
{
|
||||
if (long_arg == "stream") {
|
||||
int i;
|
||||
current_streamnos.clear();
|
||||
std::stringstream ss(optarg);
|
||||
while (ss >> i)
|
||||
{
|
||||
while (ss >> i) {
|
||||
current_streamnos.push_back(i);
|
||||
if (ss.peek() == ',')
|
||||
ss.ignore();
|
||||
@ -184,8 +175,7 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
while (optind < argc)
|
||||
stray.push_back(argv[optind++]);
|
||||
|
||||
if (!options.show_help && !options.show_version)
|
||||
{
|
||||
if (!options.show_help && !options.show_version) {
|
||||
if (stray.empty())
|
||||
throw ArgumentError("Missing input path");
|
||||
|
||||
@ -196,8 +186,7 @@ Options opustags::parse_args(const int argc, char **argv)
|
||||
if (stray.size() > 1)
|
||||
throw ArgumentError("Extra argument: " + stray.at(1));
|
||||
|
||||
if (options.path_out.empty())
|
||||
{
|
||||
if (options.path_out.empty()) {
|
||||
options.tags_handler.add_handler(
|
||||
std::make_shared<ListingTagsHandler>(
|
||||
StreamTagsHandler::ALL_STREAMS, std::cout));
|
||||
|
@ -26,8 +26,7 @@ bool ImportTagsHandler::edit(const int streamno, Tags &tags)
|
||||
const auto old_tags = tags;
|
||||
tags.clear();
|
||||
|
||||
if (tag_map.find(streamno) != tag_map.end())
|
||||
{
|
||||
if (tag_map.find(streamno) != tag_map.end()) {
|
||||
const auto &source_tags = tag_map.at(streamno);
|
||||
for (const auto &source_tag : source_tags.get_all())
|
||||
tags.add(source_tag.key, source_tag.value);
|
||||
@ -55,19 +54,13 @@ void ImportTagsHandler::parse_input_stream_if_needed()
|
||||
|
||||
int current_stream_number = 1;
|
||||
std::string line;
|
||||
while (std::getline(input_stream, line))
|
||||
{
|
||||
while (std::getline(input_stream, line)) {
|
||||
std::smatch match;
|
||||
if (std::regex_match(line, match, stream_header_regex))
|
||||
{
|
||||
if (std::regex_match(line, match, stream_header_regex)) {
|
||||
current_stream_number = std::atoi(match[1].str().c_str());
|
||||
}
|
||||
else if (std::regex_match(line, match, tag_regex))
|
||||
{
|
||||
} else if (std::regex_match(line, match, tag_regex)) {
|
||||
tag_map[current_stream_number].add(match[1], match[2]);
|
||||
}
|
||||
else if (!std::regex_match(line, match, whitespace_regex))
|
||||
{
|
||||
} else if (!std::regex_match(line, match, whitespace_regex)) {
|
||||
throw std::runtime_error("Malformed input data near line " + line);
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,7 @@ std::string ModificationTagsHandler::get_tag_value() const
|
||||
|
||||
bool ModificationTagsHandler::edit_impl(Tags &tags)
|
||||
{
|
||||
if (tags.contains(tag_key))
|
||||
{
|
||||
if (tags.contains(tag_key)) {
|
||||
if (tags.get(tag_key) == tag_value)
|
||||
return false;
|
||||
tags.remove(tag_key);
|
||||
|
@ -21,14 +21,11 @@ std::string RemovalTagsHandler::get_tag_key() const
|
||||
|
||||
bool RemovalTagsHandler::edit_impl(Tags &tags)
|
||||
{
|
||||
if (tag_key.empty())
|
||||
{
|
||||
if (tag_key.empty()) {
|
||||
const auto anything_removed = tags.get_all().size() > 0;
|
||||
tags.clear();
|
||||
return anything_removed;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (!tags.contains(tag_key))
|
||||
throw TagDoesNotExistError(tag_key);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user