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