Fix remaining compilation issues with the new string system

parent a31086a5
......@@ -366,7 +366,7 @@ BOOST_PYTHON_MODULE(melanobot)
return fmt ? fmt->name() : "";
})
.def("convert",[](string::Formatter* fmt, const color::Color12& col) {
return fmt ? fmt->color(col) : "";
return fmt ? fmt->to_string(col) : "";
})
.def("convert",[](string::Formatter* fmt, const std::string& str) {
return str;
......
......@@ -205,8 +205,8 @@ protected:
<< color::red << total << color::nocolor << " maps match";
reply_to(msg, std::move(str));
auto r = string::Color(color::red).to_string(*msg.destination->formatter());
auto nc = string::Color(color::nocolor).to_string(*msg.destination->formatter());
auto r = msg.destination->formatter()->to_string(color::red);
auto nc = msg.destination->formatter()->to_string(color::nocolor);
if ( max_print >= 0 && int(maps.size()) <= max_print && !maps.empty())
reply_to(msg, r + melanolib::string::implode(nc + ", " + r, maps));
......
......@@ -285,7 +285,7 @@ void XonoticConnection::say ( const network::OutputMessage& message )
if ( !message.prefix.empty() )
prefix_stream << message.prefix << ' ' << color::nocolor;
auto nocolor = string::Color(color::nocolor).to_string(*formatter_);
auto nocolor = formatter_->to_string(color::nocolor);
std::string prefix = prefix_stream.encode(*formatter_);
std::string from = message.from.encode(*formatter_)+nocolor;
std::string contents = message.message.encode(*formatter_)+nocolor;
......
......@@ -80,8 +80,8 @@ Settings settings::initialize ( int argc, char** argv )
// Load command line options
string::FormatterAnsi fmt(true);
auto bold = fmt.format_flags(string::FormatFlags::BOLD);
auto clear = fmt.clear();
auto bold = fmt.to_string(string::FormatFlags::BOLD);
auto clear = fmt.to_string(string::ClearFormatting());
namespace po = boost::program_options;
po::options_description described_options(bold+"Options"+clear);
described_options.add_options()
......
......@@ -27,13 +27,19 @@ namespace string {
class FormatFlags
{
public:
enum FormatFlagsEnum {
enum class FormatFlagsEnum {
NO_FORMAT = 0,
BOLD = 1,
UNDERLINE = 2,
ITALIC = 4,
};
constexpr FormatFlags(FormatFlagsEnum flags) noexcept : flags(flags) {}
static constexpr auto NO_FORMAT = FormatFlagsEnum::NO_FORMAT;
static constexpr auto BOLD = FormatFlagsEnum::BOLD;
static constexpr auto UNDERLINE = FormatFlagsEnum::UNDERLINE;
static constexpr auto ITALIC = FormatFlagsEnum::ITALIC;
constexpr FormatFlags(FormatFlagsEnum flags) noexcept : flags(int(flags)) {}
constexpr FormatFlags() noexcept = default;
......@@ -104,5 +110,10 @@ private:
int flags = 0;
};
inline FormatFlags operator~ (FormatFlags::FormatFlagsEnum e)
{
return ~FormatFlags(e);
}
} // namespace string
#endif // FORMAT_FLAGS_HPP
......@@ -490,4 +490,9 @@ std::string FormatterConfig::name() const
return "config";
}
constexpr FormatFlags::FormatFlagsEnum FormatFlags::NO_FORMAT;
constexpr FormatFlags::FormatFlagsEnum FormatFlags::BOLD;
constexpr FormatFlags::FormatFlagsEnum FormatFlags::UNDERLINE;
constexpr FormatFlags::FormatFlagsEnum FormatFlags::ITALIC;
} // namespace string
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment