aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/utils/pdb_descr.hpp
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-12 23:49:48 +0200
committerEgor Tensin <egor@tensin.name>2026-06-12 23:49:48 +0200
commitb00525a10746de26040d201fa2ca7fb075d1f83b (patch)
tree5ef06ab9fe9f1e49040a7bb76f74a62acdf4bed5 /src/utils/pdb_descr.hpp
parentcmake: move main library code to src/ (diff)
downloadwinapi-debug-b00525a10746de26040d201fa2ca7fb075d1f83b.tar.gz
winapi-debug-b00525a10746de26040d201fa2ca7fb075d1f83b.zip
utils/ -> src/utils/
Diffstat (limited to 'src/utils/pdb_descr.hpp')
-rw-r--r--src/utils/pdb_descr.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/utils/pdb_descr.hpp b/src/utils/pdb_descr.hpp
new file mode 100644
index 0000000..c2e720a
--- /dev/null
+++ b/src/utils/pdb_descr.hpp
@@ -0,0 +1,61 @@
+// Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com>
+// 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 <winapi/debug.hpp>
+
+#include <boost/program_options.hpp>
+
+#include <string>
+#include <vector>
+
+struct PDB {
+ winapi::Address online_base;
+ std::string path;
+
+ static PDB parse(const std::string& src) {
+ static constexpr auto sep = ',';
+
+ const auto sep_pos = src.find(sep);
+ if (sep_pos == std::string::npos)
+ throw boost::program_options::invalid_option_value{src};
+
+ winapi::Address online_base;
+ if (!winapi::address::parse(online_base, src.substr(0, sep_pos)))
+ throw boost::program_options::invalid_option_value{src};
+
+ return {online_base, src.substr(sep_pos + 1)};
+ }
+
+ static winapi::Address parse_address(const std::string& src) {
+ winapi::Address dest;
+ if (!winapi::address::parse(dest, src))
+ throw boost::program_options::invalid_option_value{src};
+ return dest;
+ }
+};
+
+template <typename charT>
+void validate(boost::any& dest,
+ const std::vector<std::basic_string<charT>>& src_tokens,
+ PDB*,
+ int) {
+ namespace po = boost::program_options;
+ po::validators::check_first_occurrence(dest);
+ const auto& src_token = po::validators::get_single_string(src_tokens);
+ dest = boost::any{PDB::parse(src_token)};
+}
+
+template <typename charT>
+void validate(boost::any& dest,
+ const std::vector<std::basic_string<charT>>& src_tokens,
+ winapi::Address*,
+ int) {
+ namespace po = boost::program_options;
+ po::validators::check_first_occurrence(dest);
+ const auto& src_token = po::validators::get_single_string(src_tokens);
+ dest = boost::any{PDB::parse_address(src_token)};
+}