Switch indentation to spaces to remain consistent with the rest of the project

coverity_scan^2
AnyOldName3 9 years ago
parent 08df463c94
commit e6f78ae5b7

@ -69,8 +69,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
{ {
// Create a local alias for brevity // Create a local alias for brevity
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
typedef std::vector<Files::EscapeHashString> EscapeStringsVector; typedef std::vector<Files::EscapeHashString> EscapeStringsVector;
typedef std::vector<std::string> StringsVector; typedef std::vector<std::string> StringsVector;
bpo::options_description desc("Syntax: openmw <options>\nAllowed options"); bpo::options_description desc("Syntax: openmw <options>\nAllowed options");
@ -80,16 +80,16 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("data", bpo::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data") ("data", bpo::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")
->multitoken()->composing(), "set data directories (later directories have higher priority)") ->multitoken()->composing(), "set data directories (later directories have higher priority)")
("data-local", bpo::value<Files::EscapeHashString>()->default_value(""), ("data-local", bpo::value<Files::EscapeHashString>()->default_value(""),
"set local data directory (highest priority)") "set local data directory (highest priority)")
("fallback-archive", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "fallback-archive") ("fallback-archive", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "fallback-archive")
->multitoken(), "set fallback BSA archives (later archives have higher priority)") ->multitoken(), "set fallback BSA archives (later archives have higher priority)")
("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"), ("resources", bpo::value<Files::EscapeHashString>()->default_value("resources"),
"set resources directory") "set resources directory")
("start", bpo::value<Files::EscapeHashString>()->default_value(""), ("start", bpo::value<Files::EscapeHashString>()->default_value(""),
"set initial cell") "set initial cell")
("content", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "") ("content", bpo::value<EscapeStringsVector>()->default_value(EscapeStringsVector(), "")
@ -110,7 +110,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("script-console", bpo::value<bool>()->implicit_value(true) ("script-console", bpo::value<bool>()->implicit_value(true)
->default_value(false), "enable console-only script functionality") ->default_value(false), "enable console-only script functionality")
("script-run", bpo::value<Files::EscapeHashString>()->default_value(""), ("script-run", bpo::value<Files::EscapeHashString>()->default_value(""),
"select a file containing a list of console commands that is executed on startup") "select a file containing a list of console commands that is executed on startup")
("script-warn", bpo::value<int>()->implicit_value (1) ("script-warn", bpo::value<int>()->implicit_value (1)
@ -126,7 +126,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("script-blacklist-use", bpo::value<bool>()->implicit_value(true) ("script-blacklist-use", bpo::value<bool>()->implicit_value(true)
->default_value(true), "enable script blacklisting") ->default_value(true), "enable script blacklisting")
("load-savegame", bpo::value<Files::EscapeHashString>()->default_value(""), ("load-savegame", bpo::value<Files::EscapeHashString>()->default_value(""),
"load a save game file on game startup (specify an absolute filename or a filename relative to the current working directory)") "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) ("skip-menu", bpo::value<bool>()->implicit_value(true)
@ -138,14 +138,14 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
("fs-strict", bpo::value<bool>()->implicit_value(true) ("fs-strict", bpo::value<bool>()->implicit_value(true)
->default_value(false), "strict file system handling (no case folding)") ->default_value(false), "strict file system handling (no case folding)")
("encoding", bpo::value<Files::EscapeHashString>()-> ("encoding", bpo::value<Files::EscapeHashString>()->
default_value("win1252"), default_value("win1252"),
"Character encoding used in OpenMW game messages:\n" "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" "\n\twin1250 - Central and Eastern European such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian, Serbian (Latin script), Romanian and Albanian languages\n"
"\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n"
"\n\twin1252 - Western European (Latin) alphabet, used by default") "\n\twin1252 - Western European (Latin) alphabet, used by default")
("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "") ("fallback", bpo::value<FallbackMap>()->default_value(FallbackMap(), "")
->multitoken()->composing(), "fallback values") ->multitoken()->composing(), "fallback values")
("no-grab", "Don't grab mouse cursor") ("no-grab", "Don't grab mouse cursor")
@ -215,7 +215,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setResourceDir(variables["resources"].as<Files::EscapeHashString>().toStdString()); engine.setResourceDir(variables["resources"].as<Files::EscapeHashString>().toStdString());
StringsVector content = Files::EscapeHashString::toStdStringVector(variables["content"].as<EscapeStringsVector>()); StringsVector content = Files::EscapeHashString::toStdStringVector(variables["content"].as<EscapeStringsVector>());
if (content.empty()) if (content.empty())
{ {
std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl; std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl;
@ -248,7 +248,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
// other settings // other settings
engine.setSoundUsage(!variables["no-sound"].as<bool>()); engine.setSoundUsage(!variables["no-sound"].as<bool>());
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap); engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>()); engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
engine.enableFontExport(variables["export-fonts"].as<bool>()); engine.enableFontExport(variables["export-fonts"].as<bool>());

@ -12,49 +12,49 @@
namespace Fallback namespace Fallback
{ {
struct FallbackMap { struct FallbackMap {
std::map<std::string, std::string> mMap; std::map<std::string, std::string> mMap;
}; };
void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap*, int) void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap*, int)
{ {
if (v.empty()) if (v.empty())
{ {
v = boost::any(FallbackMap()); v = boost::any(FallbackMap());
} }
FallbackMap *map = boost::any_cast<FallbackMap>(&v); FallbackMap *map = boost::any_cast<FallbackMap>(&v);
for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it) for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
{ {
std::string temp = Files::EscapeHashString::processString(*it); std::string temp = Files::EscapeHashString::processString(*it);
int sep = temp.find(","); int sep = temp.find(",");
if (sep < 1 || sep == (int)temp.length() - 1) if (sep < 1 || sep == (int)temp.length() - 1)
#if (BOOST_VERSION < 104200) #if (BOOST_VERSION < 104200)
throw boost::program_options::validation_error("invalid value"); throw boost::program_options::validation_error("invalid value");
#else #else
throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value); throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value);
#endif #endif
std::string key(temp.substr(0, sep)); std::string key(temp.substr(0, sep));
std::string value(temp.substr(sep + 1)); std::string value(temp.substr(sep + 1));
if (map->mMap.find(key) == map->mMap.end()) if (map->mMap.find(key) == map->mMap.end())
{ {
map->mMap.insert(std::make_pair(key, value)); map->mMap.insert(std::make_pair(key, value));
} }
} }
} }
} }
namespace Files { namespace Files {
void validate(boost::any &v, const std::vector<std::string> &tokens, Files::EscapeHashString * eHS, int a) void validate(boost::any &v, const std::vector<std::string> &tokens, Files::EscapeHashString * eHS, int a)
{ {
boost::program_options::validators::check_first_occurrence(v); boost::program_options::validators::check_first_occurrence(v);
if (v.empty()) if (v.empty())
v = boost::any(EscapeHashString(boost::program_options::validators::get_single_string(tokens))); v = boost::any(EscapeHashString(boost::program_options::validators::get_single_string(tokens)));
} }
} }
#endif #endif

@ -142,9 +142,9 @@ bool ConfigurationManager::loadConfig(const boost::filesystem::path& path,
std::cout << "Loading config file: " << cfgFile.string() << "... "; std::cout << "Loading config file: " << cfgFile.string() << "... ";
boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile); boost::filesystem::ifstream configFileStreamUnfiltered(cfgFile);
boost::iostreams::filtering_istream configFileStream; boost::iostreams::filtering_istream configFileStream;
configFileStream.push(escape_hash_filter()); configFileStream.push(escape_hash_filter());
configFileStream.push(configFileStreamUnfiltered); configFileStream.push(configFileStreamUnfiltered);
if (configFileStreamUnfiltered.is_open()) if (configFileStreamUnfiltered.is_open())
{ {
boost::program_options::store(boost::program_options::parse_config_file( boost::program_options::store(boost::program_options::parse_config_file(
@ -179,80 +179,80 @@ escape_hash_filter::~escape_hash_filter()
template <typename Source> template <typename Source>
int escape_hash_filter::get(Source & src) int escape_hash_filter::get(Source & src)
{ {
if (mNext.empty()) if (mNext.empty())
{ {
int character = boost::iostreams::get(src); int character = boost::iostreams::get(src);
bool record = true; bool record = true;
if (character == boost::iostreams::WOULD_BLOCK) if (character == boost::iostreams::WOULD_BLOCK)
{ {
mNext.push(character); mNext.push(character);
record = false; record = false;
} }
else if (character == EOF) else if (character == EOF)
{ {
mSeenNonWhitespace = false; mSeenNonWhitespace = false;
mFinishLine = false; mFinishLine = false;
mNext.push(character); mNext.push(character);
} }
else if (character == '\n') else if (character == '\n')
{ {
mSeenNonWhitespace = false; mSeenNonWhitespace = false;
mFinishLine = false; mFinishLine = false;
mNext.push(character); mNext.push(character);
} }
else if (mFinishLine) else if (mFinishLine)
{ {
mNext.push(character); mNext.push(character);
} }
else if (character == '#') else if (character == '#')
{ {
if (mSeenNonWhitespace) if (mSeenNonWhitespace)
{ {
mNext.push(sEscape); mNext.push(sEscape);
mNext.push(sHashIdentifier); mNext.push(sHashIdentifier);
} }
else else
{ {
//it's fine being interpreted by Boost as a comment, and so is anything afterwards //it's fine being interpreted by Boost as a comment, and so is anything afterwards
mNext.push(character); mNext.push(character);
mFinishLine = true; mFinishLine = true;
} }
} }
else if (mPrevious == sEscape) else if (mPrevious == sEscape)
{ {
mNext.push(sEscape); mNext.push(sEscape);
mNext.push(sEscapeIdentifier); mNext.push(sEscapeIdentifier);
} }
else else
{ {
mNext.push(character); mNext.push(character);
} }
if (!mSeenNonWhitespace && !isspace(character)) if (!mSeenNonWhitespace && !isspace(character))
mSeenNonWhitespace = true; mSeenNonWhitespace = true;
if (record) if (record)
mPrevious = character; mPrevious = character;
} }
int retval = mNext.front(); int retval = mNext.front();
mNext.pop(); mNext.pop();
return retval; return retval;
} }
std::string EscapeHashString::processString(const std::string & str) std::string EscapeHashString::processString(const std::string & str)
{ {
std::string temp = boost::replace_all_copy<std::string>(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#"); std::string temp = boost::replace_all_copy<std::string>(str, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sHashIdentifier, "#");
boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, std::string((char) escape_hash_filter::sEscape, 1)); boost::replace_all(temp, std::string() + (char)escape_hash_filter::sEscape + (char)escape_hash_filter::sEscapeIdentifier, std::string((char) escape_hash_filter::sEscape, 1));
return temp; return temp;
} }
std::vector<std::string> EscapeHashString::toStdStringVector(const std::vector<EscapeHashString> & vec) std::vector<std::string> EscapeHashString::toStdStringVector(const std::vector<EscapeHashString> & vec)
{ {
std::vector<std::string> temp = std::vector<std::string>(); std::vector<std::string> temp = std::vector<std::string>();
for (std::vector<EscapeHashString>::const_iterator it = vec.begin(); it != vec.end(); ++it) for (std::vector<EscapeHashString>::const_iterator it = vec.begin(); it != vec.end(); ++it)
{ {
temp.push_back(it->toStdString()); temp.push_back(it->toStdString());
} }
return temp; return temp;
} }
EscapeHashString::EscapeHashString() : mData() EscapeHashString::EscapeHashString() : mData()
@ -286,12 +286,12 @@ EscapeHashString::EscapeHashString(InputIterator first, InputIterator last) : mD
std::string EscapeHashString::toStdString() const std::string EscapeHashString::toStdString() const
{ {
return std::string(mData); return std::string(mData);
} }
std::string * EscapeHashString::toStdStringPtr() const std::string * EscapeHashString::toStdStringPtr() const
{ {
return new std::string(mData); return new std::string(mData);
} }
const boost::filesystem::path& ConfigurationManager::getGlobalPath() const const boost::filesystem::path& ConfigurationManager::getGlobalPath() const

@ -71,21 +71,21 @@ struct ConfigurationManager
*/ */
struct escape_hash_filter : public boost::iostreams::input_filter struct escape_hash_filter : public boost::iostreams::input_filter
{ {
static const int sEscape; static const int sEscape;
static const int sHashIdentifier; static const int sHashIdentifier;
static const int sEscapeIdentifier; static const int sEscapeIdentifier;
escape_hash_filter(); escape_hash_filter();
virtual ~escape_hash_filter(); virtual ~escape_hash_filter();
template <typename Source> int get(Source & src); template <typename Source> int get(Source & src);
private: private:
std::queue<int> mNext; std::queue<int> mNext;
int mPrevious; int mPrevious;
bool mSeenNonWhitespace; bool mSeenNonWhitespace;
bool mFinishLine; bool mFinishLine;
}; };
/** /**
@ -93,23 +93,23 @@ struct escape_hash_filter : public boost::iostreams::input_filter
*/ */
class EscapeHashString : public std::string class EscapeHashString : public std::string
{ {
private: private:
std::string mData; std::string mData;
public: public:
static std::string processString(const std::string & str); static std::string processString(const std::string & str);
static std::vector<std::string> toStdStringVector(const std::vector<EscapeHashString> & vec); static std::vector<std::string> toStdStringVector(const std::vector<EscapeHashString> & vec);
EscapeHashString(); EscapeHashString();
EscapeHashString(const std::string & str); EscapeHashString(const std::string & str);
EscapeHashString(const std::string & str, size_t pos, size_t len = std::string::npos); EscapeHashString(const std::string & str, size_t pos, size_t len = std::string::npos);
EscapeHashString(const char * s); EscapeHashString(const char * s);
EscapeHashString(const char * s, size_t n); EscapeHashString(const char * s, size_t n);
EscapeHashString(size_t n, char c); EscapeHashString(size_t n, char c);
template <class InputIterator> template <class InputIterator>
EscapeHashString(InputIterator first, InputIterator last); EscapeHashString(InputIterator first, InputIterator last);
std::string toStdString() const; std::string toStdString() const;
std::string * toStdStringPtr() const; std::string * toStdStringPtr() const;
}; };
} /* namespace Cfg */ } /* namespace Cfg */

Loading…
Cancel
Save