ATLAS Offline Software
Functions
HLT::StringSerializer Namespace Reference

Functions

void serialize (const std::vector< std::string > &strings, std::vector< uint32_t > &storage)
 
void serialize (const std::string &str, std::vector< uint32_t > &storage)
 
std::size_t deserialize (std::vector< uint32_t >::const_iterator first, std::vector< uint32_t >::const_iterator last, std::vector< std::string > &strings)
 
std::size_t deserialize (std::vector< uint32_t >::const_iterator first, std::vector< uint32_t >::const_iterator last, std::string &str)
 

Function Documentation

◆ deserialize() [1/2]

size_t HLT::StringSerializer::deserialize ( std::vector< uint32_t >::const_iterator  first,
std::vector< uint32_t >::const_iterator  last,
std::string &  str 
)

Definition at line 103 of file TrigEvent/TrigNavStructure/Root/StringSerializer.cxx.

106  {
107  std::vector<std::string> tmp;
108  std::size_t nWords = deserialize(first, last, tmp);
109  if (tmp.size() == 1 )
110  str = tmp[0];
111 
112  return nWords;
113  }

◆ deserialize() [2/2]

size_t HLT::StringSerializer::deserialize ( std::vector< uint32_t >::const_iterator  first,
std::vector< uint32_t >::const_iterator  last,
std::vector< std::string > &  strings 
)

Definition at line 66 of file TrigEvent/TrigNavStructure/Root/StringSerializer.cxx.

69  {
70  std::size_t storageSize = std::distance(first, last);
71 
72  if ( storageSize <= 1 ) return storageSize;
73  unsigned int numOfStrings = *first;
74 
75  // Copy storage into array of uint32_t
76  uint32_t * uarray = new uint32_t[storageSize-1];
77  std::vector<uint32_t>::const_iterator itBegin = first;
78  advance(itBegin, 1);
79  copy(itBegin, last, &uarray[0]);
80 
81  const char * carray = (const char*)uarray;
82  std::string whole(carray, (storageSize-1)*sizeof(uint32_t));
83  std::istringstream istream;
84 
85  istream.clear(); // istream reset
86  istream.str(whole);
87 
88  std::string one;
89  unsigned int readInStrings=0;
90  std::size_t nChars=0;
91 
92  while ( istream.good() && readInStrings < numOfStrings ) {
93  getline(istream, one, delimiter[0]);
94  strings.push_back(one);
95  readInStrings++;
96  nChars += one.size() + 1;
97  }
98  delete[] uarray;
99 
100  return 1 + (nChars+getPadding(nChars))/sizeof(uint32_t); // # uint32_t words (incl. header)
101  }

◆ serialize() [1/2]

void HLT::StringSerializer::serialize ( const std::string &  str,
std::vector< uint32_t > &  storage 
)

Definition at line 60 of file TrigEvent/TrigNavStructure/Root/StringSerializer.cxx.

60  {
61  std::vector<std::string> tmp(1, str);
62  return serialize(tmp, storage);
63  }

◆ serialize() [2/2]

void HLT::StringSerializer::serialize ( const std::vector< std::string > &  strings,
std::vector< uint32_t > &  storage 
)

Definition at line 31 of file TrigEvent/TrigNavStructure/Root/StringSerializer.cxx.

31  {
32  std::ostringstream ostream;
33  ostream.str(""); // ostream reset
34 
35  // copy strings into m_ostream with delimiter after each element (even after last element)
36  copy(strings.begin(), strings.end(), std::ostream_iterator<std::string>(ostream, delimiter));
37 
38  unsigned sizeToReserve = ostream.str().size();
39 
40  // Pad with '\n'
41  unsigned int sizeToPad = getPadding(sizeToReserve);
42 
43  if ( sizeToPad != 0 ) {
44  sizeToReserve += sizeToPad;
45  for ( unsigned i = 0 ; i < sizeToPad; i++ )
46  ostream << delimiter;
47  }
48  ostream.flush();
49 
50  char * carray = new char [sizeToReserve];
51  strncpy(carray, ostream.str().c_str(), sizeToReserve);
52  const uint32_t * uarray = (const uint32_t*) carray;
53 
54  storage.push_back(strings.size()); // put number of strings first
55  storage.insert(storage.end(), &uarray[0], &uarray[sizeToReserve/sizeof(uint32_t)]);
56 
57  delete[] carray;
58  }
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Trk::one
@ one
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:22
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
lumiFormat.i
int i
Definition: lumiFormat.py:85
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
HLT::StringSerializer::deserialize
std::size_t deserialize(std::vector< uint32_t >::const_iterator first, std::vector< uint32_t >::const_iterator last, std::string &str)
Definition: TrigEvent/TrigNavStructure/Root/StringSerializer.cxx:103
DeMoScan.first
bool first
Definition: DeMoScan.py:536
str
Definition: BTagTrackIpAccessor.cxx:11
calibdata.copy
bool copy
Definition: calibdata.py:27
HLT::StringSerializer::serialize
void serialize(const std::string &str, std::vector< uint32_t > &storage)
Definition: TrigEvent/TrigNavStructure/Root/StringSerializer.cxx:60
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54