forked from OpenEnroth/OpenEnroth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdfa69d
commit b2a6a41
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <CLI/CLI.hpp> | ||
|
||
/** | ||
* Utility class that converts program arguments to utf-8 on Windows, and does nothing on POSIX. | ||
* | ||
* Use it like this: | ||
* ``` | ||
* int main(int argc, char **argv) { | ||
* try { | ||
* CliUtf8fy _(argc, argv); | ||
* // Use argc & argv here. | ||
* } catch (...) { | ||
* // Your error processing here. | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* Note that while `CliUtf8fy` constructor shouldn't normally throw, it can theoretically throw. | ||
* | ||
* Also note that `CliUtf8fy` is only needed if the program isn't using `platformMain`. | ||
*/ | ||
class CliUtf8fy { | ||
public: | ||
CliUtf8fy(int /*argc*/, char **&argv) { | ||
_app = std::make_unique<CLI::App>(); | ||
argv = _app->ensure_utf8(argv); | ||
} | ||
|
||
private: | ||
std::unique_ptr<CLI::App> _app; | ||
}; |