Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
6fa5b4f3
Commit
6fa5b4f3
authored
Feb 13, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Options parser improvement
parent
70485c2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
src/utils/options.cpp
src/utils/options.cpp
+3
-2
src/utils/options.hpp
src/utils/options.hpp
+11
-1
No files found.
src/utils/options.cpp
View file @
6fa5b4f3
...
@@ -48,8 +48,9 @@ opt::OptionsResult::OptionsResult(const std::vector<std::string> &args, const op
...
@@ -48,8 +48,9 @@ opt::OptionsResult::OptionsResult(const std::vector<std::string> &args, const op
{
{
}
}
opt
::
OptionsResult
::
OptionsResult
(
int
argc
,
char
**
argv
,
const
opt
::
OptionsDescription
&
desc
,
bool
freeArgv
)
opt
::
OptionsResult
::
OptionsResult
(
int
argc
,
char
**
argv
,
const
opt
::
OptionsDescription
&
desc
,
bool
freeArgv
,
:
m_description
{
desc
}
std
::
unique_ptr
<
IOptionsHandler
>
handler
)
:
m_handler
{
std
::
move
(
handler
)},
m_description
{
desc
}
{
{
argc
--
;
argc
--
;
argv
++
;
argv
++
;
...
...
src/utils/options.hpp
View file @
6fa5b4f3
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <cstring>
#include <cstring>
#include <istream>
#include <istream>
#include <memory>
#include <optional>
#include <optional>
#include <ostream>
#include <ostream>
#include <stdexcept>
#include <stdexcept>
...
@@ -80,15 +81,24 @@ struct OptionsDescription
...
@@ -80,15 +81,24 @@ struct OptionsDescription
}
}
};
};
class
IOptionsHandler
{
virtual
std
::
istream
istream
()
=
0
;
virtual
std
::
ostream
ostream
()
=
0
;
virtual
void
status
(
int
code
)
=
0
;
};
class
OptionsResult
class
OptionsResult
{
{
private:
private:
std
::
vector
<
std
::
string
>
m_positionalParams
{};
std
::
vector
<
std
::
string
>
m_positionalParams
{};
std
::
unordered_map
<
std
::
string
,
std
::
string
>
m_options
{};
std
::
unordered_map
<
std
::
string
,
std
::
string
>
m_options
{};
std
::
unique_ptr
<
IOptionsHandler
>
m_handler
;
OptionsDescription
m_description
;
OptionsDescription
m_description
;
public:
public:
OptionsResult
(
int
argc
,
char
**
argv
,
const
OptionsDescription
&
desc
,
bool
freeArgv
=
false
);
OptionsResult
(
int
argc
,
char
**
argv
,
const
OptionsDescription
&
desc
,
bool
freeArgv
=
false
,
std
::
unique_ptr
<
IOptionsHandler
>
handler
=
nullptr
);
OptionsResult
(
const
std
::
vector
<
std
::
string
>
&
args
,
const
OptionsDescription
&
desc
);
OptionsResult
(
const
std
::
vector
<
std
::
string
>
&
args
,
const
OptionsDescription
&
desc
);
public:
public:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment