mirror of
https://github.com/a2x/cs2-dumper.git
synced 2025-10-07 22:50:03 +08:00
Updated README
This commit is contained in:
7
include/builder/builder.hpp
Normal file
7
include/builder/builder.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "i_file_builder.hpp"
|
||||
#include "cpp_file_builder.hpp"
|
||||
#include "csharp_file_builder.hpp"
|
||||
#include "json_file_builder.hpp"
|
||||
#include "rust_file_builder.hpp"
|
27
include/builder/cpp_file_builder.hpp
Normal file
27
include/builder/cpp_file_builder.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
namespace builder {
|
||||
class CppFileBuilder : public IFileBuilder {
|
||||
public:
|
||||
std::string get_extension() noexcept override {
|
||||
return "hpp";
|
||||
}
|
||||
|
||||
void write_top_level(std::ofstream& output) noexcept override {
|
||||
output << "#pragma once\n\n";
|
||||
output << "#include <cstddef>\n\n";
|
||||
}
|
||||
|
||||
void write_namespace(std::ofstream& output, const std::string& namespace_name) noexcept override {
|
||||
output << "namespace " << namespace_name << " {\n";
|
||||
}
|
||||
|
||||
void write_variable(std::ofstream& output, const std::string& variable_name, const std::uint64_t variable_value) noexcept override {
|
||||
output << " constexpr std::ptrdiff_t " << variable_name << " = 0x" << std::hex << variable_value << ";\n";
|
||||
}
|
||||
|
||||
void write_closure(std::ofstream& output, const bool eof) noexcept override {
|
||||
output << (!eof ? "}\n\n": "}");
|
||||
}
|
||||
};
|
||||
}
|
26
include/builder/csharp_file_builder.hpp
Normal file
26
include/builder/csharp_file_builder.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
namespace builder {
|
||||
class CSharpFileBuilder : public IFileBuilder {
|
||||
public:
|
||||
std::string get_extension() noexcept override {
|
||||
return "cs";
|
||||
}
|
||||
|
||||
void write_top_level(std::ofstream& output) noexcept override {
|
||||
// Nothing needed here.
|
||||
}
|
||||
|
||||
void write_namespace(std::ofstream& output, const std::string& namespace_name) noexcept override {
|
||||
output << "public static class " << namespace_name << " {\n";
|
||||
}
|
||||
|
||||
void write_variable(std::ofstream& output, const std::string& variable_name, const std::uint64_t variable_value) noexcept override {
|
||||
output << " public const ulong " << variable_name << " = 0x" << std::hex << variable_value << ";\n";
|
||||
}
|
||||
|
||||
void write_closure(std::ofstream& output, const bool eof) noexcept override {
|
||||
output << (!eof ? "}\n\n": "}");
|
||||
}
|
||||
};
|
||||
}
|
16
include/builder/i_file_builder.hpp
Normal file
16
include/builder/i_file_builder.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace builder {
|
||||
class IFileBuilder {
|
||||
public:
|
||||
virtual ~IFileBuilder() noexcept = default;
|
||||
virtual std::string get_extension() noexcept = 0;
|
||||
virtual void write_top_level(std::ofstream& output) noexcept = 0;
|
||||
virtual void write_namespace(std::ofstream& output, const std::string& namespace_name) noexcept = 0;
|
||||
virtual void write_variable(std::ofstream& output, const std::string& variable_name, std::uint64_t variable_value) noexcept = 0;
|
||||
virtual void write_closure(std::ofstream& output, bool eof) noexcept = 0;
|
||||
};
|
||||
}
|
38
include/builder/json_file_builder.hpp
Normal file
38
include/builder/json_file_builder.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace builder {
|
||||
class JsonFileBuilder : public IFileBuilder {
|
||||
public:
|
||||
std::string get_extension() noexcept override {
|
||||
return "json";
|
||||
}
|
||||
|
||||
void write_top_level(std::ofstream& output) noexcept override {
|
||||
// Nothing needed here.
|
||||
}
|
||||
|
||||
void write_namespace(std::ofstream& output, const std::string& namespace_name) noexcept override {
|
||||
current_namespace_name_ = namespace_name;
|
||||
}
|
||||
|
||||
void write_variable(std::ofstream& output, const std::string& variable_name, const std::uint64_t variable_value) noexcept override {
|
||||
json[current_namespace_name_][variable_name] = variable_value;
|
||||
}
|
||||
|
||||
void write_closure(std::ofstream& output, const bool eof) noexcept override {
|
||||
if (eof) {
|
||||
output << json.dump(4);
|
||||
|
||||
json.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
nlohmann::json json;
|
||||
|
||||
private:
|
||||
std::string current_namespace_name_;
|
||||
};
|
||||
}
|
27
include/builder/rust_file_builder.hpp
Normal file
27
include/builder/rust_file_builder.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
namespace builder {
|
||||
class RustFileBuilder : public IFileBuilder {
|
||||
public:
|
||||
std::string get_extension() noexcept override {
|
||||
return "rs";
|
||||
}
|
||||
|
||||
void write_top_level(std::ofstream& output) noexcept override {
|
||||
// Nothing needed here.
|
||||
}
|
||||
|
||||
void write_namespace(std::ofstream& output, const std::string& namespace_name) noexcept override {
|
||||
output << "#[allow(non_snake_case, non_upper_case_globals)]\n";
|
||||
output << "pub mod " << namespace_name << " {\n";
|
||||
}
|
||||
|
||||
void write_variable(std::ofstream& output, const std::string& variable_name, const std::uint64_t variable_value) noexcept override {
|
||||
output << " pub const " << variable_name << ": usize = 0x" << std::hex << variable_value << ";\n";
|
||||
}
|
||||
|
||||
void write_closure(std::ofstream& output, const bool eof) noexcept override {
|
||||
output << (!eof ? "}\n\n": "}");
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user