Skip to content
DK edited this page Mar 6, 2024 · 9 revisions

DKUtil

Some utilitarian headers to help with x64 native plugin development

Implementations

Config Hook Logger Utility Extra(For SKSE)

  • Config
    • abstracted and contained config layer
    • ini, toml, json file support
    • bool, int64_t, double, string type support
    • built in array support
    • multiple file loads & generate default file
    • custom formatted string parser to c++ structure
  • Hook
  • Logger
    • logging macros
  • Utility
    • function
      • consteval helper functions retrieving the argument count of a function.
    • model
      • Singleton data model abstract class to save boilerplate code.
      • enumeration addition to the original RE::stl::enumeration.
        • static reflection for enum name, type name and value name, support value_type(n) and flag_type(1<<n)
        • std::ranges iterator for value_range(n) and flag_range(1<<n)
      • concepts useful concepts for contraining function templates
      • struct_cast, tuple_cast compile time conversion for same aligned structs/tuples using structure binding (up to 9 bindable members)
      • vector_cast, range_cast constexpr conversion for std::ranges::range and std::vector
    • numbers
      • FNV-1A compile time string hashing with 32bit/64bit implementation.
    • string
      • to_wstring method
      • concat compile time string concatenation.
      • various string related functions using std::ranges
  • Extra(For SKSE)
    • CONSOLE logging macro but for in-game console.
    • serializable painless, all-in-one serialization solution for SKSE plugins.(Planned to move to general support instead of strict SKSE)

Consumption

Requirement

All dependencies should be handled by vcpkg.

Installation

Clone a copy of DKUtil onto your local environment, in your target project's CMakeLists.txt, add:

add_subdirectory("Path/To/Local/Copy/Of/DKUtil" DKUtil)

target_link_libraries(
	"YOUR PROJECT NAME"
	INTERFACE
		DKUtil::DKUtil
)

Or using git submodule, within your target project's root directory, add:

git submodule add https://github.com/gottyduke/DKUtil.git extern/DKUtil
git submodule update -f --init

And in your target project's CMakeLists.txt, add:

# dependency macros
macro(find_dependency_path DEPENDENCY FILE)
	# searches extern for dependencies and if not checks the environment variable
	if(NOT ${DEPENDENCY} STREQUAL "")
		# Check extern
		message(
			STATUS
			"Searching for ${DEPENDENCY} using file ${FILE}"
		)
		find_path("${DEPENDENCY}Path"
			${FILE}
			PATHS "extern/${DEPENDENCY}")

		if("${${DEPENDENCY}Path}" STREQUAL "${DEPENDENCY}Path-NOTFOUND")
			# Check path
			message(
				STATUS
				"Getting environment for ${DEPENDENCY}Path: $ENV{${DEPENDENCY}Path}"
			)
			set("${DEPENDENCY}Path" "$ENV{${DEPENDENCY}Path}")
		endif()

		message(
			STATUS
			"Found ${DEPENDENCY} in ${${DEPENDENCY}Path}; adding"
		)
		add_subdirectory("${${DEPENDENCY}Path}" ${DEPENDENCY})
	endif()
endmacro()

# dependencies
find_dependency_path(DKUtil include/DKUtil/Logger.hpp)