Merge pull request 'deleted more stringstrem' (#25) from delete-more-stringstream into main
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled
Reviewed-on: https://gitea.home.com:3000/TolaMironcenko/openrouter/pulls/25
This commit was merged in pull request #25.
This commit is contained in:
commit
11028cb567
3 files changed
+20
-24
No files matched your search
@@ -1,5 +1,4 @@
|
|||||||
#include "qrtosvg.hpp"
|
#include "qrtosvg.hpp"
|
||||||
#include <sstream>
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
std::string toSvgString(const qrcodegen::QrCode& qr, int border)
|
std::string toSvgString(const qrcodegen::QrCode& qr, int border)
|
||||||
@@ -9,23 +8,23 @@ std::string toSvgString(const qrcodegen::QrCode& qr, int border)
|
|||||||
if (border > INT_MAX / 2 || border * 2 > INT_MAX - qr.getSize())
|
if (border > INT_MAX / 2 || border * 2 > INT_MAX - qr.getSize())
|
||||||
throw std::overflow_error("Border too large");
|
throw std::overflow_error("Border too large");
|
||||||
|
|
||||||
std::ostringstream sb;
|
std::string sb = "";
|
||||||
sb << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
sb += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||||
sb << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
sb += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
||||||
sb << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 ";
|
sb += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 "
|
||||||
sb << (qr.getSize() + border * 2) << " " << (qr.getSize() + border * 2) << "\" stroke=\"none\">\n";
|
+ std::to_string(qr.getSize() + border * 2) + " " + std::to_string(qr.getSize() + border * 2) + "\" stroke=\"none\">\n"
|
||||||
sb << "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n";
|
+ "\t<rect width=\"100%\" height=\"100%\" fill=\"#FFFFFF\"/>\n"
|
||||||
sb << "\t<path d=\"";
|
+ "\t<path d=\"";
|
||||||
for (int y = 0; y < qr.getSize(); y++) {
|
for (int y = 0; y < qr.getSize(); y++) {
|
||||||
for (int x = 0; x < qr.getSize(); x++) {
|
for (int x = 0; x < qr.getSize(); x++) {
|
||||||
if (qr.getModule(x, y)) {
|
if (qr.getModule(x, y)) {
|
||||||
if (x != 0 || y != 0)
|
if (x != 0 || y != 0)
|
||||||
sb << " ";
|
sb += " ";
|
||||||
sb << "M" << (x + border) << "," << (y + border) << "h1v1h-1z";
|
sb += "M" + std::to_string(x + border) + "," + std::to_string(y + border) + "h1v1h-1z";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb << "\" fill=\"#000000\"/>\n";
|
sb += "\" fill=\"#000000\"/>\n";
|
||||||
sb << "</svg>\n";
|
sb += "</svg>\n";
|
||||||
return sb.str();
|
return sb;
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <types.hpp>
|
#include <types.hpp>
|
||||||
#include <json.hpp>
|
#include <json.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <auth/auth.hpp>
|
#include <auth/auth.hpp>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
#include <sstream>
|
|
||||||
#include <types.hpp>
|
#include <types.hpp>
|
||||||
|
|
||||||
namespace api
|
namespace api
|
||||||
@@ -15,15 +14,14 @@ namespace api
|
|||||||
struct sysinfo x;
|
struct sysinfo x;
|
||||||
if (sysinfo(&x) == 0)
|
if (sysinfo(&x) == 0)
|
||||||
{
|
{
|
||||||
std::stringstream responsedata;
|
std::string responsedata(R"({"uptime":{"hour":")"
|
||||||
responsedata << R"({"uptime":{"hour":")"
|
+ std::to_string(static_cast<unsigned long long>(x.uptime) / 3600ULL)
|
||||||
<< static_cast<unsigned long long>(x.uptime) / 3600ULL
|
+ R"(","minute":")"
|
||||||
<< R"(","minute":")"
|
+ std::to_string(static_cast<unsigned long long>(x.uptime) / 60ULL % 60ULL)
|
||||||
<< static_cast<unsigned long long>(x.uptime) / 60ULL % 60ULL
|
+ R"(","second":")"
|
||||||
<< R"(","second":")"
|
+ std::to_string(static_cast<unsigned long long>(x.uptime) % 60ULL)
|
||||||
<< static_cast<unsigned long long>(x.uptime) % 60ULL
|
+ R"("}})");
|
||||||
<< R"("}})";
|
response.set_content(responsedata, JSON_TYPE);
|
||||||
response.set_content(responsedata.str(), JSON_TYPE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
response.set_content(R"({"error":"unknown"})", JSON_TYPE);
|
response.set_content(R"({"error":"unknown"})", JSON_TYPE);
|
||||||
|
|||||||
Reference in new issue
Block a user