mirror of
https://github.com/bkaradzic/bx.git
synced 2026-10-23 09:11:03 +00:00
This commit is contained in:
committed by
GitHub
parent
f56519b35d
commit
3fd3d3279e
@@ -10,6 +10,7 @@
|
||||
|
||||
namespace bx
|
||||
{
|
||||
struct AllocatorI;
|
||||
class Error;
|
||||
struct WriterI;
|
||||
|
||||
@@ -137,6 +138,34 @@ namespace bx
|
||||
int32_t m_numOptions;
|
||||
};
|
||||
|
||||
/// Process arguments as UTF-8.
|
||||
///
|
||||
/// On Windows `main` receives arguments converted to the ANSI code page, which loses every
|
||||
/// character the code page can't represent, so they are taken from the process command line
|
||||
/// instead. On other platforms, or when that fails, `_argv` is used as is.
|
||||
///
|
||||
class CommandLineArgs
|
||||
{
|
||||
public:
|
||||
///
|
||||
CommandLineArgs(AllocatorI* _allocator, int32_t _argc, const char* const* _argv);
|
||||
|
||||
///
|
||||
~CommandLineArgs();
|
||||
|
||||
///
|
||||
int32_t getArgc() const;
|
||||
|
||||
///
|
||||
const char** getArgv() const;
|
||||
|
||||
private:
|
||||
AllocatorI* m_allocator;
|
||||
void* m_data;
|
||||
int32_t m_argc;
|
||||
const char** m_argv;
|
||||
};
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#endif /// BX_COMMANDLINE_H_HEADER_GUARD
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace bx
|
||||
/// ^^^^^^^
|
||||
/// +-filename
|
||||
///
|
||||
/// Paths are UTF-8 on every platform. On Windows they are converted to UTF-16 before reaching
|
||||
/// the OS, so the process code page has no effect on them.
|
||||
///
|
||||
class FilePath
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace bx
|
||||
template<typename ProtoT>
|
||||
ProtoT dlsym(void* _handle, const StringView& _symbol);
|
||||
|
||||
/// Read an environment variable.
|
||||
/// Read an environment variable. Name and value are UTF-8.
|
||||
///
|
||||
/// @param[out] _out Buffer that receives the value (may be NULL to query required size).
|
||||
/// @param[in,out] _inOutSize On input the capacity of `_out`, on output the required size including terminator.
|
||||
@@ -137,7 +137,7 @@ namespace bx
|
||||
///
|
||||
bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name);
|
||||
|
||||
/// Set an environment variable.
|
||||
/// Set an environment variable. Name and value are UTF-8.
|
||||
///
|
||||
/// @param[in] _name Name of the environment variable.
|
||||
/// @param[in] _value Value to assign.
|
||||
@@ -146,7 +146,7 @@ namespace bx
|
||||
|
||||
/// Change current working directory of the process.
|
||||
///
|
||||
/// @param[in] _path Target directory path.
|
||||
/// @param[in] _path Target directory path, UTF-8.
|
||||
/// @returns 0 on success, non-zero on failure.
|
||||
///
|
||||
int chdir(const char* _path);
|
||||
|
||||
@@ -549,6 +549,16 @@ namespace bx
|
||||
/// Converts 64-bit unsigned integer value to string.
|
||||
int32_t toString(char* _out, int32_t _max, uint64_t _value, uint32_t _base = 10, char _separator = '\0');
|
||||
|
||||
/// Converts UTF-8 string to NUL terminated UTF-16 string. Returns number of UTF-16 code units
|
||||
/// written including the terminator, or 0 when the input is not valid UTF-8 or the output doesn't
|
||||
/// fit. With `_max` 0 returns the size required.
|
||||
int32_t toUtf16(uint16_t* _out, int32_t _max, const StringView& _str);
|
||||
|
||||
/// Converts NUL terminated UTF-16 string to NUL terminated UTF-8 string. Returns number of bytes
|
||||
/// written including the terminator, or 0 when the input is not valid UTF-16 or the output
|
||||
/// doesn't fit. With `_max` 0 returns the size required.
|
||||
int32_t fromUtf16(char* _out, int32_t _max, const uint16_t* _str);
|
||||
|
||||
/// Converts string to bool value.
|
||||
bool fromString(bool* _out, const StringView& _str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user