From a38dacc6489ff3c7a0748a01ed7cc2bd0cdaaa7c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 29 May 2021 01:03:28 +0300 Subject: include/pdb/ -> include/winapi/debug/ --- include/winapi/debug/address.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/winapi/debug/address.hpp (limited to 'include/winapi/debug/address.hpp') diff --git a/include/winapi/debug/address.hpp b/include/winapi/debug/address.hpp new file mode 100644 index 0000000..3d7acd6 --- /dev/null +++ b/include/winapi/debug/address.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2017 Egor Tensin +// This file is part of the "winapi-debug" project. +// For details, see https://github.com/egor-tensin/winapi-debug. +// Distributed under the MIT License. + +#pragma once + +#include + +#include +#include + +namespace pdb { + +typedef DWORD64 Address; + +inline std::string format_address(Address address) { + std::ostringstream oss; + oss << std::hex << std::showbase << address; + return oss.str(); +} + +inline std::string format_address(void* address) { + return format_address(reinterpret_cast
(address)); +} + +inline bool parse_address(Address& dest, const std::string& src) { + std::istringstream iss{src}; + iss >> std::hex; + char c; + return iss >> dest && !iss.get(c); +} + +} // namespace pdb -- cgit v1.2.3