forked from mirror/openmw-tes3mp
Remove unused unsafe function and properly remove inheritance from std::string, providing implementations of missing stream operators preventing boost reading and writing to escape strings.
This commit is contained in:
parent
e6f78ae5b7
commit
f1b5ad5804
4 changed files with 61 additions and 23 deletions
|
@ -69,7 +69,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
{
|
||||
// Create a local alias for brevity
|
||||
namespace bpo = boost::program_options;
|
||||
typedef std::vector<Files::EscapeHashString> EscapeStringsVector;
|
||||
typedef std::vector<std::string> StringsVector;
|
||||
|
||||
bpo::options_description desc("Syntax: openmw <options>\nAllowed options");
|
||||
|
@ -83,7 +82,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("data-local", bpo::value<Files::EscapeHashString>()->default_value(""),
|
||||
"set local data directory (highest priority)")
|
||||
|
||||
("fallback-archive", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "fallback-archive")
|
||||
("fallback-archive", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "fallback-archive")
|
||||
->multitoken(), "set fallback BSA archives (later archives have higher priority)")
|
||||
|
||||
("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"),
|
||||
|
@ -92,7 +91,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
("start", bpo::value<Files::EscapeHashString>()->default_value(""),
|
||||
"set initial cell")
|
||||
|
||||
("content", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "")
|
||||
("content", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
->multitoken(), "content file(s): esm/esp, or omwgame/omwaddon")
|
||||
|
||||
("no-sound", bpo::value<bool>()->implicit_value(true)
|
||||
|
@ -120,7 +119,7 @@ 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<EscapeStringsVector>()->default_value(EscapeStringsVector(), "")
|
||||
("script-blacklist", bpo::value<Files::EscapeStringVector>()->default_value(Files::EscapeStringVector(), "")
|
||||
->multitoken(), "ignore the specified script (if the use of the blacklist is enabled)")
|
||||
|
||||
("script-blacklist-use", bpo::value<bool>()->implicit_value(true)
|
||||
|
@ -207,7 +206,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setDataDirs(dataDirs);
|
||||
|
||||
// fallback archives
|
||||
StringsVector archives = Files::EscapeHashString::toStdStringVector(variables["fallback-archive"].as<EscapeStringsVector>());
|
||||
StringsVector archives = variables["fallback-archive"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); ++it)
|
||||
{
|
||||
engine.addArchive(*it);
|
||||
|
@ -215,7 +214,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
|
||||
engine.setResourceDir(variables["resources"].as<Files::EscapeHashString>().toStdString());
|
||||
|
||||
StringsVector content = Files::EscapeHashString::toStdStringVector(variables["content"].as<EscapeStringsVector>());
|
||||
StringsVector content = variables["content"].as<Files::EscapeStringVector>().toStdStringVector();
|
||||
if (content.empty())
|
||||
{
|
||||
std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl;
|
||||
|
@ -242,7 +241,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||
engine.setStartupScript (variables["script-run"].as<Files::EscapeHashString>().toStdString());
|
||||
engine.setWarningsMode (variables["script-warn"].as<int>());
|
||||
engine.setScriptBlacklist (Files::EscapeHashString::toStdStringVector(variables["script-blacklist"].as<EscapeStringsVector>()));
|
||||
engine.setScriptBlacklist (variables["script-blacklist"].as<Files::EscapeStringVector>().toStdStringVector());
|
||||
engine.setScriptBlacklistUse (variables["script-blacklist-use"].as<bool>());
|
||||
engine.setSaveGameFile (variables["load-savegame"].as<Files::EscapeHashString>().toStdString());
|
||||
|
||||
|
|
|
@ -55,6 +55,17 @@ namespace Files {
|
|||
if (v.empty())
|
||||
v = boost::any(EscapeHashString(boost::program_options::validators::get_single_string(tokens)));
|
||||
}
|
||||
|
||||
void validate(boost::any &v, const std::vector<std::string> &tokens, EscapeStringVector *, int)
|
||||
{
|
||||
if (v.empty())
|
||||
v = boost::any(EscapeStringVector());
|
||||
|
||||
EscapeStringVector * eSV = boost::any_cast<EscapeStringVector>(&v);
|
||||
|
||||
for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
|
||||
eSV->mVector.push_back(EscapeHashString(*it));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -244,17 +244,6 @@ std::string EscapeHashString::processString(const std::string & str)
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> EscapeHashString::toStdStringVector(const std::vector<EscapeHashString> & vec)
|
||||
{
|
||||
std::vector<std::string> temp = std::vector<std::string>();
|
||||
for (std::vector<EscapeHashString>::const_iterator it = vec.begin(); it != vec.end(); ++it)
|
||||
{
|
||||
temp.push_back(it->toStdString());
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
EscapeHashString::EscapeHashString() : mData()
|
||||
{
|
||||
}
|
||||
|
@ -289,9 +278,36 @@ std::string EscapeHashString::toStdString() const
|
|||
return std::string(mData);
|
||||
}
|
||||
|
||||
std::string * EscapeHashString::toStdStringPtr() const
|
||||
std::istream & operator>> (std::istream & is, EscapeHashString & eHS)
|
||||
{
|
||||
return new std::string(mData);
|
||||
std::string temp;
|
||||
is >> temp;
|
||||
eHS = EscapeHashString(temp);
|
||||
return is;
|
||||
}
|
||||
|
||||
std::ostream & operator<< (std::ostream & os, const EscapeHashString & eHS)
|
||||
{
|
||||
os << eHS.mData;
|
||||
return os;
|
||||
}
|
||||
|
||||
EscapeStringVector::EscapeStringVector() : mVector()
|
||||
{
|
||||
}
|
||||
|
||||
EscapeStringVector::~EscapeStringVector()
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<std::string> EscapeStringVector::toStdStringVector() const
|
||||
{
|
||||
std::vector<std::string> temp = std::vector<std::string>();
|
||||
for (std::vector<EscapeHashString>::const_iterator it = mVector.begin(); it != mVector.end(); ++it)
|
||||
{
|
||||
temp.push_back(it->toStdString());
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getGlobalPath() const
|
||||
|
|
|
@ -91,13 +91,12 @@ struct escape_hash_filter : public boost::iostreams::input_filter
|
|||
/**
|
||||
* \class EscapeHashString
|
||||
*/
|
||||
class EscapeHashString : public std::string
|
||||
class EscapeHashString
|
||||
{
|
||||
private:
|
||||
std::string mData;
|
||||
public:
|
||||
static std::string processString(const std::string & str);
|
||||
static std::vector<std::string> toStdStringVector(const std::vector<EscapeHashString> & vec);
|
||||
|
||||
EscapeHashString();
|
||||
EscapeHashString(const std::string & str);
|
||||
|
@ -109,7 +108,20 @@ class EscapeHashString : public std::string
|
|||
EscapeHashString(InputIterator first, InputIterator last);
|
||||
|
||||
std::string toStdString() const;
|
||||
std::string * toStdStringPtr() const;
|
||||
|
||||
friend std::ostream & operator<< (std::ostream & os, const EscapeHashString & eHS);
|
||||
};
|
||||
|
||||
std::istream & operator>> (std::istream & is, EscapeHashString & eHS);
|
||||
|
||||
struct EscapeStringVector
|
||||
{
|
||||
std::vector<Files::EscapeHashString> mVector;
|
||||
|
||||
EscapeStringVector();
|
||||
virtual ~EscapeStringVector();
|
||||
|
||||
std::vector<std::string> toStdStringVector() const;
|
||||
};
|
||||
|
||||
} /* namespace Cfg */
|
||||
|
|
Loading…
Reference in a new issue