ATLAS Offline Software
TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGSERIALIZERESULT_STRINGSERIALIZER_H
6 #define TRIGSERIALIZERESULT_STRINGSERIALIZER_H
7 #include <iostream>
8 #include <sstream>
9 #include <vector>
10 #include <cstdlib>
11 #include <iterator>
12 #include <stdint.h>
13 
20 
21 public:
32  void serialize (const std::vector<std::string>& strings, std::vector<uint32_t>& storage );
33  void serialize (const std::string& str, std::vector<uint32_t>& storage );
34 
44  std::size_t deserialize (std::vector<uint32_t>::const_iterator first,
45  std::vector<uint32_t>::const_iterator last,
46  std::vector<std::string>& strings);
47 
49  std::size_t deserialize (const std::vector<uint32_t>& storage, std::vector<std::string>& strings ) {
50  return deserialize(storage.begin(), storage.end(), strings);
51  }
52 
54  std::vector<std::string> deserialize (const std::vector<uint32_t>& storage) {
55  std::vector<std::string> strings;
56  deserialize(storage.begin(), storage.end(), strings);
57  return strings;
58  }
59 
61  std::size_t deserialize (std::vector<uint32_t>::const_iterator first,
62  std::vector<uint32_t>::const_iterator last,
63  std::string& str);
64 
66  std::size_t deserialize (const std::vector<uint32_t>& storage, std::string& str ) {
67  return deserialize(storage.begin(), storage.end(), str);
68  }
69 
73  unsigned int inquireSize(const std::vector<uint32_t>& storage);
74 
75 private:
76 
80  unsigned int getPadding(unsigned int sizeToReserve) {
81  return (sizeof(uint32_t) - sizeToReserve%sizeof(uint32_t)) % sizeof(uint32_t);
82  }
83 
84  std::ostringstream m_ostream;
85  std::istringstream m_istream;
86  static const char* const s_delimiter;
87 };
88 #endif // TRIGSERIALIZERESULT_STRINGSERIALIZER_H
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
StringSerializer::serialize
void serialize(const std::vector< std::string > &strings, std::vector< uint32_t > &storage)
Serializes vector of strings into vector of integers.
Definition: TrigDataAccess/TrigSerializeResult/src/StringSerializer.cxx:10
StringSerializer::deserialize
std::vector< std::string > deserialize(const std::vector< uint32_t > &storage)
Same as above but return string by value (useful when invoked from Python)
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:54
StringSerializer::m_istream
std::istringstream m_istream
sstream used in de-serialization
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:85
StringSerializer::m_ostream
std::ostringstream m_ostream
sstream used in serialization
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:84
StringSerializer::deserialize
std::size_t deserialize(std::vector< uint32_t >::const_iterator first, std::vector< uint32_t >::const_iterator last, std::vector< std::string > &strings)
Deserialize vector into strings.
Definition: TrigDataAccess/TrigSerializeResult/src/StringSerializer.cxx:62
StringSerializer::s_delimiter
static const char *const s_delimiter
default delimeter which is put between strings from the input vector while serialization happens
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:86
StringSerializer::deserialize
std::size_t deserialize(const std::vector< uint32_t > &storage, std::vector< std::string > &strings)
Same as above but with vector instead of iterators.
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:49
StringSerializer::inquireSize
unsigned int inquireSize(const std::vector< uint32_t > &storage)
Return number of strings serialized into 'storage'.
Definition: TrigDataAccess/TrigSerializeResult/src/StringSerializer.cxx:119
DeMoScan.first
bool first
Definition: DeMoScan.py:536
StringSerializer
Utility class (not a tool or so) to serialize strings into stream of 32bit integers.
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:19
str
Definition: BTagTrackIpAccessor.cxx:11
StringSerializer::deserialize
std::size_t deserialize(const std::vector< uint32_t > &storage, std::string &str)
Deserialize one single string
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:66
StringSerializer::getPadding
unsigned int getPadding(unsigned int sizeToReserve)
Get number of padding bytes needed to align with uint32_t.
Definition: TrigDataAccess/TrigSerializeResult/TrigSerializeResult/StringSerializer.h:80