Compression.h
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include "Types.h"
25 
26 namespace IFS
27 {
31 #define IFS_COMPRESSION_TYPE_MAP(XX) \
32  XX(None, "Normal file, no compression") \
33  XX(GZip, "GZIP compressed for serving via HTTP")
34 
38 struct __attribute__((packed)) Compression {
39  enum class Type : uint8_t {
40 #define XX(_tag, _comment) _tag,
42 #undef XX
43  MAX
44  };
45  Type type;
46  uint32_t originalSize;
47 
48  bool operator==(const Compression& other) const
49  {
50  return type == other.type && originalSize == other.originalSize;
51  }
52 
53  bool operator!=(const Compression& other) const
54  {
55  return !operator==(other);
56  }
57 };
58 
59 static_assert(sizeof(Compression) == 5, "Compression wrong size");
60 
67 Compression::Type getCompressionType(const char* str, Compression::Type defaultValue = Compression::Type::None);
68 
69 inline Compression::Type getCompressionType(const String& str, Compression::Type defaultValue = Compression::Type::None)
70 {
71  return getCompressionType(str.c_str(), defaultValue);
72 }
73 
76 } // namespace IFS
77 
Compression::Type getCompressionType(const char *str, Compression::Type defaultValue=Compression::Type::None)
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:641
#define str(s)
Definition: testrunner.h:124
String toString(IFS::Compression::Type type)
Get the string representation for the given compression type.
The String class.
Definition: WString.h:136
#define IFS_COMPRESSION_TYPE_MAP(XX)
compression type
Definition: Compression.h:31
Definition: DirectoryTemplate.h:36
Type
Definition: Resource.h:41
struct __attribute__((packed)) Compression
A compression descriptor.
Definition: Compression.h:38