Fix format

This commit is contained in:
Konstantin Vukolov 2026-01-17 01:46:52 +03:00
parent a89a33b595
commit 5cd56af350
6 changed files with 41 additions and 55 deletions

View File

@ -23,9 +23,9 @@ OpdsParser::~OpdsParser() {
} }
void OpdsParser::push(const char* xmlData, const size_t length) { void OpdsParser::push(const char* xmlData, const size_t length) {
if (errorOccured) { if (errorOccured) {
return; return;
} }
XML_SetUserData(parser, this); XML_SetUserData(parser, this);
XML_SetElementHandler(parser, startElement, endElement); XML_SetElementHandler(parser, startElement, endElement);
@ -64,16 +64,14 @@ void OpdsParser::push(const char* xmlData, const size_t length) {
} }
void OpdsParser::finish() { void OpdsParser::finish() {
if (XML_Parse(parser, nullptr, 0, XML_TRUE) != XML_STATUS_OK) { if (XML_Parse(parser, nullptr, 0, XML_TRUE) != XML_STATUS_OK) {
errorOccured = true; errorOccured = true;
XML_ParserFree(parser); XML_ParserFree(parser);
parser = nullptr; parser = nullptr;
} }
} }
bool OpdsParser::error() const { bool OpdsParser::error() const { return errorOccured; }
return errorOccured;
}
void OpdsParser::clear() { void OpdsParser::clear() {
entries.clear(); entries.clear();

View File

@ -59,7 +59,7 @@ class OpdsParser {
* Get the parsed entries (both navigation and book entries). * Get the parsed entries (both navigation and book entries).
* @return Vector of OpdsEntry entries * @return Vector of OpdsEntry entries
*/ */
const std::vector<OpdsEntry>& getEntries() const & { return entries; } const std::vector<OpdsEntry>& getEntries() const& { return entries; }
std::vector<OpdsEntry> getEntries() && { return std::move(entries); } std::vector<OpdsEntry> getEntries() && { return std::move(entries); }
/** /**

View File

@ -2,29 +2,20 @@
OpdsParserStream::OpdsParserStream(OpdsParser& parser) : parser(parser) {} OpdsParserStream::OpdsParserStream(OpdsParser& parser) : parser(parser) {}
int OpdsParserStream::available() { return 0; }
int OpdsParserStream::available() { int OpdsParserStream::peek() { abort(); }
return 0;
}
int OpdsParserStream::peek() { int OpdsParserStream::read() { abort(); }
abort();
}
int OpdsParserStream::read() {
abort();
}
size_t OpdsParserStream::write(uint8_t c) { size_t OpdsParserStream::write(uint8_t c) {
parser.push(reinterpret_cast<const char*>(&c), 1); parser.push(reinterpret_cast<const char*>(&c), 1);
return 1; return 1;
} }
size_t OpdsParserStream::write(const uint8_t *buffer, size_t size) { size_t OpdsParserStream::write(const uint8_t* buffer, size_t size) {
parser.push(reinterpret_cast<const char*>(buffer), size); parser.push(reinterpret_cast<const char*>(buffer), size);
return size; return size;
} }
OpdsParserStream::~OpdsParserStream() { OpdsParserStream::~OpdsParserStream() { parser.finish(); }
parser.finish();
}

View File

@ -1,23 +1,23 @@
#pragma once #pragma once
#include "OpdsParser.h"
#include <Stream.h> #include <Stream.h>
#include "OpdsParser.h"
class OpdsParserStream : public Stream { class OpdsParserStream : public Stream {
public: public:
explicit OpdsParserStream(OpdsParser& parser); explicit OpdsParserStream(OpdsParser& parser);
// That functions are not implimented for that stream // That functions are not implimented for that stream
int available() override; int available() override;
int peek() override; int peek() override;
int read() override; int read() override;
virtual size_t write(uint8_t c) override; virtual size_t write(uint8_t c) override;
virtual size_t write(const uint8_t *buffer, size_t size) override; virtual size_t write(const uint8_t* buffer, size_t size) override;
~OpdsParserStream() override; ~OpdsParserStream() override;
private: private:
OpdsParser& parser; OpdsParser& parser;
}; };

View File

@ -2,9 +2,8 @@
#include <GfxRenderer.h> #include <GfxRenderer.h>
#include <HardwareSerial.h> #include <HardwareSerial.h>
#include <WiFi.h>
#include <OpdsStream.h> #include <OpdsStream.h>
#include <WiFi.h>
#include "CrossPointSettings.h" #include "CrossPointSettings.h"
#include "MappedInputManager.h" #include "MappedInputManager.h"
@ -269,16 +268,15 @@ void OpdsBookBrowserActivity::fetchFeed(const std::string& path) {
OpdsParser parser; OpdsParser parser;
{ {
OpdsParserStream stream{parser}; OpdsParserStream stream{parser};
if (!HttpDownloader::fetchUrl(url, stream)) { if (!HttpDownloader::fetchUrl(url, stream)) {
state = BrowserState::ERROR; state = BrowserState::ERROR;
errorMessage = "Failed to fetch feed"; errorMessage = "Failed to fetch feed";
updateRequired = true; updateRequired = true;
return; return;
} }
} }
if (parser.error()) { if (parser.error()) {
state = BrowserState::ERROR; state = BrowserState::ERROR;
errorMessage = "Failed to parse feed"; errorMessage = "Failed to parse feed";

View File

@ -2,11 +2,10 @@
#include <HTTPClient.h> #include <HTTPClient.h>
#include <HardwareSerial.h> #include <HardwareSerial.h>
#include <StreamString.h>
#include <WiFiClient.h> #include <WiFiClient.h>
#include <WiFiClientSecure.h> #include <WiFiClientSecure.h>
#include <StreamString.h>
#include <memory> #include <memory>
#include "util/UrlUtils.h" #include "util/UrlUtils.h"