11 #ifndef ZYPP_CONTENTTYPE_H
12 #define ZYPP_CONTENTTYPE_H
41 if ( pos == std::string::npos )
55 ContentType(
const std::string & type_r,
const std::string & subtype_r )
63 const std::string &
type()
const
69 void type(
const std::string & type_r )
79 void subtype(
const std::string & subtype_r )
88 {
return _type.empty(); }
94 explicit operator bool ()
const
102 void testAndSet( std::string & var_r,
const std::string & val_r )
104 if ( val_r.find_first_of(
"/ \t\r\n" ) != std::string::npos )
105 throw std::invalid_argument(
"ContentType: illegal char in '" + val_r +
"'" );
123 {
return !( lhs == rhs ); }
127 {
int cmp = lhs.
type().compare( rhs.
type() );
return cmp < 0 || ( cmp == 0 && lhs.
subtype() < rhs.
subtype() ); }
131 {
return lhs < rhs || lhs == rhs; }
135 {
return !( lhs <= rhs ); }
139 {
return !( lhs < rhs ); }
144 #endif // ZYPP_CONTENTTYPE_H
void subtype(const std::string &subtype_r)
Set subtype.
bool operator!=(const ContentType &lhs, const ContentType &rhs)
bool emptySubtype() const
Whether subtype is empty.
bool operator<(const ContentType &lhs, const ContentType &rhs)
bool operator>(const ContentType &lhs, const ContentType &rhs)
bool empty() const
Whether type and subtype are empty.
void testAndSet(std::string &var_r, const std::string &val_r)
ContentType(const std::string &type_r, const std::string &subtype_r)
Ctor taking type and subtype.
bool operator>=(const ContentType &lhs, const ContentType &rhs)
String related utilities and Regular expression matching.
const std::string & subtype() const
Get subtype.
const std::string & type() const
Get type.
bool operator==(const ContentType &lhs, const ContentType &rhs)
std::ostream & operator<<(std::ostream &str, const ContentType &obj)
ContentType(const std::string &type_r)
Ctor taking "type[/subtype]"
void type(const std::string &type_r)
Set type.
ContentType()
Default ctor: empty.
bool operator<=(const ContentType &lhs, const ContentType &rhs)
std::string asString() const
String representation "type[/subtype]"
bool emptyType() const
Whether type is empty.
Easy-to use interface to the ZYPP dependency resolver.
Mime type like 'type/subtype' classification of content.