diff --git a/cmake/core-sources.txt b/cmake/core-sources.txt index 86400ab2..85514b05 100644 --- a/cmake/core-sources.txt +++ b/cmake/core-sources.txt @@ -1 +1,2 @@ src/core/Resolver.cpp +src/core/OStreamOverloads/OStreamOverloads.cpp diff --git a/src/core/OStreamOverloads/OStreamOverloads.cpp b/src/core/OStreamOverloads/OStreamOverloads.cpp new file mode 100644 index 00000000..eea142bb --- /dev/null +++ b/src/core/OStreamOverloads/OStreamOverloads.cpp @@ -0,0 +1,15 @@ +#ifdef OPEN_SHC_DLL + +#include "OStreamOverloadsSupport.cpp" // provides support implementations + +/* + Include overload implementations here: + - The overload needs to be defined in OStreamOverloads.hpp. + - Implementation files should use "same" include directory as the header but relative to OStreamOverloads.cpp. + - Files should contain: the overload, the include for the type and an include for "OStreamOverloadsSupport.hpp". + - Support functions, macros and ostream imports are provided by and should be added to OStreamOverloadsSupport.hpp + and implemented in OStreamOverloadsSupport.cpp. +*/ +#include "./OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.cpp" + +#endif // OPEN_SHC_DLL diff --git a/src/core/OStreamOverloads/OStreamOverloadsSupport.cpp b/src/core/OStreamOverloads/OStreamOverloadsSupport.cpp new file mode 100644 index 00000000..b6c7c0a4 --- /dev/null +++ b/src/core/OStreamOverloads/OStreamOverloadsSupport.cpp @@ -0,0 +1,6 @@ +#include "OStreamOverloadsSupport.hpp" + +std::ostream& printEnum(std::ostream& os, char const* const name, unsigned int const value) +{ + return os << name << "(" << value << ")"; +} diff --git a/src/core/OStreamOverloads/OStreamOverloadsSupport.hpp b/src/core/OStreamOverloads/OStreamOverloadsSupport.hpp new file mode 100644 index 00000000..bd664693 --- /dev/null +++ b/src/core/OStreamOverloads/OStreamOverloadsSupport.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +/* + Support for enum printing. + The macro can be used to add a case, assign, break to a switch, easier allowing to add more cases. + Always consider number overlaps. The linter might warn, though. +*/ + +#define MACRO_ENUM_CASE(variable, name) \ + case name: \ + variable = #name; \ + break; + +std::ostream& printEnum(std::ostream& os, char const* const name, unsigned int const value); diff --git a/src/core/OStreamOverloads/OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.cpp b/src/core/OStreamOverloads/OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.cpp new file mode 100644 index 00000000..de9ee08e --- /dev/null +++ b/src/core/OStreamOverloads/OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.cpp @@ -0,0 +1,17 @@ +#include "OpenSHC/Audio/mss/UnkSoundFlagsAndLoopCount.hpp" + +#include "core/OStreamOverloads/OStreamOverloadsSupport.hpp" + +namespace OpenSHC { +namespace Audio { + namespace MSS { + + std::ostream& operator<<(std::ostream& os, UnkSoundFlagsAndLoopCount const& value) + { + return os << "{loopCount=" << value.loopCount << ", flagsUnk=0x" << std::hex << std::setw(2) + << std::setfill('0') << static_cast(value.flagsUnk) << std::dec << "}"; + } + + } +} +} diff --git a/src/precomp/FunctionResolver.h b/src/precomp/FunctionResolver.h index 2e2fbc46..bb29918f 100644 --- a/src/precomp/FunctionResolver.h +++ b/src/precomp/FunctionResolver.h @@ -7,6 +7,7 @@ // NOTE: Changed CDECL tp CCALL to avoid window macro issue // TODO: Maybe change naming convention to not run into these issues +#include "OStreamOverloads.hpp" #include "TypeUtility.h" #include "ucp3.h" #include diff --git a/src/precomp/OStreamOverloads.hpp b/src/precomp/OStreamOverloads.hpp new file mode 100644 index 00000000..fc9f8704 --- /dev/null +++ b/src/precomp/OStreamOverloads.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace OpenSHC { +namespace Audio { + namespace MSS { + struct UnkSoundFlagsAndLoopCount; + std::ostream& operator<<(std::ostream&, UnkSoundFlagsAndLoopCount const&); + } +} +}