File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 11#ifndef RUNCPP2_PLATFORM_UTIL_HPP
22#define RUNCPP2_PLATFORM_UTIL_HPP
33
4+ #include " runcpp2/Data/ParseCommon.hpp"
45#include < cstdint>
56#include < string>
7+ #include < unordered_map>
68#include < vector>
79
810namespace runcpp2
911{
1012 std::string ProcessPath (const std::string& path);
1113
1214 std::vector<std::string> GetPlatformNames ();
15+
16+ template <typename T>
17+ inline bool HasValueFromPlatformMap (const std::unordered_map<PlatformName, T>& map)
18+ {
19+ std::vector<std::string> platformNames = runcpp2::GetPlatformNames ();
20+
21+ for (int i = platformNames.size () - 1 ; i >= 0 ; --i)
22+ {
23+ if (map.find (platformNames.at (i)) != map.end ())
24+ return true ;
25+ }
26+
27+ return false ;
28+ }
29+
30+ template <typename T>
31+ inline const T* GetValueFromPlatformMap (const std::unordered_map<PlatformName, T>& map)
32+ {
33+ std::vector<std::string> platformNames = runcpp2::GetPlatformNames ();
34+
35+ for (int i = platformNames.size () - 1 ; i >= 0 ; --i)
36+ {
37+ if (map.find (platformNames.at (i)) != map.end ())
38+ return &map.at (platformNames[i]);
39+ }
40+
41+ return nullptr ;
42+ }
1343}
1444
1545#endif
You can’t perform that action at this time.
0 commit comments