AuroraRuntime/Include/Aurora/CmdLine/CmdLine.hpp
Jamie Reece Wilson 83f34b0c47 [*] I was right. String views are [mostly] pointless (*)
03:28:55:638  17>2 of 53388 functions (<0.1%) were compiled, the rest were copied from previous compilation.
03:28:55:638  17>  0 functions were new in current compilation
03:28:55:638  17>  65 functions had inline decision re-evaluated but remain unchanged
03:28:56:749  17>Finished generating code

the header of const AuString & is the same as std::string_view therefore nothing changes. in fact, we still need to alloc strings a bunch of times for a zero terminated string. worse, <c++20 always allocs each time we want to access a hashmap with o(1) lookup, making small hashmaps kinda pointless when we always have to alloc+copy (thx std)

perhaps this will help some language binders
2024-04-19 05:58:08 +01:00

67 lines
1.6 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: CmdLine.hpp
Date: 2022-1-31
Author: Reece
Note: Even kernels have a commandline so why not?
***/
#pragma once
namespace Aurora::CmdLine
{
/**
* @brief Returns a UTF-8 string array of argv[1, ...]
* @return
*/
AUKN_SYM const AuList<AuString> &GetCommandLineArguments();
/**
* @brief Performs a check on whether the exact key matches an argument
* @param key
* @return
*/
AUKN_SYM bool HasFlag(const AuROString &key);
/**
* @brief Performs a check on whether such string came before an equals sign
* @param key
* @return
*/
AUKN_SYM bool HasValue(const AuROString &key);
/**
* @brief Returns part after key= or defaultDefault
* @param key
* @param defaultValue
* @return
*/
AUKN_SYM const AuString &GetValue(const AuROString &key, const AuString &defaultValue);
/**
* @brief Returns part after key=
* @param key
* @return
*/
AUKN_SYM AuOptional<const AuString &> GetValue(const AuROString &key);
/**
* @brief Returns a constant array of values; key=values and /key values
* @param key
* @return
* @warning multiple of @param key must exist
*/
AUKN_SYM const AuList<AuString> &GetValues(const AuROString &key);
/**
* @brief Returns a constant array of flag keys
* @return
*/
AUKN_SYM const AuList<AuString> &GetFlags();
/**
* @brief Returns a constant array of value keys
* @return
*/
AUKN_SYM const AuList<AuString> &GetValues();
}