From 735e427376ecc559428ba1d4e07643c48f0746a3 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 24 Jan 2020 02:42:13 +0100 Subject: [PATCH] Removed unused bbcode stuff --- src/bbcode/bbcodes.cpp | 56 ------------------------------------------ src/bbcode/bbcodes.h | 50 ++----------------------------------- 2 files changed, 2 insertions(+), 104 deletions(-) diff --git a/src/bbcode/bbcodes.cpp b/src/bbcode/bbcodes.cpp index 17f4f0f..e6a1fb0 100644 --- a/src/bbcode/bbcodes.cpp +++ b/src/bbcode/bbcodes.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,61 +6,6 @@ using namespace std; using namespace bbcode; -struct BBStack { - shared_ptr head = make_shared(); - shared_ptr tail = head; - - string key; - string content; -}; - -shared_ptr bbcode::parse(string message) { - string current_text; - string current_key; - - deque> stack; - stack.push_back(make_shared()); - - bool escaped = false; - bool key_begin = false; - bool key_end = false; - for(size_t i = 0; i < message.length(); i++) { - if(message[i] == '[' && (i == 0 || message[i - 1] != '\\')) { - if(!current_text.empty()) { - stack.back()->tail->next(make_shared(current_text)); - stack.back()->tail = stack.back()->tail->next(); - } - if(i + 2 < message.length() && message[i + 1] == '/') { //Should be a key end - key_end = true; - i += 1; - continue; - } else { - key_begin = true; - cout << "Message: " << current_text << endl; - stack.push_back(make_shared()); - continue; - } - } else if(message[i] == ']') { - if(key_begin) { - cout << "Got key begin '" << current_key << "'" << endl; - key_begin = false; - stack.back()->key = current_key; - current_key = ""; - continue; - } else if(key_end) { - cout << "Got key end '" << current_key << "'" << endl; - key_end = false; - continue; - } - } - - if(key_begin || key_end) current_key += message[i]; - else current_text += message[i]; - } - - return stack.front()->head; -} - bool bbcode::sloppy::has_tag(std::string message, std::deque tag) { std::transform(message.begin(), message.end(), message.begin(), ::tolower); for(auto& entry : tag) diff --git a/src/bbcode/bbcodes.h b/src/bbcode/bbcodes.h index f076e2e..fec1832 100644 --- a/src/bbcode/bbcodes.h +++ b/src/bbcode/bbcodes.h @@ -3,55 +3,9 @@ #include #include -namespace bbcode { - enum BBType { - TEXT, - URL, - IMG, - LIST, - UNKNOWN - }; - - class BBEntry { - public: - virtual ~BBEntry() = default; - virtual BBType type() const = 0; - virtual std::string build() const = 0; - - inline std::shared_ptr next() const { return this->_next; } - inline std::shared_ptr previus() const { return this->_previus; } - inline std::shared_ptr parent() const { return this->_parent.lock(); } - - inline void next(std::shared_ptr next) { this->_next = std::move(next); } - inline void previus(std::shared_ptr previus) { this->_previus = std::move(previus); } - inline void parent(std::shared_ptr parent) { this->_parent = std::move(parent); } - protected: - std::weak_ptr _parent; - std::shared_ptr _previus; - std::shared_ptr _next; - }; - - class BBText : public BBEntry { - public: - BBText(const std::string& text = "") { this->_text = text; } - - inline std::string text() const { return this->_text; } - inline void text(const std::string& text) { this->_text = text; } - - BBType type() const override { return BBType::TEXT; } - - std::string build() const override { return _text; } - - private: - std::string _text; - }; - - extern std::shared_ptr parse(std::string); - - namespace sloppy { +namespace bbcode::sloppy { extern bool has_tag(std::string message, std::deque tag); inline bool has_url(const std::string& message) { return has_tag(message, {"url"}); } inline bool has_image(const std::string& message) { return has_tag(message, {"img"}); } - } -} \ No newline at end of file + } \ No newline at end of file