#ifndef _STRING_HELPERS_H_
#define _STRING_HELPERS_H_
/// \brief String utility methods
class StringHelpers
{
public:
/// \brief Generate a string containing the textual value of the objects address
/// \param a_ptr Pointer to the object in question
/// \return New std::string containing the memory address of the object in decimal (e.g. 0x0BADFOOD -> "195948557")
template <class T>
static std::string PtrToString(const T* a_ptr)
{
size_t integerFromPtr = reinterpret_cast<size_t>(a_ptr);
std::ostringstream strThis;
strThis << integerFromPtr;
return strThis.str();
}
/// \brief Return a pointer to an object given a string containing the textual value of the objects address
/// \param a_str std::string containing the memory address of the object in decimal (e.g. "195948557" -> 0x0BADF00D)
/// \return Pointer to the object in question
template <class T>
static T* StringToPtr(const std::string& a_str)
{
std::stringstream ss(a_str);
size_t integerFromPtr = 0;
ss >> integerFromPtr;
return reinterpret_cast<T*>(integerFromPtr);
}
};
#endif