strbuffer: use static initializer instead of variadic constructor

master
Andrzej Rybczak 12 years ago
parent e9a539f8ee
commit 42dce36625
  1. 12
      src/settings.cpp
  2. 16
      src/strbuffer.h

@ -306,30 +306,30 @@ bool Configuration::read(const std::string &config_path)
new_header_second_line, "{{$4$b%a$/b$9}{ - $7%b$9}{ ($4%y$9)}}|{%D}", adjust_and_validate_format
));
p.add("now_playing_prefix", buffer(
now_playing_prefix, NC::Buffer(NC::Format::Bold), [this](NC::Buffer buf) {
now_playing_prefix, NC::Buffer::init(NC::Format::Bold), [this](NC::Buffer buf) {
now_playing_prefix_length = wideLength(ToWString(buf.str()));
return buf;
}));
p.add("now_playing_suffix", buffer(
now_playing_suffix, NC::Buffer(NC::Format::NoBold), [this](NC::Buffer buf) {
now_playing_suffix, NC::Buffer::init(NC::Format::NoBold), [this](NC::Buffer buf) {
now_playing_suffix_length = wideLength(ToWString(buf.str()));
return buf;
}));
p.add("browser_playlist_prefix", buffer(
browser_playlist_prefix, NC::Buffer(NC::Color::Red, "playlist", NC::Color::End, ' '), id_()
browser_playlist_prefix, NC::Buffer::init(NC::Color::Red, "playlist", NC::Color::End, ' '), id_()
));
p.add("selected_item_prefix", buffer(
selected_item_prefix, NC::Buffer(NC::Color::Magenta), [this](NC::Buffer buf) {
selected_item_prefix, NC::Buffer::init(NC::Color::Magenta), [this](NC::Buffer buf) {
selected_item_prefix_length = wideLength(ToWString(buf.str()));
return buf;
}));
p.add("selected_item_suffix", buffer(
selected_item_suffix, NC::Buffer(NC::Color::End), [this](NC::Buffer buf) {
selected_item_suffix, NC::Buffer::init(NC::Color::End), [this](NC::Buffer buf) {
selected_item_suffix_length = wideLength(ToWString(buf.str()));
return buf;
}));
p.add("modified_item_prefix", buffer(
modified_item_prefix, NC::Buffer(NC::Color::Green, "> ", NC::Color::End), id_()
modified_item_prefix, NC::Buffer::init(NC::Color::Green, "> ", NC::Color::End), id_()
));
p.add("song_window_title_format", assign_default<std::string>(
song_window_title_format, "{%a - }{%t}|{%f}", adjust_and_validate_format

@ -90,12 +90,6 @@ public:
typedef std::basic_string<CharT> StringType;
typedef std::set<Property> Properties;
template <typename... Args>
BasicBuffer(Args&&... args)
{
construct(std::forward<Args>(args)...);
}
const StringType &str() const { return m_string; }
const Properties &properties() const { return m_properties; }
@ -187,6 +181,16 @@ public:
return *this;
}
// static variadic initializer. used instead of a proper constructor because
// it's too polymorphic and would end up invoked as a copy/move constructor.
template <typename... Args>
static BasicBuffer init(Args&&... args)
{
BasicBuffer result;
result.construct(std::forward<Args>(args)...);
return result;
}
private:
void construct() { }
template <typename ArgT, typename... Args>

Loading…
Cancel
Save