Fix to allow re-writing of SMPTE subtitles.
[libdcp.git] / src / name_format.cc
index 300ff3158b9a395bf996f59e90b7100beb3cf71c..76cca3fd3d45e2edbba4fc8d74df256d9f8e15b5 100644 (file)
@@ -64,21 +64,24 @@ filter (string c)
        return o;
 }
 
-void
-NameFormat::add (char placeholder)
-{
-       _components.push_back (placeholder);
-}
 
+/** @param values Values to replace our specifications with; e.g.
+ *  if the specification contains %c it will be be replaced with the
+ *  value corresponding to the key 'c'.
+ *  @param suffix Suffix to add on after processing the specification.
+ *  @param ignore Any specification characters in this string will not
+ *  be replaced, but left as-is.
+ */
 string
-NameFormat::get (Map values) 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)) {
-                       Map::const_iterator j = values.find(_specification[i + 1]);
-                       if (j != values.end()) {
+                       char const key = _specification[i + 1];
+                       Map::const_iterator j = values.find(key);
+                       if (j != values.end() && ignore.find(key) == string::npos) {
                                result += filter (j->second);
                                ++i;
                                done = true;
@@ -90,7 +93,7 @@ NameFormat::get (Map values) const
                }
        }
 
-       return result;
+       return result + suffix;
 }
 
 bool