#include "badge.h" constexpr const char* openBracket("<"); constexpr const char* closeBracket(">"); constexpr const char* svgTag("svg"); constexpr const char* titleTag("title"); constexpr const char* svgAttrs = "xmlns=\"http://www.w3.org/2000/svg\" " "xmlns:xlink=\"http://www.w3.org/1999/xlink\" " "width=\"134\" " "height=\"20\" " "role=\"img\""; constexpr const char* ariaLabel("aria-label"); Badge::Badge(Badge::Kind kind, const std::string& title, const std::string& value, const std::string& color): Response(Type::image), kind(kind), title(title), value(value), color(color) {} Badge::~Badge() {} void Badge::writeHeader(std::ostream& out) const { out << status200Header << newLine; out << contentTypeSVG; out << headerTerminator; } void Badge::writeBody(std::ostream& out) const { out << openBracket << svgTag << " "; out << svgAttrs << " "; out << ariaLabel << "=\"" << title << ": " << value << "\""; out << closeBracket; out << openBracket << titleTag << closeBracket; out << title << ": " << value; out << openBracket << "/" << titleTag << closeBracket; //may be gradients //may be round corners out << ""; out << ""; out << openBracket << "/" << svgTag << closeBracket; } /** Documentation: HTMLDocumentationHTML */