ATLAS Offline Software
Placement.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cstdio>
8 #include <cstring>
9 
10 static const char* const fmt_tech = "[TECH=%08lX]";
11 
12 Placement::Placement() : m_technology(0L), m_fileName(""), m_containerName("") {
13 }
14 
15 const std::string Placement::toString() const {
16  char text[128];
17  int s = sprintf(text, fmt_tech, m_technology);
18  std::string str = "[FILE=";
19  str += m_fileName;
20  str += "][CONT=";
22  str += ']';
23  str.append(text, s);
24  str += m_auxString;
25  return str;
26 }
27 
28 Placement& Placement::fromString(const std::string& source) {
29  for (const char* p1 = source.c_str(); p1; p1 = ::strchr(++p1,'[')) {
30  const char* p2 = ::strchr(p1, '=');
31  const char* p3 = ::strchr(p1, ']');
32  if (p2 != 0 && p3 != 0) {
33  if (::strncmp("[FILE=", p1, 6) == 0) {
34  m_fileName.assign (p2+1, p3-p2-1);
35  } else if (::strncmp("[CONT=", p1, 6) == 0) {
36  m_containerName.assign (p2+1, p3-p2-1);
37  } else if (::strncmp(fmt_tech, p1, 6) == 0) {
38  ::sscanf(p1, fmt_tech, &m_technology);
39  } else {
40  while (*(p2 + 1) == '[' && p3 && *(++p3) != 0 && *p3 != ']') {
41  p3 = ::strchr(p3, ']');
42  }
43  if (!p3) p3 = source.c_str() + source.size();
44  m_auxString.append (p1, p3-p1);
45  m_auxString += ']';
46  }
47  }
48  }
49  return *this;
50 }
Placement
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition: Placement.h:19
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Placement::m_auxString
std::string m_auxString
Auxiliary string.
Definition: Placement.h:57
ParticleJetTools::p3
Amg::Vector3D p3(const xAOD::TruthVertex *p)
Definition: ParticleJetLabelCommon.cxx:55
Placement::m_containerName
std::string m_containerName
Container name.
Definition: Placement.h:55
Placement::m_fileName
std::string m_fileName
File name.
Definition: Placement.h:53
Placement::m_technology
long unsigned m_technology
Technology identifier.
Definition: Placement.h:51
Placement::toString
const std::string toString() const
Retrieve the string representation of the placement.
Definition: Placement.cxx:15
Placement::Placement
Placement()
Default Constructor.
Definition: Placement.cxx:12
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
str
Definition: BTagTrackIpAccessor.cxx:11
Placement.h
This file contains the class definition for the Placement class (migrated from POOL).
Placement::fromString
Placement & fromString(const std::string &from)
Build from the string representation of a placement.
Definition: Placement.cxx:28