Fix style of #7269 after Vlad's comments

This commit is contained in:
Lancelot de Ferrière
2024-12-16 18:59:47 +01:00
committed by wraitii
parent dba968013f
commit ce197de0b0
2 changed files with 13 additions and 10 deletions
+6 -1
View File
@@ -112,6 +112,11 @@ OsPath CmdLineArgs::GetArg0() const
return m_Arg0;
}
const CmdLineArgs::ArgsT& CmdLineArgs::GetArgs() const
{
return m_Args;
}
std::vector<CStr> CmdLineArgs::GetArgsWithoutName() const
{
return m_ArgsWithoutName;
@@ -123,7 +128,7 @@ template<> void Script::ToJSVal<CmdLineArgs>(const ScriptRequest& rq, JS::Mutabl
return;
std::unordered_map<CStr, std::vector<CStr>> args;
for (const std::pair<CStr, CStr>& arg : val.m_Args)
for (const std::pair<CStr, CStr>& arg : val.GetArgs())
args.emplace(arg.first, std::vector<CStr>{}).first->second.emplace_back(arg.second);
JS::RootedValue argVal(rq.cx);
+7 -9
View File
@@ -21,21 +21,18 @@
#include "lib/os_path.h"
#include "ps/containers/Span.h"
#include "ps/CStr.h"
#include "scriptinterface/ScriptTypes.h"
#include <utility>
#include <vector>
class ScriptRequest;
namespace Script {
template<typename T>
void ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, const T& val);
}
class CmdLineArgs
{
public:
using ArgsT = std::vector<std::pair<CStr, CStr>>;
CmdLineArgs() {}
/**
@@ -72,16 +69,17 @@ public:
*/
OsPath GetArg0() const;
/**
* Returns all arguments that don't have a name (string started with '-').
*/
const ArgsT& GetArgs() const;
/**
* Returns all arguments that don't have a name (string started with '-').
*/
std::vector<CStr> GetArgsWithoutName() const;
private:
template<typename T>
friend void Script::ToJSVal(const ScriptRequest& rq, JS::MutableHandleValue ret, const T& val);
typedef std::vector<std::pair<CStr, CStr> > ArgsT;
ArgsT m_Args;
OsPath m_Arg0;
std::vector<CStr> m_ArgsWithoutName;