1 #ifndef _misc__hpp__included__
2 #define _misc__hpp__included__
7 #include "library/string.hpp"
10 * \brief Get random hexes
12 * Get string of random hex characters of specified length.
14 * \param length The number of hex characters to return.
15 * \return The random hexadecimal string.
16 * \throws std::bad_alloc Not enough memory.
18 std::string
get_random_hexstring(size_t length
) throw(std::bad_alloc
);
21 * \brief Set random seed
23 * This function sets the random seed to use.
25 * \param seed The value to use as seed.
26 * \throw std::bad_alloc Not enough memory.
28 void set_random_seed(const std::string
& seed
) throw(std::bad_alloc
);
31 * \brief Set random seed to (hopefully) unique value
33 * This function sets the random seed to value that should only be used once. Note, the value is not necressarily
34 * crypto-secure, even if it is unique.
36 * \throw std::bad_alloc Not enough memory.
38 void set_random_seed() throw(std::bad_alloc
);
43 * Given commandline arguments, load a ROM.
45 * \param cmdline The command line.
46 * \return The loaded ROM set.
47 * \throws std::bad_alloc Not enough memory.
48 * \throws std::runtime_error Can't load the ROMset.
50 struct loaded_rom
load_rom_from_commandline(std::vector
<std::string
> cmdline
) throw(std::bad_alloc
,
54 * \brief Dump listing of regions to graphics system messages.
56 * \throws std::bad_alloc Not enough memory.
58 void dump_region_map() throw(std::bad_alloc
);
65 void fatal_error() throw();
68 * \brief Get path to config directory.
70 * \return The config directory path.
71 * \throw std::bad_alloc Not enough memory.
73 std::string
get_config_path() throw(std::bad_alloc
);
76 * \brief Panic on OOM.
81 * messages -> window::out().
83 class messages_relay_class
86 operator std::ostream
&() { return getstream(); }
87 static std::ostream
& getstream();
89 template<typename T
> inline std::ostream
& operator<<(messages_relay_class
& x
, T value
)
91 return messages_relay_class::getstream() << value
;
93 inline std::ostream
& operator<<(messages_relay_class
& x
, std::ostream
& (*fn
)(std::ostream
& o
))
95 return fn(messages_relay_class::getstream());
97 extern messages_relay_class messages
;
99 uint32_t gcd(uint32_t a
, uint32_t b
) throw();
102 * Return hexadecimal representation of address
104 std::string
format_address(void* addr
);
107 * Get state of running global ctors flag.
109 bool in_global_ctors();
111 * Clear the global ctors flag.
116 * Clean up filename from dangerous chars
118 std::string
safe_filename(const std::string
& str
);
121 * Mangle some characters ()|/
123 std::string
mangle_name(const std::string
& orig
);