Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ContentEncoding.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_IO_Network_HTTP_ContentEncoding_h_
5#define _Stroika_Foundation_IO_Network_HTTP_ContentEncoding_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Containers/Sequence.h"
12
13/**
14 */
15
17
18 using Characters::String;
19 using Containers::Sequence;
20
21 /**
22 * \brief Content coding values indicate an encoding transformation that has been or can be applied to an entity. Content codings are primarily used to allow a document to be compressed or otherwise usefully transformed without losing the identity of its underlying media type and without loss of information. Frequently, the entity is stored in coded form, transmitted directly, and only decoded by the recipient.
23 *
24 * All content-coding values are case-insensitive.
25 *
26 * HTTP/1.1 uses content-coding values in the Accept-Encoding (section 14.3) and Content-Encoding (section 14.11) header fields.
27 *
28 * \see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5
29 */
31 public:
32 /**
33 */
35
36 public:
37 /**
38 */
40 template <Characters::IConvertibleToString STRING_LIKE>
41 ContentEncoding (STRING_LIKE&& name);
42
43 public:
44 nonvirtual bool operator== (const ContentEncoding& rhs) const = default;
45
46 public:
47 /**
48 * \note - though three way comparable, ordering is NOT alphabetical
49 */
50 nonvirtual auto operator<=> (const ContentEncoding& rhs) const = default;
51
52 public:
53 /**
54 */
55 template <Common::IAnyOf<String, ContentEncoding::AtomType> T>
56 nonvirtual T As () const;
57
58 public:
59 /**
60 * @see Characters::ToString ();
61 */
62 nonvirtual String ToString () const;
63
64 public:
65 /**
66 * \brief 'compress' format - no longer well supported - discouraged.
67 *
68 * compress The encoding format produced by the common UNIX file compression program "compress". This format is an adaptive Lempel-Ziv-Welch coding (LZW).
69 */
71
72 /**
73 * deflate The "zlib" format defined in RFC 1950 [31] in combination with the "deflate" compression mechanism described in RFC 1951 [29].
74 */
76
77 /**
78 * gzip An encoding format produced by the file compression program "gzip" (GNU zip) as described in RFC 1952 [25]. This format is a Lempel-Ziv coding (LZ77) with a 32 bit CRC
79 *
80 * \note "gzip is deflate, and extra headers and check sum"
81 * https://stackoverflow.com/questions/7243705/what-is-the-advantage-of-gzip-vs-deflate-compression
82 */
83 static const ContentEncoding kGZip;
84
85 /**
86 * Brotli compression algorithm
87 */
88 static const ContentEncoding kBR;
89
90 /**
91 * \brief probably fastest/best, but NYI in Stroika as of 2024-06-20
92 *
93 * zstd compression algorithm
94 */
95 static const ContentEncoding kZStd;
96
97 /**
98 * identity The default (identity) encoding; the use of no transformation whatsoever. This content-coding is used only in the Accept- Encoding header, and SHOULD NOT be used in the Content-Encoding header.
99 */
101
102 private:
103 AtomType fRep_;
104 };
105
106 /**
107 */
108 class ContentEncodings : public Sequence<ContentEncoding> {
109 public:
110 ContentEncodings (const Traversal::Iterable<ContentEncoding>& src);
111 ContentEncodings (ContentEncoding tc);
112
113 public:
114 nonvirtual ContentEncodings& operator= (const ContentEncodings& rhs) = default;
115
116 public:
117 /**
118 */
119 template <typename T>
120 nonvirtual String As () const;
121
122 public:
123 /**
124 */
125 static ContentEncodings Parse (const String& headerValue);
126 };
127 template <>
128 String ContentEncodings::As<String> () const;
129
130}
131
132/*
133 ********************************************************************************
134 ***************************** Implementation Details ***************************
135 ********************************************************************************
136 */
137#include "ContentEncoding.inl"
138
139#endif /*_Stroika_Foundation_IO_Network_HTTP_ContentEncoding_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Definition Sequence.h:187
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Definition Iterable.h:237
Content coding values indicate an encoding transformation that has been or can be applied to an entit...
static const ContentEncoding kCompress
'compress' format - no longer well supported - discouraged.
nonvirtual auto operator<=>(const ContentEncoding &rhs) const =default
static const ContentEncoding kZStd
probably fastest/best, but NYI in Stroika as of 2024-06-20