mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-30 04:33:53 +00:00
Fixes #845 as discussed. Comparing the two approaches of getting `argv`: 1. The "old" way, through `CLI::argv()`: ✔️ Works automatically and almost everywhere ❌ Small abstraction overhead on macOS ❌ Does not work in weird edge-cases such as missing `/proc` 2. This PR, through `app.ensure_utf8`: ✔️ True zero-overhead abstraction: you don't pay for what you don't use ✔️ Less moving parts than the "old" approach, probably can't be broken ❌ Requires extra code to be written by the user (which is sad because ideally everyone should use this by default) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
37 lines
864 B
C++
37 lines
864 B
C++
// Copyright (c) 2017-2023, University of Cincinnati, developed by Henry Schreiner
|
|
// under NSF AWARD 1414736 and by the respective contributors.
|
|
// All rights reserved.
|
|
//
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#pragma once
|
|
|
|
// [CLI11:public_includes:set]
|
|
#include <string>
|
|
#include <vector>
|
|
// [CLI11:public_includes:end]
|
|
|
|
#include <CLI/Macros.hpp>
|
|
|
|
namespace CLI {
|
|
// [CLI11:argv_hpp:verbatim]
|
|
namespace detail {
|
|
#ifdef _WIN32
|
|
/// Decode and return UTF-8 argv from GetCommandLineW.
|
|
CLI11_INLINE std::vector<std::string> compute_win32_argv();
|
|
#endif
|
|
} // namespace detail
|
|
|
|
/// argc as passed in to this executable.
|
|
CLI11_INLINE int argc();
|
|
|
|
/// argv as passed in to this executable, converted to utf-8 on Windows.
|
|
CLI11_INLINE const char *const *argv();
|
|
|
|
// [CLI11:argv_hpp:end]
|
|
} // namespace CLI
|
|
|
|
#ifndef CLI11_COMPILE
|
|
#include "impl/Argv_inl.hpp"
|
|
#endif
|