Commit e2dabd06 authored by Steven Murray's avatar Steven Murray
Browse files

Copied demangledNameOf() from tapeserver/castor/messages/Frame.hpp

parent 8212ba58
......@@ -101,7 +101,7 @@ void cta::mediachanger::Frame::serializeProtocolBufferIntoBody(
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Frame failed to serialize protocol buffer " <<
utils::demangledNameOf(protocolBuffer) << " into frame body: "
demangledNameOf(protocolBuffer) << " into frame body: "
<< ne.getMessage().str();
throw ex;
}
......@@ -116,7 +116,7 @@ void cta::mediachanger::Frame::parseBodyIntoProtocolBuffer(
cta::exception::Exception ex;
ex.getMessage() << "Frame failed to parse contents of enclosed ZMQ"
" message into protocol buffer " <<
utils::demangledNameOf(protocolBuffer)
demangledNameOf(protocolBuffer)
<< ": ParseFromString() returned false";
throw ex;
}
......
......@@ -26,6 +26,7 @@
#include "mediachanger/Header.pb.h"
#include "mediachanger/ZmqMsg.hpp"
#include <cxxabi.h>
#include <google/protobuf/message.h>
#include <string>
......@@ -92,6 +93,24 @@ private:
* frame header.
*/
void calcAndSetHashValueOfBody();
/**
* Determines the demangled type name of the specified object.
*
* @param t The object.
* @return The demangled type name.
*/
template <class T> static std::string demangledNameOf(const T&t) {
std::string responseType = typeid(t).name();
int status = -1;
char * demangled = abi::__cxa_demangle(responseType.c_str(), NULL, NULL, &status);
if (!status) {
responseType = demangled;
}
free(demangled);
return responseType;
}
}; // struct Frame
} // namespace mediachanger
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment