ArKanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
function_data.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <typeindex>
6#include <unordered_map>
7
9public:
10 std::string path;
11
17 std::string function_name;
18
19 std::unordered_map<std::type_index, std::shared_ptr<void>> features;
20
21 template<typename T>
22 void add_feature(std::shared_ptr<T> feature) {
23 features[typeid(T)] = feature;
24 }
25
26 template<typename T>
27 std::shared_ptr<T> get_feature() const {
28 auto it = features.find(typeid(T));
29
30 if (it == features.end())
31 return nullptr;
32
33 return std::static_pointer_cast<T>(it->second);
34 }
35};
std::unordered_map< std::type_index, std::shared_ptr< void > > features
std::string function_name
Name of the function.
std::string path
std::shared_ptr< T > get_feature() const
void add_feature(std::shared_ptr< T > feature)