Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/core-sources.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/core/Resolver.cpp
src/core/OStreamOverloads/OStreamOverloads.cpp
15 changes: 15 additions & 0 deletions src/core/OStreamOverloads/OStreamOverloads.cpp
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions src/core/OStreamOverloads/OStreamOverloadsSupport.cpp
Original file line number Diff line number Diff line change
@@ -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 << ")";
}
17 changes: 17 additions & 0 deletions src/core/OStreamOverloads/OStreamOverloadsSupport.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <iomanip>
#include <ostream>

/*
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);
Original file line number Diff line number Diff line change
@@ -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<int>(value.flagsUnk) << std::dec << "}";
}

}
}
}
1 change: 1 addition & 0 deletions src/precomp/FunctionResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ios>
Expand Down
12 changes: 12 additions & 0 deletions src/precomp/OStreamOverloads.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <iosfwd>

namespace OpenSHC {
namespace Audio {
namespace MSS {
struct UnkSoundFlagsAndLoopCount;
std::ostream& operator<<(std::ostream&, UnkSoundFlagsAndLoopCount const&);
}
}
}