Use boost::join in a handful of places
This commit is contained in:
parent
0ac8df140c
commit
28705000bb
4 changed files with 39 additions and 49 deletions
|
@ -48,6 +48,8 @@
|
|||
|
||||
#include <libaegisub/of_type_adaptor.h>
|
||||
|
||||
using namespace boost::adaptors;
|
||||
|
||||
std::size_t hash_value(wxString const& s) {
|
||||
return wxStringHash()(s);
|
||||
}
|
||||
|
@ -290,7 +292,7 @@ void AssDialogue::StripTag(wxString const& tag_name) {
|
|||
static wxString get_text(AssDialogueBlock &d) { return d.GetText(); }
|
||||
void AssDialogue::UpdateText(boost::ptr_vector<AssDialogueBlock>& blocks) {
|
||||
if (blocks.empty()) return;
|
||||
Text = join(blocks | boost::adaptors::transformed(get_text), wxS(""));
|
||||
Text = join(blocks | transformed(get_text), wxS(""));
|
||||
}
|
||||
|
||||
void AssDialogue::SetMarginString(wxString const& origvalue, int which) {
|
||||
|
@ -323,12 +325,11 @@ bool AssDialogue::CollidesWith(const AssDialogue *target) const {
|
|||
return ((Start < target->Start) ? (target->Start < End) : (Start < target->End));
|
||||
}
|
||||
|
||||
static wxString get_text_p(AssDialogueBlock *d) { return d->GetText(); }
|
||||
wxString AssDialogue::GetStrippedText() const {
|
||||
wxString ret;
|
||||
boost::ptr_vector<AssDialogueBlock> blocks(ParseTags());
|
||||
for (auto block : blocks | agi::of_type<AssDialogueBlockPlain>())
|
||||
ret += block->GetText();
|
||||
return ret;
|
||||
return join(blocks | agi::of_type<AssDialogueBlockPlain>() | transformed(get_text_p), wxS(""));
|
||||
}
|
||||
|
||||
AssEntry *AssDialogue::Clone() const {
|
||||
|
|
|
@ -35,15 +35,21 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <wx/log.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
#include <libaegisub/log.h>
|
||||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_override.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <functional>
|
||||
#include <wx/log.h>
|
||||
#include <wx/tokenzr.h>
|
||||
|
||||
using namespace boost::adaptors;
|
||||
|
||||
AssOverrideParameter::AssOverrideParameter()
|
||||
: classification(PARCLASS_NORMAL)
|
||||
, omitted(false)
|
||||
|
@ -91,11 +97,9 @@ void AssDialogueBlockOverride::AddTag(wxString const& tag) {
|
|||
Tags.push_back(new AssOverrideTag(tag));
|
||||
}
|
||||
|
||||
static wxString tag_str(AssOverrideTag *t) { return *t; }
|
||||
wxString AssDialogueBlockOverride::GetText() {
|
||||
text = "{";
|
||||
for (auto tag : Tags)
|
||||
text += *tag;
|
||||
text += "}";
|
||||
text = "{" + join(Tags | transformed(tag_str), wxString()) + "}";
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -424,6 +428,7 @@ void AssOverrideTag::ParseParameters(const wxString &text, AssOverrideTagProto::
|
|||
}
|
||||
}
|
||||
|
||||
static wxString param_str(AssOverrideParameter *p) { return p->Get<wxString>(); }
|
||||
AssOverrideTag::operator wxString() const {
|
||||
wxString result = Name;
|
||||
|
||||
|
@ -432,15 +437,10 @@ AssOverrideTag::operator wxString() const {
|
|||
if (parentheses) result += "(";
|
||||
|
||||
// Add parameters
|
||||
bool any = false;
|
||||
for (auto param : Params) {
|
||||
if (param->GetType() != VARDATA_NONE && !param->omitted) {
|
||||
result += param->Get<wxString>();
|
||||
result += ",";
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (any) result.resize(result.size() - 1);
|
||||
result += join(Params
|
||||
| filtered([](AssOverrideParameter *p) { return p->GetType() != VARDATA_NONE && !p->omitted; })
|
||||
| transformed(param_str),
|
||||
wxS(","));
|
||||
|
||||
if (parentheses) result += ")";
|
||||
return result;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "../utils.h"
|
||||
#include "../video_context.h"
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include <boost/range/adaptor/sliced.hpp>
|
||||
|
||||
|
@ -468,18 +469,14 @@ struct edit_find_replace : public Command {
|
|||
}
|
||||
};
|
||||
|
||||
static wxString get_entry_data(AssDialogue *d) { return d->GetEntryData(); }
|
||||
static void copy_lines(agi::Context *c) {
|
||||
wxString data;
|
||||
SubtitleSelection sel = c->selectionController->GetSelectedSet();
|
||||
for (auto diag : c->ass->Line | agi::of_type<AssDialogue>()) {
|
||||
if (sel.count(diag)) {
|
||||
if (!data.empty())
|
||||
data += "\r\n";
|
||||
data += diag->GetEntryData();
|
||||
}
|
||||
}
|
||||
|
||||
SetClipboard(data);
|
||||
SetClipboard(join(c->ass->Line
|
||||
| agi::of_type<AssDialogue>()
|
||||
| filtered([&](AssDialogue *d) { return sel.count(d); })
|
||||
| transformed(get_entry_data),
|
||||
wxS("")));
|
||||
}
|
||||
|
||||
static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
||||
|
|
|
@ -26,23 +26,23 @@
|
|||
#include "libresrc/libresrc.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <libaegisub/hotkey.h>
|
||||
#include <libaegisub/json.h>
|
||||
#include <libaegisub/log.h>
|
||||
#include <libaegisub/signal.h>
|
||||
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <wx/frame.h>
|
||||
#include <wx/toolbar.h>
|
||||
|
||||
#include <libaegisub/hotkey.h>
|
||||
#include <libaegisub/json.h>
|
||||
#include <libaegisub/log.h>
|
||||
#include <libaegisub/signal.h>
|
||||
|
||||
namespace {
|
||||
json::Object const& get_root() {
|
||||
static json::Object root;
|
||||
if (root.empty()) {
|
||||
if (root.empty())
|
||||
root = agi::json_util::parse(new std::istringstream(GET_DEFAULT_CONFIG(default_toolbar)));
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,10 @@ namespace {
|
|||
/// Enable/disable the toolbar buttons
|
||||
void OnIdle(wxIdleEvent &) {
|
||||
for (size_t i = 0; i < commands.size(); ++i) {
|
||||
if (commands[i]->Type() & cmd::COMMAND_VALIDATE) {
|
||||
if (commands[i]->Type() & cmd::COMMAND_VALIDATE)
|
||||
EnableTool(TOOL_ID_BASE + i, commands[i]->Validate(context));
|
||||
}
|
||||
if (commands[i]->Type() & cmd::COMMAND_TOGGLE || commands[i]->Type() & cmd::COMMAND_RADIO) {
|
||||
if (commands[i]->Type() & cmd::COMMAND_TOGGLE || commands[i]->Type() & cmd::COMMAND_RADIO)
|
||||
ToggleTool(TOOL_ID_BASE + i, commands[i]->IsActive(context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,14 +155,8 @@ namespace {
|
|||
wxString ret = command->StrHelp();
|
||||
|
||||
std::vector<std::string> hotkeys = hotkey::get_hotkey_strs(ht_context, command->name());
|
||||
for (size_t i = 0; i < hotkeys.size(); ++i) {
|
||||
if (i == 0)
|
||||
ret += " (";
|
||||
else
|
||||
ret += "/";
|
||||
ret += hotkeys[i];
|
||||
}
|
||||
if (hotkeys.size()) ret += ")";
|
||||
if (!hotkeys.empty())
|
||||
ret += " (" + boost::join(hotkeys, "/") + ")";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue