[DEV] add /= and += in the uri interface

This commit is contained in:
Edouard DUPIN 2018-10-23 22:07:23 +02:00
parent c866bfe734
commit 38829891c6
2 changed files with 101 additions and 0 deletions

View File

@ -292,6 +292,73 @@ void etk::Uri::setFragment(const etk::String& _value) {
m_fragment = _value;
}
etk::Uri etk::Uri::operator/ (const etk::String& _element) const {
etk::Uri tmp = *this;
tmp /= etk::Path(_element);
return tmp;
}
etk::Uri etk::Uri::operator/ (const char* _element) const {
etk::Uri tmp = *this;
tmp /= etk::Path(_element);
return tmp;
}
etk::Uri etk::Uri::operator/ (const etk::Path& _path) const {
etk::Uri tmp = *this;
tmp /= _path;
return tmp;
}
etk::Uri& etk::Uri::operator/= (const etk::String& _element) {
*this /= etk::Path(_element);
return *this;
}
etk::Uri& etk::Uri::operator/= (const char* _element) {
*this /= etk::Path(_element);
return *this;
}
etk::Uri& etk::Uri::operator/= (const etk::Path& _path) {
m_path /= _path;
return *this;
}
etk::Uri etk::Uri::operator+ (const char* _element) const {
etk::Uri tmp = *this;
tmp += etk::Path(_element);
return tmp;
}
etk::Uri etk::Uri::operator+ (const etk::String& _element) const {
etk::Uri tmp = *this;
tmp += etk::Path(_element);
return tmp;
}
etk::Uri etk::Uri::operator+ (const etk::Path& _element) const {
etk::Uri tmp = *this;
tmp += _element;
return tmp;
}
etk::Uri& etk::Uri::operator+= (const char* _element) {
*this += etk::Path(_element);
return *this;
}
etk::Uri& etk::Uri::operator+= (const etk::String& _element) {
*this += etk::Path(_element);
return *this;
}
etk::Uri& etk::Uri::operator+= (const etk::Path& _element) {
m_path += _element;
return *this;
}
void etk::Uri::display() const {
TK_PRINT("Display of an URI:");
TK_PRINT(" m_scheme = '" << m_scheme << "'");

View File

@ -64,6 +64,8 @@ namespace etk {
* @return the uri correctly encoded
*/
etk::String get() const;
//! @previous
etk::String getString() const { return get(); }
/**
* @brief Get the scheme of the URI.
* @return Scheme value.
@ -191,6 +193,38 @@ namespace etk {
* @return false : Greater Uri, true otherwise.
*/
bool operator>= (const etk::Uri& _obj) const;
/**
* @brief Add a subfolder on the current path.
* @param[in] _element sub folder or file to add.
* @return false : same path, true otherwise.
*/
Uri operator/ (const etk::String& _element) const;
//! @preivious
Uri& operator/= (const etk::String& _element);
//! @preivious
Uri operator/ (const char* _element) const;
//! @preivious
Uri& operator/= (const char* _element);
//! @preivious
Uri operator/ (const etk::Path& _element) const;
//! @preivious
Uri& operator/= (const etk::Path& _element);
/**
* @brief Add a subfolder on the current path.
* @param[in] _element sub folder or file to add.
* @return false : same path, true otherwise.
*/
Uri operator+ (const etk::String& _element) const;
//! @preivious
Uri& operator+= (const etk::String& _element);
//! @preivious
Uri operator+ (const char* _element) const;
//! @preivious
Uri& operator+= (const char* _element);
//! @preivious
Uri operator+ (const etk::Path& _element) const;
//! @preivious
Uri& operator+= (const etk::Path& _element);
/**
* @brief Detail display of this element
*/