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
1adc0599
Commit
1adc0599
authored
Feb 13, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Options parser improvement
parent
69648564
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
src/utils/options.cpp
src/utils/options.cpp
+27
-1
src/utils/options.hpp
src/utils/options.hpp
+4
-0
No files found.
src/utils/options.cpp
View file @
1adc0599
...
@@ -18,6 +18,14 @@
...
@@ -18,6 +18,14 @@
static
constexpr
const
size_t
MAX_WIDTH
=
90
;
static
constexpr
const
size_t
MAX_WIDTH
=
90
;
static
char
**
ConvertArgs
(
const
std
::
vector
<
std
::
string
>
&
vec
)
{
char
**
res
=
static_cast
<
char
**>
(
malloc
(
sizeof
(
char
*
)
*
vec
.
size
()));
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
i
++
)
res
[
i
]
=
strdup
(
vec
[
i
].
c_str
());
return
res
;
}
static
std
::
string
ItemNameDisplay
(
const
opt
::
OptionItem
&
item
)
static
std
::
string
ItemNameDisplay
(
const
opt
::
OptionItem
&
item
)
{
{
std
::
stringstream
ss
{};
std
::
stringstream
ss
{};
...
@@ -35,7 +43,18 @@ static std::string ItemNameDisplay(const opt::OptionItem &item)
...
@@ -35,7 +43,18 @@ static std::string ItemNameDisplay(const opt::OptionItem &item)
return
ss
.
str
();
return
ss
.
str
();
}
}
opt
::
OptionsResult
::
OptionsResult
(
int
argc
,
char
**
argv
,
const
opt
::
OptionsDescription
&
desc
)
:
m_description
{
desc
}
opt
::
OptionsResult
::
OptionsResult
(
const
std
::
vector
<
std
::
string
>
&
args
,
const
opt
::
OptionsDescription
&
desc
)
:
OptionsResult
(
static_cast
<
int
>
(
args
.
size
()),
ConvertArgs
(
args
),
desc
,
true
)
{
}
opt
::
OptionsResult
::
OptionsResult
(
int
argc
,
char
**
argv
,
const
opt
::
OptionsDescription
&
desc
)
:
OptionsResult
(
argc
,
argv
,
desc
,
false
)
{
}
opt
::
OptionsResult
::
OptionsResult
(
int
argc
,
char
**
argv
,
const
opt
::
OptionsDescription
&
desc
,
bool
freeArgv
)
:
m_description
{
desc
}
{
{
argc
--
;
argc
--
;
argv
++
;
argv
++
;
...
@@ -139,6 +158,13 @@ opt::OptionsResult::OptionsResult(int argc, char **argv, const opt::OptionsDescr
...
@@ -139,6 +158,13 @@ opt::OptionsResult::OptionsResult(int argc, char **argv, const opt::OptionsDescr
}
}
}
}
}
}
if
(
freeArgv
)
{
for
(
int
i
=
0
;
i
<
argc
;
i
++
)
free
(
argv
[
i
]);
free
(
argv
);
}
}
}
bool
opt
::
OptionsResult
::
hasFlag
(
const
opt
::
OptionItem
&
item
)
const
bool
opt
::
OptionsResult
::
hasFlag
(
const
opt
::
OptionItem
&
item
)
const
...
...
src/utils/options.hpp
View file @
1adc0599
...
@@ -87,8 +87,12 @@ class OptionsResult
...
@@ -87,8 +87,12 @@ class OptionsResult
std
::
unordered_map
<
std
::
string
,
std
::
string
>
m_options
{};
std
::
unordered_map
<
std
::
string
,
std
::
string
>
m_options
{};
OptionsDescription
m_description
;
OptionsDescription
m_description
;
private:
OptionsResult
(
int
argc
,
char
**
argv
,
const
OptionsDescription
&
desc
,
bool
freeArgv
);
public:
public:
OptionsResult
(
int
argc
,
char
**
argv
,
const
OptionsDescription
&
desc
);
OptionsResult
(
int
argc
,
char
**
argv
,
const
OptionsDescription
&
desc
);
OptionsResult
(
const
std
::
vector
<
std
::
string
>
&
args
,
const
OptionsDescription
&
desc
);
public:
public:
bool
hasFlag
(
const
OptionItem
&
item
)
const
;
bool
hasFlag
(
const
OptionItem
&
item
)
const
;
...
...
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