Commit d946508a authored by jan.koester's avatar jan.koester
Browse files

fixed mem crash

parent b613e501
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -2400,6 +2400,22 @@ libhtmlpp::Element* libhtmlpp::HtmlElement::firstChild() const {
    return _childElement.get();
}

const std::string libhtmlpp::HtmlElement::Attributes::getKey() const {
    return std::string(_Key.begin(), _Key.end());
}

const std::string libhtmlpp::HtmlElement::Attributes::getValue() const {
    return std::string(_Value.begin(), _Value.end());
}

libhtmlpp::HtmlElement::Attributes* libhtmlpp::HtmlElement::Attributes::nextAttribute() const {
    return _nextAttr.get();
}

const libhtmlpp::HtmlElement::Attributes* libhtmlpp::HtmlElement::firstAttribute() const {
    return _firstAttr.get();
}

void libhtmlpp::HtmlElement::setAttribute(const std::string &name, const std::string &value) {
    Attributes* cattr = nullptr;

+20 −8
Original line number Diff line number Diff line
@@ -140,22 +140,34 @@ namespace libhtmlpp {

        Element*     firstChild() const;

        int    getType() const;
        void   remove(Element* el);

        static size_t parseElement(const std::vector<char> &in,std::unique_ptr<libhtmlpp::Element> &el,size_t start,bool &termination);
    protected:

        std::unique_ptr<Element>  _childElement=nullptr;

        struct Attributes {
            Attributes();
            ~Attributes();

            const std::string getKey() const;
            const std::string getValue() const;
            Attributes*       nextAttribute() const;

        private:
            std::vector<char>                _Key;
            std::vector<char>                _Value;
            std::unique_ptr<Attributes> _nextAttr;

            friend class HtmlElement;
            friend void  print(const Element& element, HtmlString &output,bool formated);
            friend void _copy(libhtmlpp::Element *dest,const libhtmlpp::Element *src);
        };

        const Attributes* firstAttribute() const;

        int    getType() const;
        void   remove(Element* el);

        static size_t parseElement(const std::vector<char> &in,std::unique_ptr<libhtmlpp::Element> &el,size_t start,bool &termination);
    protected:

        std::unique_ptr<Element>  _childElement=nullptr;

        void _serialelize(const std::vector<char> &in);
    private:
        //if text tagname must be zero