25 bool win32_parse_single_arg(
const char*& next,
const char* end, std::string& res)
28 while(next != end && *next ==
' ') {
36 bool is_escaped =
false;
38 for(; next !=
end; ++next) {
39 if(*next ==
' ' && !is_escaped) {
41 }
else if(*next ==
'"' && !is_escaped) {
44 }
else if(*next ==
'"' && is_escaped && next + 1 != end && *(next + 1) ==
'"') {
48 }
else if(*next ==
'"' && is_escaped) {
59 std::vector<std::string> win32_read_argv(
const std::string& input)
61 const char*
start = &input[0];
62 const char*
end =
start + input.size();
65 std::vector<std::string> res;
67 while(win32_parse_single_arg(
start, end, buffer)) {
68 res.emplace_back().swap(buffer);
78 std::vector<std::string>
read_argv([[maybe_unused]]
int argc, [[maybe_unused]]
char** argv)
84 auto flat_cmdline = unicode_cast<std::string>(std::wstring{GetCommandLineW()});
85 return win32_read_argv(flat_cmdline);
87 std::vector<std::string> args;
89 for(
int i = 0;
i < argc; ++
i) {
90 args.emplace_back(argv[
i]);
std::vector< std::string > read_argv([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
T end(const std::pair< T, T > &p)
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.