ATLAS Offline Software
Loading...
Searching...
No Matches
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
10static const char* const fmt_tech = "[TECH=%08lX]";
11
14
15const 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);
25 return str;
26}
27
28Placement& 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}
static const char *const fmt_tech
Definition Placement.cxx:10
This file contains the class definition for the Placement class (migrated from POOL).
long unsigned m_technology
Technology identifier.
Definition Placement.h:51
std::string m_fileName
File name.
Definition Placement.h:53
std::string m_containerName
Container name.
Definition Placement.h:55
const std::string toString() const
Retrieve the string representation of the placement.
Definition Placement.cxx:15
Placement()
Default Constructor.
Definition Placement.cxx:12
Placement & fromString(const std::string &from)
Build from the string representation of a placement.
Definition Placement.cxx:28
std::string m_auxString
Auxiliary string.
Definition Placement.h:57