mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 09:15:38 +00:00
Purge all uses of Escape Hash types
This commit is contained in:
parent
cf3596fbb4
commit
af0d399103
5 changed files with 58 additions and 61 deletions
|
@ -88,16 +88,16 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
boost::program_options::options_description desc("Syntax: openmw-cs <options>\nAllowed options");
|
||||
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::EscapePathContainer>()->default_value(Files::EscapePathContainer(), "data")->multitoken()->composing())
|
||||
("data-local", boost::program_options::value<Files::EscapePath>()->default_value(Files::EscapePath(), ""))
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken()->composing())
|
||||
("data-local", boost::program_options::value<Files::PathContainer::value_type>()->default_value(Files::PathContainer::value_type(), ""))
|
||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||
("encoding", boost::program_options::value<Files::EscapeHashString>()->default_value("win1252"))
|
||||
("resources", boost::program_options::value<Files::EscapePath>()->default_value(Files::EscapePath(), "resources"))
|
||||
("fallback-archive", boost::program_options::value<Files::EscapeStringVector>()->
|
||||
default_value(Files::EscapeStringVector(), "fallback-archive")->multitoken())
|
||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"))
|
||||
("resources", boost::program_options::value<boost::filesystem::path>()->default_value(boost::filesystem::path(), "resources"))
|
||||
("fallback-archive", boost::program_options::value<std::vector<std::string>>()->
|
||||
default_value(std::vector<std::string>(), "fallback-archive")->multitoken())
|
||||
("fallback", boost::program_options::value<FallbackMap>()->default_value(FallbackMap(), "")
|
||||
->multitoken()->composing(), "fallback values")
|
||||
("script-blacklist", boost::program_options::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("script-blacklist", boost::program_options::value<std::vector<std::string>>()->default_value(std::vector<std::string>(), "")
|
||||
->multitoken(), "exclude specified script from the verifier (if the use of the blacklist is enabled)")
|
||||
("script-blacklist-use", boost::program_options::value<bool>()->implicit_value(true)
|
||||
->default_value(true), "enable script blacklisting");
|
||||
|
@ -108,24 +108,24 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
|
||||
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);
|
||||
|
||||
mEncodingName = variables["encoding"].as<Files::EscapeHashString>().toStdString();
|
||||
mEncodingName = variables["encoding"].as<std::string>();
|
||||
mDocumentManager.setEncoding(ToUTF8::calculateEncoding(mEncodingName));
|
||||
mFileDialog.setEncoding (QString::fromUtf8(mEncodingName.c_str()));
|
||||
|
||||
mDocumentManager.setResourceDir (mResources = variables["resources"].as<Files::EscapePath>().mPath);
|
||||
mDocumentManager.setResourceDir (mResources = variables["resources"].as<boost::filesystem::path>());
|
||||
|
||||
if (variables["script-blacklist-use"].as<bool>())
|
||||
mDocumentManager.setBlacklistedScripts (
|
||||
variables["script-blacklist"].as<Files::EscapeStringVector>().toStdStringVector());
|
||||
variables["script-blacklist"].as<std::vector<std::string>>());
|
||||
|
||||
mFsStrict = variables["fs-strict"].as<bool>();
|
||||
|
||||
Files::PathContainer dataDirs, dataLocal;
|
||||
if (!variables["data"].empty()) {
|
||||
dataDirs = Files::PathContainer(Files::EscapePath::toPathContainer(variables["data"].as<Files::EscapePathContainer>()));
|
||||
dataDirs = variables["data"].as<Files::PathContainer>();
|
||||
}
|
||||
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::EscapePath>().mPath);
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::PathContainer::value_type>());
|
||||
if (!local.empty())
|
||||
dataLocal.push_back(local);
|
||||
|
||||
|
@ -155,7 +155,7 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
mFileDialog.addFiles(path);
|
||||
}
|
||||
|
||||
return std::make_pair (dataDirs, variables["fallback-archive"].as<Files::EscapeStringVector>().toStdStringVector());
|
||||
return std::make_pair (dataDirs, variables["fallback-archive"].as<std::vector<std::string>>());
|
||||
}
|
||||
|
||||
void CS::Editor::createGame()
|
||||
|
|
|
@ -45,31 +45,31 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("help", "print help message")
|
||||
("version", "print version information and quit")
|
||||
|
||||
("replace", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("replace", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken()->composing(), "settings where the values from the current source should replace those from lower-priority sources instead of being appended")
|
||||
|
||||
("data", bpo::value<Files::EscapePathContainer>()->default_value(Files::EscapePathContainer(), "data")
|
||||
("data", bpo::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")
|
||||
->multitoken()->composing(), "set data directories (later directories have higher priority)")
|
||||
|
||||
("data-local", bpo::value<Files::EscapePath>()->default_value(Files::EscapePath(), ""),
|
||||
("data-local", bpo::value<Files::PathContainer::value_type>()->default_value(Files::PathContainer::value_type(), ""),
|
||||
"set local data directory (highest priority)")
|
||||
|
||||
("fallback-archive", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "fallback-archive")
|
||||
("fallback-archive", bpo::value<StringsVector>()->default_value(StringsVector(), "fallback-archive")
|
||||
->multitoken()->composing(), "set fallback BSA archives (later archives have higher priority)")
|
||||
|
||||
("resources", bpo::value<Files::EscapePath>()->default_value(Files::EscapePath(), "resources"),
|
||||
("resources", bpo::value<boost::filesystem::path>()->default_value(boost::filesystem::path(), "resources"),
|
||||
"set resources directory")
|
||||
|
||||
("start", bpo::value<Files::EscapeHashString>()->default_value(""),
|
||||
("start", bpo::value<std::string>()->default_value(""),
|
||||
"set initial cell")
|
||||
|
||||
("content", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("content", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken()->composing(), "content file(s): esm/esp, or omwgame/omwaddon")
|
||||
|
||||
("groundcover", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("groundcover", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken()->composing(), "groundcover content file(s): esm/esp, or omwgame/omwaddon")
|
||||
|
||||
("lua-scripts", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("lua-scripts", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken()->composing(), "file(s) with a list of global Lua scripts: omwscripts")
|
||||
|
||||
("no-sound", bpo::value<bool>()->implicit_value(true)
|
||||
|
@ -84,7 +84,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("script-console", bpo::value<bool>()->implicit_value(true)
|
||||
->default_value(false), "enable console-only script functionality")
|
||||
|
||||
("script-run", bpo::value<Files::EscapeHashString>()->default_value(""),
|
||||
("script-run", bpo::value<std::string>()->default_value(""),
|
||||
"select a file containing a list of console commands that is executed on startup")
|
||||
|
||||
("script-warn", bpo::value<int>()->implicit_value (1)
|
||||
|
@ -94,13 +94,13 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
"\t1 - show warning but consider script as correctly compiled anyway\n"
|
||||
"\t2 - treat warnings as errors")
|
||||
|
||||
("script-blacklist", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("script-blacklist", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken()->composing(), "ignore the specified script (if the use of the blacklist is enabled)")
|
||||
|
||||
("script-blacklist-use", bpo::value<bool>()->implicit_value(true)
|
||||
->default_value(true), "enable script blacklisting")
|
||||
|
||||
("load-savegame", bpo::value<Files::EscapePath>()->default_value(Files::EscapePath(), ""),
|
||||
("load-savegame", bpo::value<boost::filesystem::path>()->default_value(boost::filesystem::path(), ""),
|
||||
"load a save game file on game startup (specify an absolute filename or a filename relative to the current working directory)")
|
||||
|
||||
("skip-menu", bpo::value<bool>()->implicit_value(true)
|
||||
|
@ -112,7 +112,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("fs-strict", bpo::value<bool>()->implicit_value(true)
|
||||
->default_value(false), "strict file system handling (no case folding)")
|
||||
|
||||
("encoding", bpo::value<Files::EscapeHashString>()->
|
||||
("encoding", bpo::value<std::string>()->
|
||||
default_value("win1252"),
|
||||
"Character encoding used in OpenMW game messages:\n"
|
||||
"\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
|
||||
|
@ -153,7 +153,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
{
|
||||
cfgMgr.readConfiguration(variables, desc, true);
|
||||
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::EscapePath>().mPath.string());
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<boost::filesystem::path>().string());
|
||||
getRawStdout() << v.describe() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -162,38 +162,38 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
cfgMgr.readConfiguration(variables, desc);
|
||||
cfgMgr.mergeComposingVariables(variables, composingVariables, desc);
|
||||
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<Files::EscapePath>().mPath.string());
|
||||
Version::Version v = Version::getOpenmwVersion(variables["resources"].as<boost::filesystem::path>().string());
|
||||
Log(Debug::Info) << v.describe();
|
||||
|
||||
engine.setGrabMouse(!variables["no-grab"].as<bool>());
|
||||
|
||||
// Font encoding settings
|
||||
std::string encoding(variables["encoding"].as<Files::EscapeHashString>().toStdString());
|
||||
std::string encoding(variables["encoding"].as<std::string>());
|
||||
Log(Debug::Info) << ToUTF8::encodingUsingMessage(encoding);
|
||||
engine.setEncoding(ToUTF8::calculateEncoding(encoding));
|
||||
|
||||
// directory settings
|
||||
engine.enableFSStrict(variables["fs-strict"].as<bool>());
|
||||
|
||||
Files::PathContainer dataDirs(Files::EscapePath::toPathContainer(variables["data"].as<Files::EscapePathContainer>()));
|
||||
Files::PathContainer dataDirs(variables["data"].as<Files::PathContainer>());
|
||||
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::EscapePath>().mPath);
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::PathContainer::value_type>());
|
||||
if (!local.empty())
|
||||
dataDirs.push_back(local);
|
||||
|
||||
cfgMgr.processPaths(dataDirs);
|
||||
|
||||
engine.setResourceDir(variables["resources"].as<Files::EscapePath>().mPath);
|
||||
engine.setResourceDir(variables["resources"].as<boost::filesystem::path>());
|
||||
engine.setDataDirs(dataDirs);
|
||||
|
||||
// fallback archives
|
||||
StringsVector archives = variables["fallback-archive"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
StringsVector archives = variables["fallback-archive"].as<StringsVector>();
|
||||
for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); ++it)
|
||||
{
|
||||
engine.addArchive(*it);
|
||||
}
|
||||
|
||||
StringsVector content = variables["content"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
StringsVector content = variables["content"].as<StringsVector>();
|
||||
if (content.empty())
|
||||
{
|
||||
Log(Debug::Error) << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting...";
|
||||
|
@ -214,18 +214,18 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.addContentFile(file);
|
||||
}
|
||||
|
||||
StringsVector groundcover = variables["groundcover"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
StringsVector groundcover = variables["groundcover"].as<StringsVector>();
|
||||
for (auto& file : groundcover)
|
||||
{
|
||||
engine.addGroundcoverFile(file);
|
||||
}
|
||||
|
||||
StringsVector luaScriptLists = variables["lua-scripts"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
StringsVector luaScriptLists = variables["lua-scripts"].as<StringsVector>();
|
||||
for (const auto& file : luaScriptLists)
|
||||
engine.addLuaScriptListFile(file);
|
||||
|
||||
// startup-settings
|
||||
engine.setCell(variables["start"].as<Files::EscapeHashString>().toStdString());
|
||||
engine.setCell(variables["start"].as<std::string>());
|
||||
engine.setSkipMenu (variables["skip-menu"].as<bool>(), variables["new-game"].as<bool>());
|
||||
if (!variables["skip-menu"].as<bool>() && variables["new-game"].as<bool>())
|
||||
Log(Debug::Warning) << "Warning: new-game used without skip-menu -> ignoring it";
|
||||
|
@ -234,11 +234,11 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setCompileAll(variables["script-all"].as<bool>());
|
||||
engine.setCompileAllDialogue(variables["script-all-dialogue"].as<bool>());
|
||||
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
|
||||
engine.setStartupScript (variables["script-run"].as<std::string>());
|
||||
engine.setWarningsMode (variables["script-warn"].as<int>());
|
||||
engine.setScriptBlacklist (variables["script-blacklist"].as<Files::EscapeStringVector>().toStdStringVector());
|
||||
engine.setScriptBlacklist (variables["script-blacklist"].as<StringsVector>());
|
||||
engine.setScriptBlacklistUse (variables["script-blacklist-use"].as<bool>());
|
||||
engine.setSaveGameFile (variables["load-savegame"].as<Files::EscapePath>().mPath.string());
|
||||
engine.setSaveGameFile (variables["load-savegame"].as<boost::filesystem::path>().string());
|
||||
|
||||
// other settings
|
||||
Fallback::Map::init(variables["fallback"].as<FallbackMap>().mMap);
|
||||
|
|
|
@ -59,10 +59,10 @@ struct ContentFileTest : public ::testing::Test
|
|||
|
||||
boost::program_options::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("data", boost::program_options::value<Files::EscapePathContainer>()->default_value(Files::EscapePathContainer(), "data")->multitoken()->composing())
|
||||
("content", boost::program_options::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken()->composing())
|
||||
("content", boost::program_options::value<std::vector<std::string>>()->default_value(std::vector<std::string>(), "")
|
||||
->multitoken()->composing(), "content file(s): esm/esp, or omwgame/omwaddon")
|
||||
("data-local", boost::program_options::value<Files::EscapePath>()->default_value(Files::EscapePath(), ""));
|
||||
("data-local", boost::program_options::value<Files::PathContainer::value_type>()->default_value(Files::PathContainer::value_type(), ""));
|
||||
|
||||
boost::program_options::notify(variables);
|
||||
|
||||
|
@ -70,10 +70,10 @@ struct ContentFileTest : public ::testing::Test
|
|||
|
||||
Files::PathContainer dataDirs, dataLocal;
|
||||
if (!variables["data"].empty()) {
|
||||
dataDirs = Files::EscapePath::toPathContainer(variables["data"].as<Files::EscapePathContainer>());
|
||||
dataDirs = variables["data"].as<Files::PathContainer>();
|
||||
}
|
||||
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::EscapePath>().mPath);
|
||||
Files::PathContainer::value_type local(variables["data-local"].as<Files::PathContainer::value_type>());
|
||||
if (!local.empty()) {
|
||||
dataLocal.push_back(local);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ struct ContentFileTest : public ::testing::Test
|
|||
|
||||
Files::Collections collections (dataDirs, true);
|
||||
|
||||
std::vector<std::string> contentFiles = variables["content"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
std::vector<std::string> contentFiles = variables["content"].as<std::vector<std::string>>();
|
||||
for (auto & contentFile : contentFiles)
|
||||
mContentFiles.push_back(collections.getPath(contentFile));
|
||||
}
|
||||
|
|
|
@ -158,8 +158,8 @@ namespace Files
|
|||
while (this->getline(s)) {
|
||||
|
||||
// strip '#' comments and whitespace
|
||||
if ((n = s.find('#')) != std::string::npos)
|
||||
s = s.substr(0, n);
|
||||
if (s.find('#') == s.find_first_not_of(" \t\r\n"))
|
||||
continue;
|
||||
s = trim_ws(s);
|
||||
|
||||
if (!s.empty()) {
|
||||
|
|
|
@ -108,7 +108,7 @@ void ConfigurationManager::mergeComposingVariables(boost::program_options::varia
|
|||
auto replace = second["replace"];
|
||||
if (!replace.defaulted() && !replace.empty())
|
||||
{
|
||||
std::vector<std::string> replaceVector = replace.as<Files::EscapeStringVector>().toStdStringVector();
|
||||
std::vector<std::string> replaceVector = replace.as<std::vector<std::string>>();
|
||||
replacedVariables.insert(replaceVector.begin(), replaceVector.end());
|
||||
}
|
||||
}
|
||||
|
@ -137,19 +137,19 @@ void ConfigurationManager::mergeComposingVariables(boost::program_options::varia
|
|||
boost::any& firstValue = firstPosition->second.value();
|
||||
const boost::any& secondValue = second[name].value();
|
||||
|
||||
if (firstValue.type() == typeid(Files::EscapePathContainer))
|
||||
if (firstValue.type() == typeid(Files::PathContainer))
|
||||
{
|
||||
auto& firstPathContainer = boost::any_cast<Files::EscapePathContainer&>(firstValue);
|
||||
const auto& secondPathContainer = boost::any_cast<const Files::EscapePathContainer&>(secondValue);
|
||||
auto& firstPathContainer = boost::any_cast<Files::PathContainer&>(firstValue);
|
||||
const auto& secondPathContainer = boost::any_cast<const Files::PathContainer&>(secondValue);
|
||||
|
||||
firstPathContainer.insert(firstPathContainer.end(), secondPathContainer.begin(), secondPathContainer.end());
|
||||
}
|
||||
else if (firstValue.type() == typeid(Files::EscapeStringVector))
|
||||
else if (firstValue.type() == typeid(std::vector<std::string>))
|
||||
{
|
||||
auto& firstVector = boost::any_cast<Files::EscapeStringVector&>(firstValue);
|
||||
const auto& secondVector = boost::any_cast<const Files::EscapeStringVector&>(secondValue);
|
||||
auto& firstVector = boost::any_cast<std::vector<std::string>&>(firstValue);
|
||||
const auto& secondVector = boost::any_cast<const std::vector<std::string>&>(secondValue);
|
||||
|
||||
firstVector.mVector.insert(firstVector.mVector.end(), secondVector.mVector.begin(), secondVector.mVector.end());
|
||||
firstVector.insert(firstVector.end(), secondVector.begin(), secondVector.end());
|
||||
}
|
||||
else if (firstValue.type() == typeid(Fallback::FallbackMap))
|
||||
{
|
||||
|
@ -234,11 +234,8 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path,
|
|||
if (!mSilent)
|
||||
Log(Debug::Info) << "Loading config file: " << cfgFile.string();
|
||||
|
||||
boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile);
|
||||
boost::iostreams::filtering_istream configFileStream;
|
||||
configFileStream.push(escape_hash_filter());
|
||||
configFileStream.push(configFileStreamUnfiltered);
|
||||
if (configFileStreamUnfiltered.is_open())
|
||||
boost::filesystem::ifstream configFileStream(cfgFile);
|
||||
if (configFileStream.is_open())
|
||||
{
|
||||
boost::program_options::store(Files::parse_config_file(
|
||||
configFileStream, description, true), variables);
|
||||
|
|
Loading…
Reference in a new issue