Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a84eed8

Browse filesBrowse files
committed
fix config::set API
1 parent 0b070a6 commit a84eed8
Copy full SHA for a84eed8

3 files changed

+16-8Lines changed: 16 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎include/components.hpp‎

Copy file name to clipboardExpand all lines: include/components.hpp
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ namespace eclipse::events {
159159
};
160160
}
161161

162+
#ifndef ECLIPSE_DONT_DEFINE_IMPLS
163+
162164
namespace eclipse {
163165
/// @brief Get a menu tab handle by name. Creates the tab if it doesn't exist.
164166
/// @param name The name of the tab.
@@ -284,4 +286,6 @@ namespace eclipse {
284286
}
285287
}
286288

289+
#endif // ECLIPSE_DONT_DEFINE_IMPLS
290+
287291
#endif // ECLIPSE_COMPONENTS_HPP
Collapse file

‎include/config.hpp‎

Copy file name to clipboardExpand all lines: include/config.hpp
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace eclipse::events {
2222
explicit RequestConfigValueEvent(std::string key, bool internal = false)
2323
: m_key(std::move(key)), m_useInternal(internal) {}
2424
const std::string& getKey() const { return m_key; }
25-
T getValue() const { return m_value; }
25+
T&& getValue() { return std::move(m_value); }
2626
bool hasValue() const { return m_hasValue; }
2727
bool getUseInternal() const { return m_useInternal; }
2828

@@ -42,10 +42,10 @@ namespace eclipse::events {
4242
class SetConfigValueEvent : public geode::Event {
4343
public:
4444
SetConfigValueEvent(std::string key, T value, bool internal = false)
45-
: m_key(std::move(key)), m_value(value), m_useInternal(internal) {}
45+
: m_key(std::move(key)), m_value(std::move(value)), m_useInternal(internal) {}
4646

4747
std::string const& getKey() const { return m_key; }
48-
T getValue() const { return m_value; }
48+
T&& getValue() { return std::move(m_value); }
4949
bool getUseInternal() const { return m_useInternal; }
5050

5151
private:
@@ -56,15 +56,16 @@ namespace eclipse::events {
5656

5757
}
5858

59-
namespace eclipse::config {
59+
#ifndef ECLIPSE_DONT_DEFINE_IMPLS
6060

61+
namespace eclipse::config {
6162
/// @brief Get a config value by key from the session storage.
6263
/// @param key The key of the value.
6364
/// @param defaultValue The default value to return if the key doesn't exist.
6465
/// @return The value of the key or the default value if the key doesn't exist.
6566
template <SupportedType T>
6667
T get(std::string key, T defaultValue) {
67-
events::RequestConfigValueEvent<T> event(key);
68+
events::RequestConfigValueEvent<T> event(std::move(key));
6869
event.post();
6970
if (event.hasValue())
7071
return event.getValue();
@@ -77,7 +78,7 @@ namespace eclipse::config {
7778
/// @return The value of the key or the default value if the key doesn't exist.
7879
template <SupportedType T>
7980
T getInternal(std::string key, T defaultValue) {
80-
events::RequestConfigValueEvent<T> event(key, true);
81+
events::RequestConfigValueEvent<T> event(std::move(key), true);
8182
event.post();
8283
if (event.hasValue())
8384
return event.getValue();
@@ -89,16 +90,18 @@ namespace eclipse::config {
8990
/// @param value The value to set.
9091
template <SupportedType T>
9192
void set(std::string key, T value) {
92-
events::SetConfigValueEvent<T>(key, value, false).post();
93+
events::SetConfigValueEvent<T>(std::move(key), std::move(value), false).post();
9394
}
9495

9596
/// @brief Set a config value by key in the persistent storage (config.json).
9697
/// @param key The key of the value.
9798
/// @param value The value to set.
9899
template <SupportedType T>
99100
void setInternal(std::string key, T value) {
100-
events::SetConfigValueEvent<T>(key, value, true).post();
101+
events::SetConfigValueEvent<T>(std::move(key), std::move(value), true).post();
101102
}
102103
}
103104

105+
#endif // ECLIPSE_DONT_DEFINE_IMPLS
106+
104107
#endif // ECLIPSE_CONFIG_HPP
Collapse file

‎src/modules/api/events.cpp‎

Copy file name to clipboardExpand all lines: src/modules/api/events.cpp
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define ECLIPSE_DONT_DEFINE_IMPLS
12
#include <eclipse.hpp>
23
#include <modules/config/config.hpp>
34
#include <modules/gui/gui.hpp>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.