-
-
Notifications
You must be signed in to change notification settings - Fork 854
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3944 from pqrs-org/open_application
Add open_application
- Loading branch information
Showing
40 changed files
with
243 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/share/types/software_function_details/open_application.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#pragma once | ||
|
||
#include <CoreGraphics/CoreGraphics.h> | ||
#include <optional> | ||
#include <pqrs/hash.hpp> | ||
#include <pqrs/json.hpp> | ||
#include <regex> | ||
|
||
namespace krbn { | ||
namespace software_function_details { | ||
class open_application { | ||
public: | ||
open_application(void) { | ||
} | ||
|
||
const std::optional<std::string>& get_bundle_identifier(void) const { | ||
return bundle_identifier_; | ||
} | ||
|
||
void set_bundle_identifier(const std::optional<std::string>& value) { | ||
bundle_identifier_ = value; | ||
} | ||
|
||
const std::optional<std::string>& get_file_path(void) const { | ||
return file_path_; | ||
} | ||
|
||
void set_file_path(const std::optional<std::string>& value) { | ||
file_path_ = value; | ||
} | ||
|
||
constexpr bool operator==(const open_application&) const = default; | ||
|
||
private: | ||
std::optional<std::string> bundle_identifier_; | ||
std::optional<std::string> file_path_; | ||
}; | ||
|
||
inline void to_json(nlohmann::json& json, const open_application& value) { | ||
if (auto v = value.get_bundle_identifier()) { | ||
json["bundle_identifier"] = *v; | ||
} | ||
if (auto v = value.get_file_path()) { | ||
json["file_path"] = *v; | ||
} | ||
} | ||
|
||
inline void from_json(const nlohmann::json& json, open_application& value) { | ||
pqrs::json::requires_object(json, "json"); | ||
|
||
for (const auto& [k, v] : json.items()) { | ||
if (k == "bundle_identifier") { | ||
pqrs::json::requires_string(v, "`" + k + "`"); | ||
value.set_bundle_identifier(v.get<std::string>()); | ||
} else if (k == "file_path") { | ||
pqrs::json::requires_string(v, "`" + k + "`"); | ||
value.set_file_path(v.get<std::string>()); | ||
} else { | ||
throw pqrs::json::unmarshal_error(fmt::format("unknown key: `{0}`", k)); | ||
} | ||
} | ||
} | ||
} // namespace software_function_details | ||
} // namespace krbn | ||
|
||
namespace std { | ||
template <> | ||
struct hash<krbn::software_function_details::open_application> final { | ||
std::size_t operator()(const krbn::software_function_details::open_application& value) const { | ||
std::size_t h = 0; | ||
|
||
pqrs::hash::combine(h, value.get_bundle_identifier()); | ||
pqrs::hash::combine(h, value.get_file_path()); | ||
|
||
return h; | ||
} | ||
}; | ||
} // namespace std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
include ../Makefile.rules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
all: build_make | ||
./build/karabiner_test | ||
MallocNanoZone=0 ./build/karabiner_test | ||
|
||
clean: clean_builds | ||
|
||
|
Oops, something went wrong.