CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ContentType.hpp
Go to the documentation of this file.
1//
2// Allogica Disk
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2014-2020 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
12
13#include <iosfwd>
14
15namespace CeresEngine {
16
19 private:
22
25
28
31
34
35 public:
38
42 explicit ContentType(StringView type);
43
49
53 explicit ContentType(const char* type);
54
61 ContentType(String type, String subtype, String tree = {}, String suffix = {}, Map<String, String> parameters = {}) noexcept;
62
68
71 ContentType(const ContentType& other);
72
77
80 ContentType(ContentType&& other) noexcept;
81
85 ContentType& operator=(ContentType&& other) noexcept;
86
87 public:
89 [[nodiscard]] const String& getType() const;
90
94 void setType(String type);
95
97 [[nodiscard]] const String& getTree() const;
98
103
105 [[nodiscard]] const String& getSubtype() const;
106
111
113 [[nodiscard]] const String& getSuffix() const;
114
118 void setSuffix(String suffix);
119
122
127
130 [[nodiscard]] const String& getParameter(const String& name) const;
131
136 void setParameter(const String& name, String value);
137
138 public:
140 [[nodiscard]] bool empty() const;
141
143 [[nodiscard]] bool emptyTree() const;
144
146 [[nodiscard]] bool emptyType() const;
147
149 [[nodiscard]] bool emptySubtype() const;
150
152 [[nodiscard]] bool emptySuffix() const;
153
155 [[nodiscard]] bool emptyParameters() const;
156
159 explicit operator bool() const;
160
164
165 public:
169 bool operator==(const ContentType& other) const;
170
174 bool operator!=(const ContentType& other) const;
175
179 bool operator<(const ContentType& other) const;
180
184 bool operator<=(const ContentType& other) const;
185
189 bool operator>(const ContentType& other) const;
190
194 bool operator>=(const ContentType& other) const;
195
196 private:
199 void parse(StringView str);
200 };
201
203 std::ostream& operator<<(std::ostream& str, const ContentType& obj);
204
205} // namespace CeresEngine
A class that parses, handles and encapsulates a MIME-like content type.
Definition ContentType.hpp:18
const String & getTree() const
ContentType()
Creates a empty FileContentType object.
const String & getParameter(const String &name) const
ContentType(String type, String subtype, Map< String, String > parameters) noexcept
Creates a new content type from its type, subtype and parameters.
bool operator>=(const ContentType &other) const
A lexicographical comparison for a content type.
void setType(String type)
Set the type.
const Map< String, String > & getParameters() const
void setSubtype(String subtype)
Set the subtype.
ContentType(ContentType &&other) noexcept
Creates a new content type by moving the contents of another.
const String & getSubtype() const
ContentType(String type, String subtype, String tree={}, String suffix={}, Map< String, String > parameters={}) noexcept
Creates a new content type from its individual parts.
std::ostream & operator<<(std::ostream &str, const ContentType &obj)
Stream output.
String toString() const
Creates a string representation as "type[/subtype]".
void setParameters(Map< String, String > parameters)
Set the parameters.
String mSubtype
The content type "subtype" field.
Definition ContentType.hpp:27
ContentType(const char *type)
Creates a new content type by parsing a content type string.
const String & getType() const
Map< String, String > mParameters
The content type parameters.
Definition ContentType.hpp:33
const String & getSuffix() const
bool operator==(const ContentType &other) const
Checks if two contents types are equal.
void parse(StringView str)
Parses the file content type.
bool operator<(const ContentType &other) const
A lexicographical comparison for a content type.
String mType
The content type "type" field.
Definition ContentType.hpp:21
bool emptyParameters() const
ContentType & operator=(const ContentType &other)
Assigns the content type by copying the contents of another.
void setTree(String tree)
Set the tree.
bool operator!=(const ContentType &other) const
Checks if two contents types are not equal.
ContentType & operator=(ContentType &&other) noexcept
Assigns the content type by moving the contents of another.
String mTree
The content type "tree" field.
Definition ContentType.hpp:24
ContentType & operator=(StringView contentType)
Assigns the content type by parsing the assigned string.
void setSuffix(String suffix)
Set the suffix.
ContentType(const ContentType &other)
Creates a new content type by copying the contents of another.
void setParameter(const String &name, String value)
Set a parameter.
String mSuffix
The content type "suffix" field.
Definition ContentType.hpp:30
bool operator>(const ContentType &other) const
A lexicographical comparison for a content type.
ContentType(StringView type)
Creates a new content type by parsing a content type string.
bool operator<=(const ContentType &other) const
A lexicographical comparison for a content type.
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
std::map< Key, T, Compare, ScopedAllocatorAdaptor< StdAllocator< Pair< const Key, T >, RawAllocator > > > Map
Map is a sorted associative container that contains key-value pairs with unique keys.
Definition Map.hpp:24