constexpr string conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 3a2309bfea
commit a25bbe133f

@ -690,12 +690,12 @@ namespace Exiv2 {
@brief The extension of the temporary file which is created when getting input data
to read metadata. This file will be deleted in destructor.
*/
static const std::string TEMP_FILE_EXT;
static constexpr std::string_view TEMP_FILE_EXT = ".exiv2_temp";
/*!
@brief The extension of the generated file which is created when getting input data
to add or modify the metadata.
*/
static const std::string GEN_FILE_EXT;
static constexpr std::string_view GEN_FILE_EXT = ".exiv2";
//! @name Creators
//@{

@ -53,7 +53,7 @@ namespace fs = std::filesystem;
// class member definitions
namespace {
/// @brief replace each substring of the subject that matches the given search string with the given replacement.
void ReplaceStringInPlace(std::string& subject, const std::string& search, const std::string& replace)
void ReplaceStringInPlace(std::string& subject, std::string_view search, std::string_view replace)
{
auto pos = subject.find(search);
while (pos != std::string::npos) {
@ -946,9 +946,6 @@ namespace Exiv2 {
}
#else
const std::string XPathIo::TEMP_FILE_EXT = ".exiv2_temp";
const std::string XPathIo::GEN_FILE_EXT = ".exiv2";
XPathIo::XPathIo(const std::string& orgPath) : FileIo(XPathIo::writeDataToFile(orgPath)), isTemp_(true)
{
tempFilePath_ = path();

@ -33,7 +33,7 @@ namespace {
using Exiv2::byte;
// signature of DOS EPS
const std::string dosEpsSignature = "\xC5\xD0\xD3\xC6";
constexpr auto dosEpsSignature = std::string_view("\xC5\xD0\xD3\xC6");
// first line of EPS
constexpr auto epsFirstLine = std::array<std::string_view, 3>{
@ -43,11 +43,12 @@ namespace {
};
// blank EPS file
const std::string epsBlank = "%!PS-Adobe-3.0 EPSF-3.0\n"
"%%BoundingBox: 0 0 0 0\n";
constexpr auto epsBlank = std::string_view(
"%!PS-Adobe-3.0 EPSF-3.0\n"
"%%BoundingBox: 0 0 0 0\n");
// list of all valid XMP headers
const std::string xmpHeaders[] = {
constexpr std::string_view xmpHeaders[] = {
// We do not enforce the trailing "?>" here, because the XMP specification
// permits additional attributes after begin="..." and id="...".
@ -67,23 +68,23 @@ namespace {
// list of all valid XMP trailers
struct XmpTrailer {
std::string trailer;
std::string_view trailer;
bool readOnly;
};
const XmpTrailer xmpTrailers[] = {
constexpr XmpTrailer xmpTrailers[] = {
// We do not enforce the trailing "?>" here, because the XMP specification
// permits additional attributes after end="...".
{"<?xpacket end=\"r\"", true},
{"<?xpacket end='r'", true},
{"<?xpacket end='r'", true},
{"<?xpacket end=\"w\"", false},
{"<?xpacket end='w'", false},
{"<?xpacket end='w'", false},
};
// closing part of all valid XMP trailers
const std::string xmpTrailerEnd = "?>";
constexpr auto xmpTrailerEnd = std::string_view("?>");
//! Write data into temp file, taking care of errors
void writeTemp(BasicIo& tempIo, const byte* data, size_t size)
@ -186,7 +187,7 @@ namespace {
for (size_t trailerPos = xmpPos + header.size(); trailerPos < size; trailerPos++) {
if (data[xmpPos] != '\x00' && data[xmpPos] != '<') continue;
for (auto&& xmpTrailer : xmpTrailers) {
const std::string& trailer = xmpTrailer.trailer;
auto trailer = xmpTrailer.trailer;
const bool readOnly = xmpTrailer.readOnly;
if (trailerPos + trailer.size() > size) continue;

@ -206,15 +206,14 @@ namespace Exiv2 {
chType[4]=0;
if ( option == kpsBasic || option == kpsXMP || option == kpsIccProfile || option == kpsRecursive ) {
const std::string xmpKey = "XML:com.adobe.xmp";
const std::string exifKey = "Raw profile type exif";
const std::string app1Key = "Raw profile type APP1";
const std::string iptcKey = "Raw profile type iptc";
const std::string iccKey = "icc";
const std::string softKey = "Software";
const std::string commKey = "Comment";
const std::string descKey = "Description";
constexpr auto xmpKey = "XML:com.adobe.xmp";
constexpr auto exifKey = "Raw profile type exif";
constexpr auto app1Key = "Raw profile type APP1";
constexpr auto iptcKey = "Raw profile type iptc";
constexpr auto iccKey = "icc";
constexpr auto softKey = "Software";
constexpr auto commKey = "Comment";
constexpr auto descKey = "Description";
bool bPrint = option == kpsBasic || option == kpsRecursive ;
if ( bPrint ) {

@ -831,7 +831,7 @@ namespace Exiv2 {
return value_.size();
}
static const std::string x_default = "x-default";
static constexpr auto x_default = "x-default";
std::ostream& LangAltValue::write(std::ostream& os) const
{

Loading…
Cancel
Save