diff --git a/include/docpp.hpp b/include/docpp.hpp index 760bf6a..1828ef9 100644 --- a/include/docpp.hpp +++ b/include/docpp.hpp @@ -97,16 +97,31 @@ namespace docpp { * @return std::string The key of the property */ std::string getKey() const; + /** + * @brief Get the key of the property in a specific type + * @return T The key of the property + */ + template T getKey() const; /** * @brief Get the value of the property * @return std::string The value of the property */ std::string getValue() const; + /** + * @brief Get the value of the property in a specific type + * @return T The value of the property + */ + template T getValue() const; /** * @brief Get the property. * @return std::pair The value of the property */ std::pair get() const; + /** + * @brief Get the property in a specific type. + * @return std::pair The value of the property + */ + template std::pair get() const; /** * @brief Set the key of the property. * @param key The key. @@ -332,12 +347,23 @@ namespace docpp { * @return std::string The data of the element */ std::string getTag() const; + /** + * @brief Get the tag of the element in a specific type + * @return T The tag of the element + */ + template T getTag() const; /** * @brief Get the data of the element * @return std::string The data of the element */ std::string getData() const; + /** + * @brief Get the data of the element in a specific type + * @return T The data of the element + */ + template T getData() const; + Element operator=(const Element& element); void operator+=(const std::string& data); }; @@ -609,6 +635,11 @@ namespace docpp { * @return std::string The doctype of the document */ std::string getDoctype() const; + /** + * @brief Get the doctype of the document in a specific type + * @return T The doctype of the document + */ + template T getDoctype() const; /** * @brief Set the document @@ -677,16 +708,31 @@ namespace docpp { * @return std::string The key of the property */ std::string getKey() const; + /** + * @brief Get the key of the property in a specific type + * @return T The key of the property + */ + template T getKey() const; /** * @brief Get the value of the property * @return std::string The value of the property */ std::string getValue() const; + /** + * @brief Get the value of the property in a specific type + * @return T The value of the property + */ + template T getValue() const; /** * @brief Get the property. * @return std::pair The value of the property */ std::pair get() const; + /** + * @brief Get the property in a specific type. + * @return std::pair The value of the property + */ + template std::pair get() const; /** * @brief Set the key of the property. * @param key The key. @@ -877,6 +923,11 @@ namespace docpp { * @return std::string The tag of the element */ std::string getTag() const; + /** + * @brief Get the tag of the element in a specific type + * @return T The tag of the element + */ + template T getTag() const; /** * @brief Get the properties of the element * @return std::vector The properties of the element diff --git a/src/docpp.cpp b/src/docpp.cpp index 922763e..a7390ca 100644 --- a/src/docpp.cpp +++ b/src/docpp.cpp @@ -22,14 +22,26 @@ std::string docpp::HTML::Property::getKey() const { return this->property.first; } +template T docpp::HTML::Property::getKey() const { + return T(this->property.first); +} + std::string docpp::HTML::Property::getValue() const { return this->property.second; } +template T docpp::HTML::Property::getValue() const { + return T(this->property.second); +} + std::pair docpp::HTML::Property::get() const { return this->property; } +template std::pair docpp::HTML::Property::get() const { + return T(this->property); +} + void docpp::HTML::Property::setKey(const std::string& key) { this->property.first = key; } @@ -236,10 +248,18 @@ std::string docpp::HTML::Element::getTag() const { return this->tag; } +template T docpp::HTML::Element::getTag() const { + return T(this->tag); +} + std::string docpp::HTML::Element::getData() const { return this->data; } +template T docpp::HTML::Element::getData() const { + return T(this->data); +} + docpp::HTML::Section::Section(const std::string& tag, const Properties& properties) { this->tag = tag; this->properties = properties; @@ -615,6 +635,10 @@ std::string docpp::HTML::Document::getDoctype() const { return this->doctype; } +template T docpp::HTML::Document::getDoctype() const { + return T(this->doctype); +} + docpp::CSS::Property::Property(const std::string& key, const std::string& value) { this->set(key, value); } @@ -627,14 +651,26 @@ std::string docpp::CSS::Property::getKey() const { return this->property.first; } +template T docpp::CSS::Property::getKey() const { + return T(this->property.first); +} + std::string docpp::CSS::Property::getValue() const { return this->property.second; } +template T docpp::CSS::Property::getValue() const { + return T(this->property.second); +} + std::pair docpp::CSS::Property::get() const { return this->property; } +template std::pair docpp::CSS::Property::get() const { + return std::pair(this->property.first, this->property.second); +} + void docpp::CSS::Property::setKey(const std::string& key) { this->property.first = key; } @@ -812,6 +848,10 @@ std::string docpp::CSS::Element::getTag() const { return this->element.first; } +template T docpp::CSS::Element::getTag() const { + return T(this->element.first); +} + std::vector docpp::CSS::Element::getProperties() const { return this->element.second; }