mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
util: Replace boost::signals2 with std::function
This commit is contained in:
23
src/util.h
23
src/util.h
@@ -19,8 +19,8 @@
|
||||
#include <logging.h>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <utiltime.h>
|
||||
#include <utilmemory.h>
|
||||
#include <utiltime.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <exception>
|
||||
@@ -31,33 +31,24 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
#include <boost/thread/condition_variable.hpp> // for boost::thread_interrupted
|
||||
|
||||
// Application startup time (used for uptime calculation)
|
||||
int64_t GetStartupTime();
|
||||
|
||||
/** Signals for translation. */
|
||||
class CTranslationInterface
|
||||
{
|
||||
public:
|
||||
/** Translate a message to the native language of the user. */
|
||||
boost::signals2::signal<std::string (const char* psz)> Translate;
|
||||
};
|
||||
|
||||
extern CTranslationInterface translationInterface;
|
||||
|
||||
extern const char * const BITCOIN_CONF_FILENAME;
|
||||
extern const char * const BITCOIN_PID_FILENAME;
|
||||
|
||||
/** Translate a message to the native language of the user. */
|
||||
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
|
||||
|
||||
/**
|
||||
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
|
||||
* If no translation slot is registered, nothing is returned, and simply return the input.
|
||||
* Translation function.
|
||||
* If no translation function is set, simply return the input.
|
||||
*/
|
||||
inline std::string _(const char* psz)
|
||||
{
|
||||
boost::optional<std::string> rv = translationInterface.Translate(psz);
|
||||
return rv ? (*rv) : psz;
|
||||
return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz;
|
||||
}
|
||||
|
||||
void SetupEnvironment();
|
||||
|
||||
Reference in New Issue
Block a user