Electroneum
Loading...
Searching...
No Matches
epee Namespace Reference

Namespaces

namespace  ado_db_helper
namespace  file_io_utils
namespace  fnv
namespace  net_utils
namespace  math_helper
namespace  misc_utils
namespace  debug
namespace  json_rpc
namespace  levin
namespace  profile_tools
namespace  reg_utils
namespace  serialization
namespace  StorageNamed
namespace  string_encoding
namespace  string_tools
namespace  tiny_ini
namespace  zlib_helper
namespace  tests

Classes

class  async_stdin_reader
class  async_console_handler
class  command_handler
class  console_handlers_binder
class  copyable_atomic
struct  to_hex
struct  from_hex
class  mlocker
struct  mlocked
class  http_server_impl_base
class  jsonrpc_server_impl_base
class  global_regexp_critical_section
struct  enableable
class  service_impl_base
class  span
 Non-owning sequence of data. Does not deep copy. More...
class  initializer
class  crypted_storage
struct  simple_event
class  critical_section
class  critical_region_t
class  critical_region
class  shared_critical_section
class  shared_guard
class  exclusive_guard
class  event
class  wipeable_string

Typedefs

template<class T, size_t N>
using mlocked_arr = mlocked<std::array<T, N>>

Enumerations

enum  console_colors {
  console_color_default , console_color_white , console_color_red , console_color_green ,
  console_color_blue , console_color_cyan , console_color_magenta , console_color_yellow
}

Functions

template<class t_server>
bool empty_commands_handler (t_server *psrv, const std::string &command)
template<class t_server, class t_handler>
bool start_default_console (t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
template<class t_server, class t_handler>
bool start_default_console (t_server *ptsrv, t_handler handlr, const std::string &prompt, const std::string &usage="")
template<class t_server>
bool start_default_console (t_server *ptsrv, const std::string &prompt, const std::string &usage="")
template<class t_server, class t_handler>
bool no_srv_param_adapter (t_server *ptsrv, const std::string &cmd, t_handler handlr)
template<class t_server, class t_handler>
bool run_default_console_handler_no_srv_param (t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
template<class t_server, class t_handler>
bool run_default_console_handler_no_srv_param (t_server *ptsrv, t_handler handlr, const std::string &prompt, const std::string &usage="")
template<class t_server, class t_handler>
bool start_default_console_handler_no_srv_param (t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
template<class t_server, class t_handler>
bool start_default_console_handler_no_srv_param (t_server *ptsrv, t_handler handlr, const std::string &prompt, const std::string &usage="")
bool is_stdout_a_tty ()
void set_console_color (int color, bool bright)
void reset_console_color ()
template<typename T>
Tunwrap (mlocked< T > &src)
template<typename T>
const Tunwrap (mlocked< T > const &src)
template<typename T>
void serialize_default (const T &t, T v)
template<typename T>
void serialize_default (T &t, T v)
template<typename T>
constexpr span< const typename T::value_type > to_span (const T &src)
template<typename T>
constexpr span< typename T::value_type > to_mut_span (T &src)
template<typename T>
constexpr bool has_padding () noexcept
template<typename T>
span< const std::uint8_t > to_byte_span (const span< const T > src) noexcept
template<typename T>
span< const std::uint8_t > as_byte_span (const T &src) noexcept
template<typename T>
span< std::uint8_t > as_mut_byte_span (T &src) noexcept
template<typename T>
span< const Tstrspan (const std::string &s) noexcept
 make a span from a std::string
template<class Type>
Type::iterator to_nonsonst_iterator (Type &obj, typename Type::const_iterator it)
template<class Type>
Type::iterator to_nonsonst_iterator (typename Type::iterator base_it, typename Type::const_iterator it)
const char * get_wait_for_result_as_text (DWORD res)

Variables

unsigned int g_test_dbg_lock_sleep = 0

Typedef Documentation

◆ mlocked_arr

template<class T, size_t N>
using epee::mlocked_arr = mlocked<std::array<T, N>>

Definition at line 86 of file mlocker.h.

Enumeration Type Documentation

◆ console_colors

Enumerator
console_color_default 
console_color_white 
console_color_red 
console_color_green 
console_color_blue 
console_color_cyan 
console_color_magenta 
console_color_yellow 

Definition at line 206 of file misc_log_ex.h.

Function Documentation

◆ as_byte_span()

template<typename T>
span< const std::uint8_t > epee::as_byte_span ( const T & src)
noexcept
Returns
span<const std::uint8_t> which represents the bytes at &src.

Definition at line 153 of file span.h.

154 {
155 static_assert(!std::is_empty<T>(), "empty types will not work -> sizeof == 1");
156 static_assert(!has_padding<T>(), "source type may have padding");
157 return {reinterpret_cast<const std::uint8_t*>(std::addressof(src)), sizeof(T)};
158 }
constexpr bool has_padding() noexcept
Definition span.h:138
#define T(x)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ as_mut_byte_span()

template<typename T>
span< std::uint8_t > epee::as_mut_byte_span ( T & src)
noexcept
Returns
span<std::uint8_t> which represents the bytes at &src.

Definition at line 162 of file span.h.

163 {
164 static_assert(!std::is_empty<T>(), "empty types will not work -> sizeof == 1");
165 static_assert(!has_padding<T>(), "source type may have padding");
166 return {reinterpret_cast<std::uint8_t*>(std::addressof(src)), sizeof(T)};
167 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty_commands_handler()

template<class t_server>
bool epee::empty_commands_handler ( t_server * psrv,
const std::string & command )

Definition at line 284 of file console_handler.h.

285 {
286 return true;
287 }
Here is the caller graph for this function:

◆ get_wait_for_result_as_text()

const char * epee::get_wait_for_result_as_text ( DWORD res)
inline

Definition at line 210 of file winobj.h.

211 {
212 switch(res)
213 {
214 case WAIT_ABANDONED: return "WAIT_ABANDONED";
215 case WAIT_TIMEOUT: return "WAIT_TIMEOUT";
216 case WAIT_OBJECT_0: return "WAIT_OBJECT_0";
217 case WAIT_OBJECT_0+1: return "WAIT_OBJECT_1";
218 case WAIT_OBJECT_0+2: return "WAIT_OBJECT_2";
219 default:
220 return "UNKNOWN CODE";
221 }
222
223 }
const char * res

◆ has_padding()

template<typename T>
bool epee::has_padding ( )
constexprnoexcept

Definition at line 138 of file span.h.

139 {
140 return !std::is_standard_layout<T>() || alignof(T) != 1;
141 }
Here is the caller graph for this function:

◆ is_stdout_a_tty()

bool epee::is_stdout_a_tty ( )

Definition at line 323 of file mlog.cpp.

324{
325 static std::atomic<bool> initialized(false);
326 static std::atomic<bool> is_a_tty(false);
327
328 if (!initialized.load(std::memory_order_acquire))
329 {
330#if defined(WIN32)
331 is_a_tty.store(0 != _isatty(_fileno(stdout)), std::memory_order_relaxed);
332#else
333 is_a_tty.store(0 != isatty(fileno(stdout)), std::memory_order_relaxed);
334#endif
335 initialized.store(true, std::memory_order_release);
336 }
337
338 return is_a_tty.load(std::memory_order_relaxed);
339}
Here is the caller graph for this function:

◆ no_srv_param_adapter()

template<class t_server, class t_handler>
bool epee::no_srv_param_adapter ( t_server * ptsrv,
const std::string & cmd,
t_handler handlr )

Definition at line 429 of file console_handler.h.

430 {
431 return handlr(cmd);
432 }
Here is the caller graph for this function:

◆ reset_console_color()

void epee::reset_console_color ( )

Definition at line 460 of file mlog.cpp.

460 {
461 if (!is_stdout_a_tty())
462 return;
463
464#ifdef WIN32
465 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
466 SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
467#else
468 std::cout << "\033[0m";
469 std::cout.flush();
470#endif
471}
bool is_stdout_a_tty()
Definition mlog.cpp:323
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_default_console_handler_no_srv_param() [1/2]

template<class t_server, class t_handler>
bool epee::run_default_console_handler_no_srv_param ( t_server * ptsrv,
t_handler handlr,
const std::string & prompt,
const std::string & usage = "" )

Definition at line 442 of file console_handler.h.

443 {
444 return run_default_console_handler_no_srv_param(ptsrv, handlr, [prompt](){return prompt;},usage);
445 }
bool run_default_console_handler_no_srv_param(t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
Here is the call graph for this function:

◆ run_default_console_handler_no_srv_param() [2/2]

template<class t_server, class t_handler>
bool epee::run_default_console_handler_no_srv_param ( t_server * ptsrv,
t_handler handlr,
std::function< std::string(void)> prompt,
const std::string & usage = "" )

Definition at line 435 of file console_handler.h.

436 {
437 async_console_handler console_handler;
438 return console_handler.run(ptsrv, std::bind<bool>(no_srv_param_adapter<t_server, t_handler>, std::placeholders::_1, std::placeholders::_2, handlr), prompt, usage);
439 }
bool run(t_server *psrv, chain_handler ch_handler, std::function< std::string(void)> prompt, const std::string &usage="")
bool no_srv_param_adapter(t_server *ptsrv, const std::string &cmd, t_handler handlr)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialize_default() [1/2]

template<typename T>
void epee::serialize_default ( const T & t,
T v )
inline

Definition at line 75 of file keyvalue_serialization.h.

75{ }

◆ serialize_default() [2/2]

template<typename T>
void epee::serialize_default ( T & t,
T v )
inline

Definition at line 76 of file keyvalue_serialization.h.

76{ t = v; }

◆ set_console_color()

void epee::set_console_color ( int color,
bool bright )

Definition at line 341 of file mlog.cpp.

342{
343 if (!is_stdout_a_tty())
344 return;
345
346 switch(color)
347 {
349 {
350#ifdef WIN32
351 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
352 SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE| (bright ? FOREGROUND_INTENSITY:0));
353#else
354 if(bright)
355 std::cout << "\033[1;37m";
356 else
357 std::cout << "\033[0m";
358#endif
359 }
360 break;
362 {
363#ifdef WIN32
364 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
365 SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | (bright ? FOREGROUND_INTENSITY:0));
366#else
367 if(bright)
368 std::cout << "\033[1;37m";
369 else
370 std::cout << "\033[0;37m";
371#endif
372 }
373 break;
375 {
376#ifdef WIN32
377 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
378 SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | (bright ? FOREGROUND_INTENSITY:0));
379#else
380 if(bright)
381 std::cout << "\033[1;31m";
382 else
383 std::cout << "\033[0;31m";
384#endif
385 }
386 break;
388 {
389#ifdef WIN32
390 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
391 SetConsoleTextAttribute(h_stdout, FOREGROUND_GREEN | (bright ? FOREGROUND_INTENSITY:0));
392#else
393 if(bright)
394 std::cout << "\033[1;32m";
395 else
396 std::cout << "\033[0;32m";
397#endif
398 }
399 break;
400
402 {
403#ifdef WIN32
404 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
405 SetConsoleTextAttribute(h_stdout, FOREGROUND_BLUE | FOREGROUND_INTENSITY);//(bright ? FOREGROUND_INTENSITY:0));
406#else
407 if(bright)
408 std::cout << "\033[1;34m";
409 else
410 std::cout << "\033[0;34m";
411#endif
412 }
413 break;
414
416 {
417#ifdef WIN32
418 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
419 SetConsoleTextAttribute(h_stdout, FOREGROUND_GREEN | FOREGROUND_BLUE | (bright ? FOREGROUND_INTENSITY:0));
420#else
421 if(bright)
422 std::cout << "\033[1;36m";
423 else
424 std::cout << "\033[0;36m";
425#endif
426 }
427 break;
428
430 {
431#ifdef WIN32
432 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
433 SetConsoleTextAttribute(h_stdout, FOREGROUND_BLUE | FOREGROUND_RED | (bright ? FOREGROUND_INTENSITY:0));
434#else
435 if(bright)
436 std::cout << "\033[1;35m";
437 else
438 std::cout << "\033[0;35m";
439#endif
440 }
441 break;
442
444 {
445#ifdef WIN32
446 HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
447 SetConsoleTextAttribute(h_stdout, FOREGROUND_RED | FOREGROUND_GREEN | (bright ? FOREGROUND_INTENSITY:0));
448#else
449 if(bright)
450 std::cout << "\033[1;33m";
451 else
452 std::cout << "\033[0;33m";
453#endif
454 }
455 break;
456
457 }
458}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_default_console() [1/3]

template<class t_server>
bool epee::start_default_console ( t_server * ptsrv,
const std::string & prompt,
const std::string & usage = "" )

Definition at line 423 of file console_handler.h.

424 {
425 return start_default_console(ptsrv, empty_commands_handler<t_server>, prompt, usage);
426 }
bool empty_commands_handler(t_server *psrv, const std::string &command)
bool start_default_console(t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
Here is the call graph for this function:

◆ start_default_console() [2/3]

template<class t_server, class t_handler>
bool epee::start_default_console ( t_server * ptsrv,
t_handler handlr,
const std::string & prompt,
const std::string & usage = "" )

Definition at line 417 of file console_handler.h.

418 {
419 return start_default_console(ptsrv, handlr, [prompt](){ return prompt; }, usage);
420 }
Here is the call graph for this function:

◆ start_default_console() [3/3]

template<class t_server, class t_handler>
bool epee::start_default_console ( t_server * ptsrv,
t_handler handlr,
std::function< std::string(void)> prompt,
const std::string & usage = "" )

Definition at line 409 of file console_handler.h.

410 {
411 std::shared_ptr<async_console_handler> console_handler = std::make_shared<async_console_handler>();
412 boost::thread([=](){console_handler->run<t_server, t_handler>(ptsrv, handlr, prompt, usage);}).detach();
413 return true;
414 }
Here is the caller graph for this function:

◆ start_default_console_handler_no_srv_param() [1/2]

template<class t_server, class t_handler>
bool epee::start_default_console_handler_no_srv_param ( t_server * ptsrv,
t_handler handlr,
const std::string & prompt,
const std::string & usage = "" )

Definition at line 455 of file console_handler.h.

456 {
457 return start_default_console_handler_no_srv_param(ptsrv, handlr, [prompt](){return prompt;}, usage);
458 }
bool start_default_console_handler_no_srv_param(t_server *ptsrv, t_handler handlr, std::function< std::string(void)> prompt, const std::string &usage="")
Here is the call graph for this function:

◆ start_default_console_handler_no_srv_param() [2/2]

template<class t_server, class t_handler>
bool epee::start_default_console_handler_no_srv_param ( t_server * ptsrv,
t_handler handlr,
std::function< std::string(void)> prompt,
const std::string & usage = "" )

Definition at line 448 of file console_handler.h.

449 {
450 boost::thread( boost::bind(run_default_console_handler_no_srv_param<t_server, t_handler>, ptsrv, handlr, prompt, usage) );
451 return true;
452 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ strspan()

template<typename T>
span< const T > epee::strspan ( const std::string & s)
noexcept

make a span from a std::string

Definition at line 171 of file span.h.

172 {
173 static_assert(std::is_same<T, char>() || std::is_same<T, unsigned char>() || std::is_same<T, int8_t>() || std::is_same<T, uint8_t>(), "Unexpected type");
174 return {reinterpret_cast<const T*>(s.data()), s.size()};
175 }
Here is the caller graph for this function:

◆ to_byte_span()

template<typename T>
span< const std::uint8_t > epee::to_byte_span ( const span< const T > src)
noexcept
Returns
Cast data from src as span<const std::uint8_t>.

Definition at line 145 of file span.h.

146 {
147 static_assert(!has_padding<T>(), "source type may have padding");
148 return {reinterpret_cast<const std::uint8_t*>(src.data()), src.size_bytes()};
149 }
constexpr std::size_t size_bytes() const noexcept
Definition span.h:112
constexpr pointer data() const noexcept
Definition span.h:110
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_mut_span()

template<typename T>
span< typename T::value_type > epee::to_mut_span ( T & src)
constexpr
Returns
span<T::value_type> from a STL compatible src.

Definition at line 131 of file span.h.

132 {
133 // compiler provides diagnostic if size() is not size_t.
134 return {src.data(), src.size()};
135 }
Here is the caller graph for this function:

◆ to_nonsonst_iterator() [1/2]

template<class Type>
Type::iterator epee::to_nonsonst_iterator ( Type & obj,
typename Type::const_iterator it )

Definition at line 36 of file to_nonconst_iterator.h.

37{
38 typename Type::difference_type dist = std::distance(static_cast<typename Type::const_iterator>(obj.begin()), it);
39 typename Type::iterator res_it = obj.begin()+dist;
40 return res_it;
41}

◆ to_nonsonst_iterator() [2/2]

template<class Type>
Type::iterator epee::to_nonsonst_iterator ( typename Type::iterator base_it,
typename Type::const_iterator it )

Definition at line 45 of file to_nonconst_iterator.h.

46{
47 typename Type::difference_type dist = std::distance(static_cast<typename Type::const_iterator>(base_it), it);
48 typename Type::iterator res_it = base_it+dist;
49 return res_it;
50}

◆ to_span()

template<typename T>
span< const typename T::value_type > epee::to_span ( const T & src)
constexpr
Returns
span<const T::value_type> from a STL compatible src.

Definition at line 123 of file span.h.

124 {
125 // compiler provides diagnostic if size() is not size_t.
126 return {src.data(), src.size()};
127 }
Here is the caller graph for this function:

◆ unwrap() [1/2]

template<typename T>
T & epee::unwrap ( mlocked< T > & src)

Definition at line 80 of file mlocker.h.

80{ return src; }
Here is the caller graph for this function:

◆ unwrap() [2/2]

template<typename T>
const T & epee::unwrap ( mlocked< T > const & src)

Definition at line 83 of file mlocker.h.

83{ return src; }

Variable Documentation

◆ g_test_dbg_lock_sleep

unsigned int epee::g_test_dbg_lock_sleep = 0

Definition at line 48 of file wallet_manager.cpp.