Files
narya/cpplib/src/presents/Util.h
T
Michael Bayne 1c311431ad Finished the job of splitting Narya into submodules.
The ActionScript code is now under aslib and is built via Maven (and Ant). The
CPP code is under cpplib and is ignored by everything (other than service
generation), but now at least it's not crufting up the Java submodule with its
XCode project.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6783 542714f4-19e9-0310-aa3c-eee0fc999fb1
2012-02-14 19:11:33 +00:00

37 lines
661 B
C++

#pragma once
namespace presents {
void log (const char* message);
namespace internal {
void log (const char* format, ...);
}
template <class T>
inline T reverseBytes (T source)
{
uint8* pData = reinterpret_cast<uint8*>(&source);
std::reverse(pData, pData + sizeof(T));
return source;
}
template <class T>
T presentsToHost (T source)
{
#ifdef PRESENTS_HOST_LITTLE_ENDIAN
return reverseBytes(source);
#else
return source;
#endif
}
template <class T>
T hostToPresents (T source)
{
#ifdef PRESENTS_HOST_LITTLE_ENDIAN
return reverseBytes(source);
#else
return source;
#endif
}
}