OpenMS
Base64.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Marc Sturm, Chris Bielow, Moritz Aubermann $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #ifndef OPENMS_IS_BIG_ENDIAN
12 #if defined OPENMS_BIG_ENDIAN
13 #define OPENMS_IS_BIG_ENDIAN true
14 #else
15 #define OPENMS_IS_BIG_ENDIAN false
16 #endif
17 #endif
18 
19 #include <OpenMS/CONCEPT/Types.h>
23 
24 #include <QByteArray>
25 
26 #include <algorithm>
27 #include <array>
28 #include <cmath>
29 #include <iostream>
30 #include <iterator>
31 #include <string>
32 #include <vector>
33 
34 
35 
36 #ifdef OPENMS_COMPILER_MSVC
37 #pragma comment(linker, "/export:compress")
38 #endif
39 
40 namespace OpenMS
41 {
47  class OPENMS_DLLAPI Base64
48  {
49 
50 public:
51 
53  Base64() = default;
54 
56  enum ByteOrder
57  {
59  BYTEORDER_LITTLEENDIAN
60  };
61 
69  template <typename FromType>
70  static void encode(std::vector<FromType> & in, ByteOrder to_byte_order, String & out, bool zlib_compression = false);
71 
77  template <typename ToType>
78  static void decode(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out, bool zlib_compression = false);
79 
87  template <typename FromType>
88  static void encodeIntegers(std::vector<FromType> & in, ByteOrder to_byte_order, String & out, bool zlib_compression = false);
89 
95  template <typename ToType>
96  static void decodeIntegers(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out, bool zlib_compression = false);
97 
110  static void encodeStrings(const std::vector<String> & in, String & out, bool zlib_compression = false, bool append_null_byte = true);
111 
121  static void decodeStrings(const String & in, std::vector<String> & out, bool zlib_compression = false);
122 
130  static void decodeSingleString(const String& in, QByteArray& base64_uncompressed, bool zlib_compression);
131 
132 private:
133 
136  {
137  double f;
139  };
140 
143  {
144  float f;
146  };
147 
148  static const char encoder_[];
149  static const char decoder_[];
151  template <typename ToType>
152  static void decodeUncompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out);
153 
155  template <typename ToType>
156  static void decodeCompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out);
157 
159  template <typename ToType>
160  static void decodeIntegersUncompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out);
161 
163  template <typename ToType>
164  static void decodeIntegersCompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out);
165 
166  static void stringSimdEncoder_(std::string& in, std::string& out);
167 
168  static void stringSimdDecoder_(const std::string& in, std::string& out);
169  };
170 
171  // Possible optimization: add simd registerwise endianizer (this will only be beneficial for ARM, since mzML + x64 CPU does not need to convert since both use LITTLE_ENDIAN).
172  // mzXML(!), which is outdated uses BIG_ENDIAN, i.e. "network", in its base64 encoding, so there x64 will benefit, but not ARM.
173  // However: the code below gets optimized to the bswap instruction by most compilers, which is very fast (1 cycle latency + 1 ops)
174  // and it is doubtful that SSE4's _mm_shuffle_epi8 will do better, see https://dev.to/wunk/fast-array-reversal-with-simd-j3p
176  inline UInt32 endianize32(const UInt32& n)
177  {
178  return ((n & 0x000000ff) << 24) |
179  ((n & 0x0000ff00) << 8) |
180  ((n & 0x00ff0000) >> 8) |
181  ((n & 0xff000000) >> 24);
182  }
183 
185  inline UInt64 endianize64(const UInt64& n)
186  {
187  return ((n >> 56) & 0x00000000000000FF) |
188  ((n >> 40) & 0x000000000000FF00) |
189  ((n >> 24) & 0x0000000000FF0000) |
190  ((n >> 8) & 0x00000000FF000000) |
191  ((n << 8) & 0x000000FF00000000) |
192  ((n << 24) & 0x0000FF0000000000) |
193  ((n << 40) & 0x00FF000000000000) |
194  ((n << 56) & 0xFF00000000000000);
195  }
196 
197  template <typename FromType>
198  void Base64::encode(std::vector<FromType> & in, ByteOrder to_byte_order, String & out, bool zlib_compression)
199  {
200  out.clear();
201  if (in.empty())
202  {
203  return;
204  }
205 
206  // initialize
207  const Size element_size = sizeof(FromType);
208  const Size input_bytes = element_size * in.size();
209  // change endianness if necessary
211  {
212  if (element_size == 4)
213  {
214  for (Size i = 0; i < in.size(); ++i)
215  {
216  Reinterpreter32_ tmp;
217  tmp.f = in[i];
218  tmp.i = endianize32(tmp.i);
219  in[i] = tmp.f;
220  }
221  }
222  else
223  {
224  for (Size i = 0; i < in.size(); ++i)
225  {
226  Reinterpreter64_ tmp;
227  tmp.f = static_cast<double>(in[i]);
228  tmp.i = endianize64(tmp.i);
229  in[i] = tmp.f;
230  }
231  }
233  }
234 
235  // encode with compression
236  if (zlib_compression)
237  {
238  String compressed;
239  ZlibCompression::compressData((void*)in.data(), input_bytes, compressed);
240  stringSimdEncoder_(compressed, out);
241  }
242  else // encode without compression
243  {
244  String str((char*)in.data(), input_bytes);
245  stringSimdEncoder_(str, out);
246  }
247 
248  }
249 
250  template <typename ToType>
251  void Base64::decode(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out, bool zlib_compression)
252  {
253  if (zlib_compression)
254  {
255  decodeCompressed_(in, from_byte_order, out);
256  }
257  else
258  {
259  decodeUncompressed_(in, from_byte_order, out);
260  }
261  }
262 
263  template <int type_size>
264  inline void invertEndianess(void* byte_buffer, const size_t element_count);
265  template<>
266  inline void invertEndianess<4>(void* byte_buffer, const size_t element_count)
267  {
268  UInt32* p = reinterpret_cast<UInt32*>(byte_buffer);
269  std::transform(p, p + element_count, p, endianize32);
270  }
271  template<>
272  inline void invertEndianess<8>(void* byte_buffer, const size_t element_count)
273  {
274  UInt64* p = reinterpret_cast<UInt64*>(byte_buffer);
275  std::transform(p, p + element_count, p, endianize64);
276  }
277 
278 
279  template <typename ToType>
280  void Base64::decodeCompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out)
281  {
282  out.clear();
283  if (in.empty()) return;
284 
285  constexpr Size element_size = sizeof(ToType);
286 
287  String decompressed;
288 
289  String s;
290  stringSimdDecoder_(in, s);
291  QByteArray bazip = QByteArray::fromRawData(s.c_str(), (int) s.size());
292 
294  // QByteArray qt_byte_array = QByteArray::fromRawData(in.c_str(), (int) in.size());
295  // QByteArray bazip = QByteArray::fromBase64(qt_byte_array);
296  QByteArray czip;
297  czip.resize(4);
298  czip[0] = (bazip.size() & 0xff000000) >> 24;
299  czip[1] = (bazip.size() & 0x00ff0000) >> 16;
300  czip[2] = (bazip.size() & 0x0000ff00) >> 8;
301  czip[3] = (bazip.size() & 0x000000ff);
302  czip += bazip;
303  QByteArray base64_uncompressed = qUncompress(czip);
304 
305  if (base64_uncompressed.isEmpty())
306  {
307  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Decompression error?");
308  }
309  decompressed.resize(base64_uncompressed.size());
310 
311  std::copy(base64_uncompressed.begin(), base64_uncompressed.end(), decompressed.begin());
312 
313  void* byte_buffer = reinterpret_cast<void *>(&decompressed[0]);
314  Size buffer_size = decompressed.size();
315 
316  const ToType * float_buffer = reinterpret_cast<const ToType *>(byte_buffer);
317  if (buffer_size % element_size != 0)
318  {
319  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Bad BufferCount?");
320  }
321 
322  Size float_count = buffer_size / element_size;
323 
324  // change endianness if necessary
325  if ((OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_LITTLEENDIAN) || (!OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_BIGENDIAN))
326  {
327  invertEndianess<element_size>(byte_buffer, float_count);
328  }
329 
330  // copy values
331  out.assign(float_buffer, float_buffer + float_count);
332  }
333 
334  template <typename ToType>
335  void Base64::decodeUncompressed_(const String& in, ByteOrder from_byte_order , std::vector<ToType>& out)
336  {
337  out.clear();
338 
339  // The length of a base64 string is always a multiple of 4 (always 3
340  // bytes are encoded as 4 characters)
341  if (in.size() < 4)
342  {
343  return;
344  }
345  if (in.size() % 4 != 0)
346  {
347  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Malformed base64 input, length is not a multiple of 4.");
348  }
349 
350  Size src_size = in.size();
351  // last one or two '=' are skipped if contained
352  int padding = 0;
353  if (in[src_size - 1] == '=') padding++;
354  if (in[src_size - 2] == '=') padding++;
355 
356  src_size -= padding;
357 
358  constexpr Size element_size = sizeof(ToType);
359  String s;
360  stringSimdDecoder_(in,s);
361 
362  // change endianness if necessary (mzML is always LITTLE_ENDIAN; x64 is LITTLE_ENDIAN)
363  if ((OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_LITTLEENDIAN) || (!OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_BIGENDIAN))
364  {
365  invertEndianess<element_size>((void*)s.data(), s.size() / element_size);
366  }
367 
368  const char* cptr = s.data();
369  const ToType * fptr = reinterpret_cast<const ToType*>(cptr);
370  out.assign(fptr,fptr + s.size()/element_size);
371  }
372 
373  template <typename FromType>
374  void Base64::encodeIntegers(std::vector<FromType> & in, ByteOrder to_byte_order, String & out, bool zlib_compression)
375  {
376  out.clear();
377  if (in.empty())
378  return;
379 
380  // initialize
381  const Size element_size = sizeof(FromType);
382  const Size input_bytes = element_size * in.size();
383 
384  // change endianness if necessary
386  {
387  if (element_size == 4)
388  {
389  for (Size i = 0; i < in.size(); ++i)
390  {
391  UInt32 tmp = in[i];
392  tmp = endianize32(tmp);
393  in[i] = tmp;
394  }
395  }
396  else
397  {
398  for (Size i = 0; i < in.size(); ++i)
399  {
400  UInt64 tmp = in[i];
401  tmp = endianize64(tmp);
402  in[i] = tmp;
403  }
404  }
405  }
406 
407  // encode with compression (use Qt because of zlib support)
408  if (zlib_compression)
409  {
410  String compressed;
411  ZlibCompression::compressData((void*)in.data(), input_bytes, compressed);
412  stringSimdEncoder_(compressed, out);
413  }
414  else // encode without compression
415  {
416  String str((char*)in.data(), input_bytes);
417  stringSimdEncoder_(str, out);
418  }
419  }
420 
421  template <typename ToType>
422  void Base64::decodeIntegers(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out, bool zlib_compression)
423  {
424  if (zlib_compression)
425  {
426  decodeIntegersCompressed_(in, from_byte_order, out);
427  }
428  else
429  {
430  decodeIntegersUncompressed_(in, from_byte_order, out);
431  }
432  }
433 
434  template <typename ToType>
435  void Base64::decodeIntegersCompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out)
436  {
437  out.clear();
438  if (in.empty())
439  return;
440 
441  void * byte_buffer;
442  Size buffer_size;
443  constexpr Size element_size = sizeof(ToType);
444 
445  String decompressed;
446 
447  QByteArray qt_byte_array = QByteArray::fromRawData(in.c_str(), (int) in.size());
448  QByteArray bazip = QByteArray::fromBase64(qt_byte_array);
449  QByteArray czip;
450  czip.resize(4);
451  czip[0] = (bazip.size() & 0xff000000) >> 24;
452  czip[1] = (bazip.size() & 0x00ff0000) >> 16;
453  czip[2] = (bazip.size() & 0x0000ff00) >> 8;
454  czip[3] = (bazip.size() & 0x000000ff);
455  czip += bazip;
456  QByteArray base64_uncompressed = qUncompress(czip);
457  if (base64_uncompressed.isEmpty())
458  {
459  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Decompression error?");
460  }
461  decompressed.resize(base64_uncompressed.size());
462 
463  std::copy(base64_uncompressed.begin(), base64_uncompressed.end(), decompressed.begin());
464 
465  byte_buffer = reinterpret_cast<void *>(&decompressed[0]);
466  buffer_size = decompressed.size();
467 
468  // change endianness if necessary
469  if ((OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_LITTLEENDIAN) || (!OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_BIGENDIAN))
470  {
471  if constexpr(element_size == 4)
472  {
473  const Int32 * float_buffer = reinterpret_cast<const Int32 *>(byte_buffer);
474  if (buffer_size % element_size != 0)
475  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Bad BufferCount?");
476  Size float_count = buffer_size / element_size;
477  UInt32 * p = reinterpret_cast<UInt32 *>(byte_buffer);
478  std::transform(p, p + float_count, p, endianize32);
479 
480  out.resize(float_count);
481  // do NOT use assign here, as it will give a lot of type conversion warnings on VS compiler
482  for (Size i = 0; i < float_count; ++i)
483  {
484  out[i] = (ToType) * float_buffer;
485  ++float_buffer;
486  }
487  }
488  else
489  {
490  const Int64 * float_buffer = reinterpret_cast<const Int64 *>(byte_buffer);
491 
492  if (buffer_size % element_size != 0)
493  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Bad BufferCount?");
494 
495  Size float_count = buffer_size / element_size;
496 
497  UInt64 * p = reinterpret_cast<UInt64 *>(byte_buffer);
498  std::transform(p, p + float_count, p, endianize64);
499 
500  out.resize(float_count);
501  // do NOT use assign here, as it will give a lot of type conversion warnings on VS compiler
502  for (Size i = 0; i < float_count; ++i)
503  {
504  out[i] = (ToType) * float_buffer;
505  ++float_buffer;
506  }
507  }
508  }
509  else
510  {
511  if constexpr(element_size == 4)
512  {
513  const Int * float_buffer = reinterpret_cast<const Int *>(byte_buffer);
514  if (buffer_size % element_size != 0)
515  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Bad BufferCount while decoding?");
516 
517  Size float_count = buffer_size / element_size;
518  out.resize(float_count);
519  // do NOT use assign here, as it will give a lot of type conversion warnings on VS compiler
520  for (Size i = 0; i < float_count; ++i)
521  {
522  out[i] = (ToType) * float_buffer;
523  ++float_buffer;
524  }
525  }
526  else
527  {
528  const Int64 * float_buffer = reinterpret_cast<const Int64 *>(byte_buffer);
529 
530  if (buffer_size % element_size != 0)
531  throw Exception::ConversionError(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "Bad BufferCount while decoding?");
532 
533  Size float_count = buffer_size / element_size;
534  out.resize(float_count);
535  // do NOT use assign here, as it will give a lot of type conversion warnings on VS compiler
536  for (Size i = 0; i < float_count; ++i)
537  {
538  out[i] = (ToType) * float_buffer;
539  ++float_buffer;
540  }
541  }
542  }
543 
544  }
545 
546  template <typename ToType>
547  void Base64::decodeIntegersUncompressed_(const String & in, ByteOrder from_byte_order, std::vector<ToType> & out)
548  {
549  out.clear();
550 
551  // The length of a base64 string is a always a multiple of 4 (always 3
552  // bytes are encoded as 4 characters)
553  if (in.size() < 4)
554  {
555  return;
556  }
557 
558  Size src_size = in.size();
559  // last one or two '=' are skipped if contained
560  int padding = 0;
561  if (in[src_size - 1] == '=') padding++;
562  if (in[src_size - 2] == '=') padding++;
563 
564  src_size -= padding;
565 
566  UInt a;
567  UInt b;
568 
569  UInt offset = 0;
570  int inc = 1;
571  UInt written = 0;
572 
573  const Size element_size = sizeof(ToType);
574 
575  // enough for either float or double
576  char element[8] = "\x00\x00\x00\x00\x00\x00\x00";
577 
578  if ((OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_LITTLEENDIAN) || (!OPENMS_IS_BIG_ENDIAN && from_byte_order == Base64::BYTEORDER_BIGENDIAN))
579  {
580  offset = (element_size - 1); // other endian
581  inc = -1;
582  }
583  else
584  {
585  offset = 0;
586  inc = 1;
587  }
588 
589  // reserve enough space in the output vector
590  out.reserve((UInt)(std::ceil((4.0 * src_size) / 3.0) + 6.0));
591 
592  // sort all read bytes correctly into a char[4] (double) or
593  // char[8] (float) and push_back when necessary.
594  for (Size i = 0; i < src_size; i += 4)
595  {
596 
597  // decode 4 Base64-Chars to 3 Byte
598  // -------------------------------
599 
600  // decode the first two chars
601  a = decoder_[(int)in[i] - 43] - 62;
602  b = decoder_[(int)in[i + 1] - 43] - 62;
603  if (i + 1 >= src_size)
604  {
605  b = 0;
606  }
607  // write first byte (6 bits from a and 2 highest bits from b)
608  element[offset] = (unsigned char) ((a << 2) | (b >> 4));
609  written++;
610  offset = (offset + inc) % element_size;
611 
612  if (written % element_size == 0)
613  {
614  ToType float_value;
615  if (element_size == 4)
616  {
617  Int32 * value = reinterpret_cast<Int32 *>(&element[0]);
618  float_value = (ToType) * value;
619  }
620  else
621  {
622  Int64 * value = reinterpret_cast<Int64 *>(&element[0]);
623  float_value = (ToType) * value;
624  }
625  out.push_back(float_value);
626  strcpy(element, "");
627  }
628 
629  // decode the third char
630  a = decoder_[(int)in[i + 2] - 43] - 62;
631  if (i + 2 >= src_size)
632  {
633  a = 0;
634  }
635  // write second byte (4 lowest bits from b and 4 highest bits from a)
636  element[offset] = (unsigned char) (((b & 15) << 4) | (a >> 2));
637  written++;
638  offset = (offset + inc) % element_size;
639 
640  if (written % element_size == 0)
641  {
642  ToType float_value;
643  if (element_size == 4)
644  {
645  Int32 * value = reinterpret_cast<Int32 *>(&element[0]);
646  float_value = (ToType) * value;
647  }
648  else
649  {
650  Int64 * value = reinterpret_cast<Int64 *>(&element[0]);
651  float_value = (ToType) * value;
652  }
653  out.push_back(float_value);
654  strcpy(element, "");
655  }
656 
657  // decode the fourth char
658  b = decoder_[(int)in[i + 3] - 43] - 62;
659  if (i + 3 >= src_size)
660  {
661  b = 0;
662  }
663  // write third byte (2 lowest bits from a and 6 bits from b)
664  element[offset] = (unsigned char) (((a & 3) << 6) | b);
665  written++;
666  offset = (offset + inc) % element_size;
667 
668  if (written % element_size == 0)
669  {
670  ToType float_value;
671  if (element_size == 4)
672  {
673  Int32 * value = reinterpret_cast<Int32 *>(&element[0]);
674  float_value = (ToType) * value;
675  }
676  else
677  {
678  Int64 * value = reinterpret_cast<Int64 *>(&element[0]);
679  float_value = (ToType) * value;
680  }
681  out.push_back(float_value);
682  strcpy(element, "");
683  }
684  }
685  }
686 
687 } //namespace OpenMS
688 
#define OPENMS_IS_BIG_ENDIAN
Definition: Base64.h:15
Class to encode and decode Base64.
Definition: Base64.h:48
static void stringSimdDecoder_(const std::string &in, std::string &out)
static void decodeSingleString(const String &in, QByteArray &base64_uncompressed, bool zlib_compression)
Decodes a Base64 string to a QByteArray.
static void decode(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out, bool zlib_compression=false)
Decodes a Base64 string to a vector of floating point numbers.
Definition: Base64.h:251
static void decodeIntegersCompressed_(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out)
Decodes a compressed Base64 string to a vector of integer numbers.
Definition: Base64.h:435
double f
Definition: Base64.h:137
static const char decoder_[]
Definition: Base64.h:149
static void decodeCompressed_(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out)
Decodes a compressed Base64 string to a vector of floating point numbers.
Definition: Base64.h:280
static void decodeIntegersUncompressed_(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out)
Decodes a Base64 string to a vector of integer numbers.
Definition: Base64.h:547
static void decodeStrings(const String &in, std::vector< String > &out, bool zlib_compression=false)
Decodes a Base64 string to a vector of (null-terminated) strings.
static void stringSimdEncoder_(std::string &in, std::string &out)
static void decodeUncompressed_(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out)
Decodes a Base64 string to a vector of floating point numbers.
Definition: Base64.h:335
Base64()=default
default constructor
static void encodeStrings(const std::vector< String > &in, String &out, bool zlib_compression=false, bool append_null_byte=true)
Encodes a vector of strings to a Base64 string.
UInt64 i
Definition: Base64.h:138
ByteOrder
Byte order type.
Definition: Base64.h:57
@ BYTEORDER_BIGENDIAN
Big endian type.
Definition: Base64.h:58
@ BYTEORDER_LITTLEENDIAN
Little endian type.
Definition: Base64.h:59
static void encode(std::vector< FromType > &in, ByteOrder to_byte_order, String &out, bool zlib_compression=false)
Encodes a vector of floating point numbers to a Base64 string.
Definition: Base64.h:198
static void decodeIntegers(const String &in, ByteOrder from_byte_order, std::vector< ToType > &out, bool zlib_compression=false)
Decodes a Base64 string to a vector of integer numbers.
Definition: Base64.h:422
UInt32 i
Definition: Base64.h:145
static void encodeIntegers(std::vector< FromType > &in, ByteOrder to_byte_order, String &out, bool zlib_compression=false)
Encodes a vector of integer point numbers to a Base64 string.
Definition: Base64.h:374
float f
Definition: Base64.h:144
Internal class needed for type-punning.
Definition: Base64.h:143
Internal class needed for type-punning.
Definition: Base64.h:136
Invalid conversion exception.
Definition: Exception.h:330
A more convenient string class.
Definition: String.h:34
static void compressData(const void *raw_data, const size_t in_length, std::string &compressed_data)
Compresses data using zlib directly.
OPENMS_UINT32_TYPE UInt32
Unsigned integer type (32bit)
Definition: Types.h:37
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:51
int Int
Signed integer type.
Definition: Types.h:76
OPENMS_INT32_TYPE Int32
Signed integer type (32bit)
Definition: Types.h:30
OPENMS_INT64_TYPE Int64
Signed integer type (64bit)
Definition: Types.h:44
unsigned int UInt
Unsigned integer type.
Definition: Types.h:68
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
UInt32 endianize32(const UInt32 &n)
Endianizes a 32 bit type from big endian to little endian and vice versa.
Definition: Base64.h:176
void invertEndianess< 4 >(void *byte_buffer, const size_t element_count)
Definition: Base64.h:266
void invertEndianess(void *byte_buffer, const size_t element_count)
void invertEndianess< 8 >(void *byte_buffer, const size_t element_count)
Definition: Base64.h:272
UInt64 endianize64(const UInt64 &n)
Endianizes a 64 bit type from big endian to little endian and vice versa.
Definition: Base64.h:185