mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-09 03:57:51 +03:00
Merge branch 'string_view' into 'master'
Move a couple of files from `const std::string&` to `std::string_view` See merge request OpenMW/openmw!1901
This commit is contained in:
commit
8dd3e53a30
6 changed files with 14 additions and 17 deletions
|
@ -284,7 +284,7 @@ void loadCell(const Arguments& info, ESM::Cell &cell, ESM::ESMReader &esm, ESMDa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void printRawTes3(const std::string& path)
|
void printRawTes3(std::string_view path)
|
||||||
{
|
{
|
||||||
std::cout << "TES3 RAW file listing: " << path << '\n';
|
std::cout << "TES3 RAW file listing: " << path << '\n';
|
||||||
ESM::ESMReader esm;
|
ESM::ESMReader esm;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void ESMReader::resolveParentFileIndices(const std::vector<ESMReader>& allPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESMReader::openRaw(std::unique_ptr<std::istream>&& stream, const std::string& name)
|
void ESMReader::openRaw(std::unique_ptr<std::istream>&& stream, std::string_view name)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
mEsm = std::move(stream);
|
mEsm = std::move(stream);
|
||||||
|
@ -94,9 +94,9 @@ void ESMReader::openRaw(std::unique_ptr<std::istream>&& stream, const std::strin
|
||||||
mEsm->seekg(0, mEsm->beg);
|
mEsm->seekg(0, mEsm->beg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESMReader::openRaw(const std::string& filename)
|
void ESMReader::openRaw(std::string_view filename)
|
||||||
{
|
{
|
||||||
openRaw(Files::openBinaryInputFileStream(filename), filename);
|
openRaw(Files::openBinaryInputFileStream(std::string(filename)), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ESMReader::open(std::unique_ptr<std::istream>&& stream, const std::string &name)
|
void ESMReader::open(std::unique_ptr<std::istream>&& stream, const std::string &name)
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
/// Raw opening. Opens the file and sets everything up but doesn't
|
/// Raw opening. Opens the file and sets everything up but doesn't
|
||||||
/// parse the header.
|
/// parse the header.
|
||||||
void openRaw(std::unique_ptr<std::istream>&& stream, const std::string &name);
|
void openRaw(std::unique_ptr<std::istream>&& stream, std::string_view name);
|
||||||
|
|
||||||
/// Load ES file from a new stream, parses the header. Closes the
|
/// Load ES file from a new stream, parses the header. Closes the
|
||||||
/// currently open file first, if any.
|
/// currently open file first, if any.
|
||||||
|
@ -69,7 +69,7 @@ public:
|
||||||
|
|
||||||
void open(const std::string &file);
|
void open(const std::string &file);
|
||||||
|
|
||||||
void openRaw(const std::string &filename);
|
void openRaw(std::string_view filename);
|
||||||
|
|
||||||
/// Get the current position in the file. Make sure that the file has been opened!
|
/// Get the current position in the file. Make sure that the file has been opened!
|
||||||
size_t getFileOffset() const { return mEsm->tellg(); };
|
size_t getFileOffset() const { return mEsm->tellg(); };
|
||||||
|
|
|
@ -292,12 +292,9 @@ namespace Shader
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap", "bumpMap", "glossMap" };
|
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap", "bumpMap", "glossMap" };
|
||||||
bool isTextureNameRecognized(const std::string& name)
|
bool isTextureNameRecognized(std::string_view name)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<sizeof(defaultTextures)/sizeof(defaultTextures[0]); ++i)
|
return std::find(std::begin(defaultTextures), std::end(defaultTextures), name) != std::end(defaultTextures);
|
||||||
if (name == defaultTextures[i])
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderVisitor::applyStateSet(osg::ref_ptr<osg::StateSet> stateset, osg::Node& node)
|
void ShaderVisitor::applyStateSet(osg::ref_ptr<osg::StateSet> stateset, osg::Node& node)
|
||||||
|
|
|
@ -348,7 +348,7 @@ std::string_view Utf8Encoder::getLegacyEnc(std::string_view input)
|
||||||
return mImpl.getLegacyEnc(input, BufferAllocationPolicy::UseGrowFactor, mBuffer);
|
return mImpl.getLegacyEnc(input, BufferAllocationPolicy::UseGrowFactor, mBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ToUTF8::FromType ToUTF8::calculateEncoding(const std::string& encodingName)
|
ToUTF8::FromType ToUTF8::calculateEncoding(std::string_view encodingName)
|
||||||
{
|
{
|
||||||
if (encodingName == "win1250")
|
if (encodingName == "win1250")
|
||||||
return ToUTF8::WINDOWS_1250;
|
return ToUTF8::WINDOWS_1250;
|
||||||
|
@ -357,10 +357,10 @@ ToUTF8::FromType ToUTF8::calculateEncoding(const std::string& encodingName)
|
||||||
else if (encodingName == "win1252")
|
else if (encodingName == "win1252")
|
||||||
return ToUTF8::WINDOWS_1252;
|
return ToUTF8::WINDOWS_1252;
|
||||||
else
|
else
|
||||||
throw std::runtime_error(std::string("Unknown encoding '") + encodingName + std::string("', see openmw --help for available options."));
|
throw std::runtime_error("Unknown encoding '" + std::string(encodingName) + "', see openmw --help for available options.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToUTF8::encodingUsingMessage(const std::string& encodingName)
|
std::string ToUTF8::encodingUsingMessage(std::string_view encodingName)
|
||||||
{
|
{
|
||||||
if (encodingName == "win1250")
|
if (encodingName == "win1250")
|
||||||
return "Using Central and Eastern European font encoding.";
|
return "Using Central and Eastern European font encoding.";
|
||||||
|
@ -369,5 +369,5 @@ std::string ToUTF8::encodingUsingMessage(const std::string& encodingName)
|
||||||
else if (encodingName == "win1252")
|
else if (encodingName == "win1252")
|
||||||
return "Using default (English) font encoding.";
|
return "Using default (English) font encoding.";
|
||||||
else
|
else
|
||||||
throw std::runtime_error(std::string("Unknown encoding '") + encodingName + std::string("', see openmw --help for available options."));
|
throw std::runtime_error("Unknown encoding '" + std::string(encodingName) + "', see openmw --help for available options.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace ToUTF8
|
||||||
UseGrowFactor,
|
UseGrowFactor,
|
||||||
};
|
};
|
||||||
|
|
||||||
FromType calculateEncoding(const std::string& encodingName);
|
FromType calculateEncoding(std::string_view encodingName);
|
||||||
std::string encodingUsingMessage(const std::string& encodingName);
|
std::string encodingUsingMessage(std::string_view encodingName);
|
||||||
|
|
||||||
class StatelessUtf8Encoder
|
class StatelessUtf8Encoder
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue