CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::ContentType Class Reference

A class that parses, handles and encapsulates a MIME-like content type. More...

#include <CeresEngine/Foundation/ContentType.hpp>

Public Member Functions

 ContentType ()
 Creates a empty FileContentType object.
 
 ContentType (StringView type)
 Creates a new content type by parsing a content type string.
 
ContentTypeoperator= (StringView contentType)
 Assigns the content type by parsing the assigned string.
 
 ContentType (const char *type)
 Creates a new content type by parsing a content type string.
 
 ContentType (String type, String subtype, String tree={}, String suffix={}, Map< String, String > parameters={}) noexcept
 Creates a new content type from its individual parts.
 
 ContentType (String type, String subtype, Map< String, String > parameters) noexcept
 Creates a new content type from its type, subtype and parameters.
 
 ContentType (const ContentType &other)
 Creates a new content type by copying the contents of another.
 
ContentTypeoperator= (const ContentType &other)
 Assigns the content type by copying the contents of another.
 
 ContentType (ContentType &&other) noexcept
 Creates a new content type by moving the contents of another.
 
ContentTypeoperator= (ContentType &&other) noexcept
 Assigns the content type by moving the contents of another.
 
const StringgetType () const
 
void setType (String type)
 Set the type.
 
const StringgetTree () const
 
void setTree (String tree)
 Set the tree.
 
const StringgetSubtype () const
 
void setSubtype (String subtype)
 Set the subtype.
 
const StringgetSuffix () const
 
void setSuffix (String suffix)
 Set the suffix.
 
const Map< String, String > & getParameters () const
 
void setParameters (Map< String, String > parameters)
 Set the parameters.
 
const StringgetParameter (const String &name) const
 
void setParameter (const String &name, String value)
 Set a parameter.
 
bool empty () const
 
bool emptyTree () const
 
bool emptyType () const
 
bool emptySubtype () const
 
bool emptySuffix () const
 
bool emptyParameters () const
 
 operator bool () const
 Validate object in a boolean context: !empty.
 
String toString () const
 Creates a string representation as "type[/subtype]".
 
bool operator== (const ContentType &other) const
 Checks if two contents types are equal.
 
bool operator!= (const ContentType &other) const
 Checks if two contents types are not equal.
 
bool operator< (const ContentType &other) const
 A lexicographical comparison for a content type.
 
bool operator<= (const ContentType &other) const
 A lexicographical comparison for a content type.
 
bool operator> (const ContentType &other) const
 A lexicographical comparison for a content type.
 
bool operator>= (const ContentType &other) const
 A lexicographical comparison for a content type.
 

Private Member Functions

void parse (StringView str)
 Parses the file content type.
 

Private Attributes

String mType
 The content type "type" field.
 
String mTree
 The content type "tree" field.
 
String mSubtype
 The content type "subtype" field.
 
String mSuffix
 The content type "suffix" field.
 
Map< String, StringmParameters
 The content type parameters.
 

Related Symbols

(Note that these are not member symbols.)

std::ostream & operator<< (std::ostream &str, const ContentType &obj)
 Stream output.
 

Detailed Description

A class that parses, handles and encapsulates a MIME-like content type.

Constructor & Destructor Documentation

◆ ContentType() [1/7]

CeresEngine::ContentType::ContentType ( )

Creates a empty FileContentType object.

◆ ContentType() [2/7]

CeresEngine::ContentType::ContentType ( StringView  type)
explicit

Creates a new content type by parsing a content type string.

Parameters
typethe content type string to parse from.
Exceptions
std::invalid_argumentif string is malformed

◆ ContentType() [3/7]

CeresEngine::ContentType::ContentType ( const char type)
explicit

Creates a new content type by parsing a content type string.

Parameters
typethe content type string to parse from.
Exceptions
std::invalid_argumentif string is malformed

◆ ContentType() [4/7]

CeresEngine::ContentType::ContentType ( String  type,
String  subtype,
String  tree = {},
String  suffix = {},
Map< String, String parameters = {} 
)
noexcept

Creates a new content type from its individual parts.

Parameters
typethe content type
subtypethe content subtype
treethe content type tree
suffixthe content type suffix
parametersthe content type parameters

◆ ContentType() [5/7]

CeresEngine::ContentType::ContentType ( String  type,
String  subtype,
Map< String, String parameters 
)
noexcept

Creates a new content type from its type, subtype and parameters.

Parameters
typethe content type
subtypethe content subtype
parametersthe content type parameters

◆ ContentType() [6/7]

CeresEngine::ContentType::ContentType ( const ContentType other)

Creates a new content type by copying the contents of another.

Parameters
otherthe instance to copy from

◆ ContentType() [7/7]

CeresEngine::ContentType::ContentType ( ContentType &&  other)
noexcept

Creates a new content type by moving the contents of another.

Parameters
otherthe instance to move from

Member Function Documentation

◆ empty()

bool CeresEngine::ContentType::empty ( ) const
Returns
true if type and subtype are empty, false otherwise

◆ emptyParameters()

bool CeresEngine::ContentType::emptyParameters ( ) const
Returns
true if parameter list is empty

◆ emptySubtype()

bool CeresEngine::ContentType::emptySubtype ( ) const
Returns
true if subtype is empty

◆ emptySuffix()

bool CeresEngine::ContentType::emptySuffix ( ) const
Returns
true if suffix is empty

◆ emptyTree()

bool CeresEngine::ContentType::emptyTree ( ) const
Returns
true if tree is empty

◆ emptyType()

bool CeresEngine::ContentType::emptyType ( ) const
Returns
true if type is empty

◆ getParameter()

const String & CeresEngine::ContentType::getParameter ( const String name) const
Parameters
namethe parameter name to get a value for
Returns
the value for the parameter named name.

◆ getParameters()

const Map< String, String > & CeresEngine::ContentType::getParameters ( ) const
Returns
the parameters

◆ getSubtype()

const String & CeresEngine::ContentType::getSubtype ( ) const
Returns
the subtype

◆ getSuffix()

const String & CeresEngine::ContentType::getSuffix ( ) const
Returns
the suffix

◆ getTree()

const String & CeresEngine::ContentType::getTree ( ) const
Returns
the tree

◆ getType()

const String & CeresEngine::ContentType::getType ( ) const
Returns
the type

◆ operator bool()

CeresEngine::ContentType::operator bool ( ) const
explicit

Validate object in a boolean context: !empty.

Returns
true if empty() is false.

◆ operator!=()

bool CeresEngine::ContentType::operator!= ( const ContentType other) const

Checks if two contents types are not equal.

Parameters
otherthe content type to check against
Returns
true if any part of the content type are not equal

◆ operator<()

bool CeresEngine::ContentType::operator< ( const ContentType other) const

A lexicographical comparison for a content type.

Parameters
otherthe content type to compare against
Returns
the comparison result

◆ operator<=()

bool CeresEngine::ContentType::operator<= ( const ContentType other) const

A lexicographical comparison for a content type.

Parameters
otherthe content type to compare against
Returns
the comparison result

◆ operator=() [1/3]

ContentType & CeresEngine::ContentType::operator= ( const ContentType other)

Assigns the content type by copying the contents of another.

Parameters
otherthe instance to copy from
Returns
this

◆ operator=() [2/3]

ContentType & CeresEngine::ContentType::operator= ( ContentType &&  other)
noexcept

Assigns the content type by moving the contents of another.

Parameters
otherthe instance to move from
Returns
this

◆ operator=() [3/3]

ContentType & CeresEngine::ContentType::operator= ( StringView  contentType)

Assigns the content type by parsing the assigned string.

Parameters
contentTypethe content type to be parsed.
Returns
this
Exceptions
std::invalid_argumentif string is malformed

◆ operator==()

bool CeresEngine::ContentType::operator== ( const ContentType other) const

Checks if two contents types are equal.

Parameters
otherthe content type to check against
Returns
true if all parts of the content type are equal

◆ operator>()

bool CeresEngine::ContentType::operator> ( const ContentType other) const

A lexicographical comparison for a content type.

Parameters
otherthe content type to compare against
Returns
the comparison result

◆ operator>=()

bool CeresEngine::ContentType::operator>= ( const ContentType other) const

A lexicographical comparison for a content type.

Parameters
otherthe content type to compare against
Returns
the comparison result

◆ parse()

void CeresEngine::ContentType::parse ( StringView  str)
private

Parses the file content type.

Parameters
strthe content type string to be parsed

◆ setParameter()

void CeresEngine::ContentType::setParameter ( const String name,
String  value 
)

Set a parameter.

Parameters
namethe parameter name to set a value for
valuethe parameter value
Exceptions
std::invalid_argumentif string is malformed

◆ setParameters()

void CeresEngine::ContentType::setParameters ( Map< String, String parameters)

Set the parameters.

Parameters
parametersthe parameters to be set
Exceptions
std::invalid_argumentif string is malformed

◆ setSubtype()

void CeresEngine::ContentType::setSubtype ( String  subtype)

Set the subtype.

Parameters
subtypethe subtype to be set
Exceptions
std::invalid_argumentif string is malformed

◆ setSuffix()

void CeresEngine::ContentType::setSuffix ( String  suffix)

Set the suffix.

Parameters
suffixthe suffix to be set
Exceptions
std::invalid_argumentif string is malformed

◆ setTree()

void CeresEngine::ContentType::setTree ( String  tree)

Set the tree.

Parameters
treethe tree to be set
Exceptions
std::invalid_argumentif string is malformed

◆ setType()

void CeresEngine::ContentType::setType ( String  type)

Set the type.

Parameters
typethe type to be set
Exceptions
std::invalid_argumentif string is malformed

◆ toString()

String CeresEngine::ContentType::toString ( ) const

Creates a string representation as "type[/subtype]".

Returns
a string representing the ContentType in its canonical form.

Friends And Related Symbol Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  str,
const ContentType obj 
)
related

Stream output.

Member Data Documentation

◆ mParameters

Map<String, String> CeresEngine::ContentType::mParameters
private

The content type parameters.

◆ mSubtype

String CeresEngine::ContentType::mSubtype
private

The content type "subtype" field.

◆ mSuffix

String CeresEngine::ContentType::mSuffix
private

The content type "suffix" field.

◆ mTree

String CeresEngine::ContentType::mTree
private

The content type "tree" field.

◆ mType

String CeresEngine::ContentType::mType
private

The content type "type" field.


The documentation for this class was generated from the following file: