atf is an implementation of the scripting language known as Advanced Title Formatting or Tagz. The language has been used by some popular applications such as Winamp, foobar2000, Mp3tag and MusicBrainz Picard.
Basically, it converts this:
[%artist% - ][%album% - ][$num(%track%,2) - ]$if2(%title%,$filepart(%filename%))
...to this:
Iron Maiden - Brave New World - 04 - Blood Brothers
(atf is currently not in a usable state.)
The library doesn't have any fields on its own. Applications have to override the EvaluateField
virtual function in order to provide the data to corresponding fields:
std::string CustomAtf::EvaluateField(const std::string& field) const {
const std::map<std::string, std::string> fields{
{"artist", "Iron Maiden"},
{"album", "Brave New World"},
{"track", "4"},
{"title", "Blood Brothers"},
};
auto it = fields.find(field);
return it != fields.end() ? it.second : std::string();
}
The library does provide you with a basic set of functions such as if
and len
. You may override the EvaluateFunction
virtual function according to your application's needs:
std::string CustomAtf::EvaluateFunction(
const std::string& name, const std::vector<std::string>& params) const {
std::string result;
// $reverse(x)
// Reverses the order of the characters in string x.
if (name == "reverse" && params.size() == 1) {
const auto& x = params.back();
std::copy_backward(x.begin(), x.end(), result.end());
return result;
}
return Atf::EvaluateFunction(name, params);
}
- Winamp ATF Reference
- foobar2000 Title Formatting Reference
- Mp3tag Scripting Functions
- MusicBrainz Picard Scripting
atf is licensed under the MIT License.