ATLAS Offline Software
Loading...
Searching...
No Matches
LArEM_Base_ID.cxx File Reference

Factor out code common between LArEM_ID and LArEM_SuperCell_ID. More...

Go to the source code of this file.

Functions

std::string strformat (const char *fmt,...)
 return a std::string according to a format fmt and varargs

Detailed Description

Factor out code common between LArEM_ID and LArEM_SuperCell_ID.

Author
scott snyder snyde.nosp@m.r@bn.nosp@m.l.gov
Date
Aug, 2012

Definition in file LArEM_Base_ID.cxx.

Function Documentation

◆ strformat()

std::string CxxUtils::strformat ( const char * fmt,
... )

return a std::string according to a format fmt and varargs

Definition at line 49 of file StrFormat.cxx.

50{
51 char *buf = NULL;
52 int nbytes = -1;
53
54 va_list ap;
55 va_start(ap, fmt); /* Initialize the va_list */
56
57 nbytes = vasprintf(&buf, fmt, ap);
58 va_end(ap); /* Cleanup the va_list */
59
60 if (nbytes < 0) {
61 /*buf is undefined when allocation failed
62 * see: http://linux.die.net/man/3/asprintf
63 */
64 // free(buf);
65 throw std::runtime_error("problem while calling vasprintf");
66 }
67
68 CharLiberator guard(buf);
69
70 // help compiler to apply RVO
71 return std::string(buf);
72}
const char *const fmt