11 #ifndef ZYPP_CONTENTTYPE_H
12 #define ZYPP_CONTENTTYPE_H
42 if ( pos == std::string::npos )
56 ContentType(
const std::string & type_r,
const std::string & subtype_r )
64 const std::string &
type()
const
70 void type(
const std::string & type_r )
80 void subtype(
const std::string & subtype_r )
89 {
return _type.empty(); }
95 explicit operator bool ()
const
103 void testAndSet( std::string & var_r,
const std::string & val_r )
105 if ( val_r.find_first_of(
"/ \t\r\n" ) != std::string::npos )
106 throw std::invalid_argument(
"ContentType: illegal char in '" + val_r +
"'" );
124 {
return !( lhs == rhs ); }
128 {
int cmp = lhs.
type().compare( rhs.
type() );
return cmp < 0 || ( cmp == 0 && lhs.
subtype() < rhs.
subtype() ); }
132 {
return lhs < rhs || lhs == rhs; }
136 {
return !( lhs <= rhs ); }
140 {
return !( lhs < rhs ); }
145 #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.