projects
/
libdcp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add OK note when PKL and CPL annotation texts match.
[libdcp.git]
/
src
/
name_format.cc
diff --git
a/src/name_format.cc
b/src/name_format.cc
index 7b9cfd634760b1b57d6dd399729da6cdb2b9d150..dce0935bb2f92f673669b03c532a818106167182 100644
(file)
--- a/
src/name_format.cc
+++ b/
src/name_format.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016
-2021
Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
This file is part of libdcp.
@@
-31,15
+31,22
@@
files in the program, then also delete it here.
*/
files in the program, then also delete it here.
*/
+
+/** @file src/name_format.cc
+ * @brief NameFormat class
+ */
+
+
#include "name_format.h"
#include <boost/optional.hpp>
#include "name_format.h"
#include <boost/optional.hpp>
-#include <boost/foreach.hpp>
+
using std::string;
using std::map;
using boost::optional;
using namespace dcp;
using std::string;
using std::map;
using boost::optional;
using namespace dcp;
+
static char
filter (char c)
{
static char
filter (char c)
{
@@
-48,10
+55,16
@@
filter (char c)
} else if (c == ' ') {
c = '_';
}
} else if (c == ' ') {
c = '_';
}
+#ifdef LIBDCP_WINDOWS
+ else if (c == '?' || c == '.') {
+ c = '_';
+ }
+#endif
return c;
}
return c;
}
+
static string
filter (string c)
{
static string
filter (string c)
{
@@
-64,15
+77,17
@@
filter (string c)
return o;
}
return o;
}
+
string
string
-NameFormat::get (Map values, string suffix) const
+NameFormat::get (Map values, string suffix
, string ignore
) const
{
string result;
for (size_t i = 0; i < _specification.length(); ++i) {
bool done = false;
if (_specification[i] == '%' && (i < _specification.length() - 1)) {
{
string result;
for (size_t i = 0; i < _specification.length(); ++i) {
bool done = false;
if (_specification[i] == '%' && (i < _specification.length() - 1)) {
- Map::const_iterator j = values.find(_specification[i + 1]);
- if (j != values.end()) {
+ char const key = _specification[i + 1];
+ auto j = values.find(key);
+ if (j != values.end() && ignore.find(key) == string::npos) {
result += filter (j->second);
++i;
done = true;
result += filter (j->second);
++i;
done = true;
@@
-87,6
+102,7
@@
NameFormat::get (Map values, string suffix) const
return result + suffix;
}
return result + suffix;
}
+
bool
dcp::operator== (NameFormat const & a, NameFormat const & b)
{
bool
dcp::operator== (NameFormat const & a, NameFormat const & b)
{