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

View File

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

View File

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

View File

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

View File

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