Replace boost::tokenizer with agi::Split

This commit is contained in:
Thomas Goyne 2015-01-11 08:11:22 -08:00
parent 5d8aeb8b40
commit 9f196adc2e
5 changed files with 25 additions and 30 deletions

View File

@ -19,9 +19,9 @@
#include "libaegisub/file_mapping.h"
#include "libaegisub/log.h"
#include "libaegisub/lua/utils.h"
#include "libaegisub/split.h"
#include <boost/algorithm/string/replace.hpp>
#include <boost/tokenizer.hpp>
#include <lauxlib.h>
namespace agi { namespace lua {
@ -83,9 +83,9 @@ namespace agi { namespace lua {
std::string package_paths(check_string(L, -1));
lua_pop(L, 2);
boost::char_separator<char> sep(";");
for (auto filename : boost::tokenizer<boost::char_separator<char>>(package_paths, sep)) {
boost::replace_all(filename, "?", module);
for (auto tok : agi::Split(package_paths, ';')) {
std::string filename;
boost::replace_all_copy(std::back_inserter(filename), tok, "?", module);
// If there's a .moon file at that path, load it instead of the
// .lua file

View File

@ -43,10 +43,10 @@
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/make_unique.h>
#include <libaegisub/split.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/tokenizer.hpp>
#include <future>
#include <wx/dcmemory.h>
@ -262,9 +262,8 @@ namespace Automation4 {
include_path.emplace_back(filename.parent_path());
std::string include_paths = OPT_GET("Path/Automation/Include")->GetString();
boost::char_separator<char> sep("|");
for (auto const& tok : boost::tokenizer<boost::char_separator<char>>(include_paths, sep)) {
auto path = config::path->Decode(tok);
for (auto tok : agi::Split(include_paths, '|')) {
auto path = config::path->Decode(agi::str(tok));
if (path.is_absolute() && agi::fs::DirectoryExists(path))
include_path.emplace_back(std::move(path));
}
@ -323,9 +322,8 @@ namespace Automation4 {
std::vector<std::future<std::unique_ptr<Script>>> script_futures;
boost::char_separator<char> sep("|");
for (auto const& tok : boost::tokenizer<boost::char_separator<char>>(path, sep)) {
auto dirname = config::path->Decode(tok);
for (auto tok : agi::Split(path, '|')) {
auto dirname = config::path->Decode(agi::str(tok));
if (!agi::fs::DirectoryExists(dirname)) continue;
for (auto filename : agi::fs::DirectoryIterator(dirname, "*.*"))
@ -372,11 +370,11 @@ namespace Automation4 {
auto autobasefn(OPT_GET("Path/Automation/Base")->GetString());
boost::char_separator<char> sep("|");
for (auto const& cur : boost::tokenizer<boost::char_separator<char>>(local_scripts, sep)) {
auto trimmed = boost::trim_copy(cur);
char first_char = trimmed[0];
trimmed.erase(0, 1);
for (auto tok : agi::Split(local_scripts, '|')) {
tok = boost::trim_copy(tok);
if (boost::size(tok) == 0) continue;
char first_char = tok[0];
std::string trimmed(begin(tok) + 1, end(tok));
agi::fs::path basepath;
if (first_char == '~') {

View File

@ -42,11 +42,11 @@
#include <libaegisub/log.h>
#include <libaegisub/lua/utils.h>
#include <libaegisub/make_unique.h>
#include <libaegisub/split.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/tokenizer.hpp>
#include <cfloat>
#include <unordered_map>
@ -533,13 +533,12 @@ namespace Automation4 {
}
void LuaDialog::Unserialise(const std::string &serialised) {
boost::char_separator<char> psep("|"), csep(":");
for (auto const& cur : boost::tokenizer<boost::char_separator<char>>(serialised, psep)) {
size_t pos = cur.find(':');
if (pos == std::string::npos) continue;
for (auto tok : agi::Split(serialised, '|')) {
auto pos = std::find(begin(tok), end(tok), ':');
if (pos == end(tok)) continue;
std::string name = inline_string_decode(cur.substr(0, pos));
std::string value = cur.substr(pos + 1);
std::string name = inline_string_decode(std::string(begin(tok), pos));
std::string value(pos + 1, end(tok));
// Hand value to all controls matching name
for (auto& control : controls) {

View File

@ -37,10 +37,10 @@
#include "utils.h"
#include <libaegisub/charset_conv.h>
#include <libaegisub/split.h>
#include <algorithm>
#include <boost/filesystem/path.hpp>
#include <boost/tokenizer.hpp>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/checklst.h>
@ -113,8 +113,7 @@ DialogExport::DialogExport(agi::Context *c)
// Get selected filters
std::string const& selected = c->ass->Properties.export_filters;
boost::char_separator<char> sep("|");
for (auto const& token : boost::tokenizer<boost::char_separator<char>>(selected, sep)) {
for (auto token : agi::Split(selected, '|')) {
auto it = find(begin(filters), end(filters), token);
if (it != end(filters))
filter_list->Check(distance(begin(filters), it));

View File

@ -36,9 +36,9 @@
#include "visual_tool.h"
#include <libaegisub/split.h>
#include <libaegisub/util.h>
#include <boost/tokenizer.hpp>
#include <limits>
Spline::Spline(const VisualToolBase &tl)
@ -109,10 +109,9 @@ void Spline::DecodeFromAss(std::string const& str) {
Vector2D pt{0, 0};
// Tokenize the string
boost::char_separator<char> sep(" ");
for (auto const& token : boost::tokenizer<boost::char_separator<char>>(str, sep)) {
for (auto token : agi::Split(str, ' ')) {
double n;
if (agi::util::try_parse(token, &n)) {
if (agi::util::try_parse(agi::str(token), &n)) {
stack.push_back(n);
// Move