/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
files in the program, then also delete it here.
*/
+
+/** @file src/name_format.h
+ * @brief NameFormat class
+ */
+
+
#ifndef LIBDCP_NAME_FORMAT
#define LIBDCP_NAME_FORMAT
+
+#include <string>
#include <boost/optional.hpp>
#include <map>
#include <list>
+
namespace dcp {
+
class NameFormat
{
public:
- struct Component
- {
- Component (std::string name_, char placeholder_, std::string title_)
- : name (name_)
- , placeholder (placeholder_)
- , title (title_)
- {}
-
- std::string name;
- char placeholder;
- std::string title;
- };
-
- std::list<Component> components () const {
- return _components;
- }
+ NameFormat () {}
+
+ NameFormat (std::string specification)
+ : _specification (specification)
+ {}
std::string specification () const {
return _specification;
_specification = specification;
}
- typedef std::map<std::string, std::string> Map;
+ typedef std::map<char, std::string> Map;
- std::string get (Map) const;
-
-protected:
- NameFormat () {}
-
- NameFormat (std::string specification)
- : _specification (specification)
- {}
-
- void add (std::string name, char placeholder, std::string title);
+ /** @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.
+ */
+ std::string get (Map, std::string suffix, std::string ignore = "") const;
private:
- boost::optional<NameFormat::Component> component_by_placeholder (char p) const;
-
- std::list<Component> _components;
std::string _specification;
};
+
extern bool operator== (NameFormat const & a, NameFormat const & b);
+
}
+
#endif