diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-29 19:19:23 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-29 19:19:23 +0100 |
| commit | a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df (patch) | |
| tree | 6dafcf2674780649dcdc2649855722357837a68e /nihil.posix/posix.argv.cc | |
| parent | 4fa6821e0645ff61a9380cd090abff472205c630 (diff) | |
| download | nihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.gz nihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.bz2 | |
wip macOS port
Diffstat (limited to 'nihil.posix/posix.argv.cc')
| -rw-r--r-- | nihil.posix/posix.argv.cc | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/nihil.posix/posix.argv.cc b/nihil.posix/posix.argv.cc deleted file mode 100644 index e6b1389..0000000 --- a/nihil.posix/posix.argv.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -module; - -#include <memory> -#include <ranges> -#include <string> -#include <vector> - -module nihil.posix; - -namespace nihil { - -argv::argv() = default; -argv::argv(argv &&) noexcept = default; -auto argv::operator=(this argv &, argv &&) -> argv & = default; - -argv::~argv() -{ - for (auto *arg : m_args) - delete[] arg; -} - -auto argv::data(this argv const &self) -> char const * const * -{ - return self.m_args.data(); -} - -auto argv::data(this argv &self) -> char * const * -{ - return self.m_args.data(); -} - -auto argv::size(this argv const &self) -{ - return self.m_args.size(); -} - -auto argv::begin(this argv const &self) -{ - return self.m_args.begin(); -} - -auto argv::end(this argv const &self) -{ - return self.m_args.end(); -} - - -auto argv::add_arg(this argv &self, std::string_view arg) -> void -{ - // Create a nul-terminated C string. - auto ptr = std::make_unique<char[]>(arg.size() + 1); - std::ranges::copy(arg, ptr.get()); - ptr[arg.size()] = '\0'; - - // Ensure we won't throw when emplacing the pointer. - self.m_args.reserve(self.m_args.size() + 1); - self.m_args.emplace_back(ptr.release()); -} - -} // namespace nihil - |
