Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rlib
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
river
rlib
Commits
1314649d
There was an error fetching the commit references. Please try again later.
Commit
1314649d
authored
6 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
tiny update. opt::getCommand interface update
parent
50f75532
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
impl/traceable_list.hpp
+2
-0
2 additions, 0 deletions
impl/traceable_list.hpp
opt.hpp
+19
-1
19 additions, 1 deletion
opt.hpp
with
23 additions
and
3 deletions
Makefile
+
2
−
2
View file @
1314649d
...
@@ -28,8 +28,8 @@ install_cmake: install_library
...
@@ -28,8 +28,8 @@ install_cmake: install_library
install
:
install_header install_library install_cmake
install
:
install_header install_library install_cmake
uninstall
:
uninstall
:
rm
-rf
$(
PREFIX
)
/include/rlib
rm
-rf
$(
PREFIX
)
/include/rlib
$(
PREFIX
)
/lib/cmake/rlib
rm
$(
PREFIX
)
/lib/libr.a
rm
-f
$(
PREFIX
)
/lib/libr.a
clean
:
clean
:
rm
*
.o
*
.a
rm
*
.o
*
.a
This diff is collapsed.
Click to expand it.
impl/traceable_list.hpp
+
2
−
0
View file @
1314649d
...
@@ -31,6 +31,8 @@ namespace rlib {
...
@@ -31,6 +31,8 @@ namespace rlib {
friend
class
traceable_list
;
friend
class
traceable_list
;
public:
public:
using
pointer
=
T
*
;
using
reference
=
T
&
;
explicit
iterator
(
node
*
ptr
)
:
ptr
(
ptr
)
{}
explicit
iterator
(
node
*
ptr
)
:
ptr
(
ptr
)
{}
explicit
iterator
(
T
*
data_pointer
)
:
ptr
(
reinterpret_cast
<
node
*>
(
data_pointer
))
{
explicit
iterator
(
T
*
data_pointer
)
:
ptr
(
reinterpret_cast
<
node
*>
(
data_pointer
))
{
...
...
This diff is collapsed.
Click to expand it.
opt.hpp
+
19
−
1
View file @
1314649d
...
@@ -25,16 +25,33 @@ namespace rlib {
...
@@ -25,16 +25,33 @@ namespace rlib {
public:
public:
opt_parser
()
=
delete
;
opt_parser
()
=
delete
;
opt_parser
(
size_t
arglen
,
char
**
argv
)
{
opt_parser
(
size_t
arglen
,
char
**
argv
)
{
if
(
argv
[
0
]
==
nullptr
)
throw
std
::
runtime_error
(
"Invalid argv passed to rlib::opt_parser. argv[0] is nullptr."
);
arg0
=
argv
[
0
];
for
(
size_t
cter
=
1
;
cter
<
arglen
;
++
cter
)
for
(
size_t
cter
=
1
;
cter
<
arglen
;
++
cter
)
args
.
push_back
(
std
::
string
(
argv
[
cter
]));
args
.
push_back
(
std
::
string
(
argv
[
cter
]));
}
}
rlib
::
string
getCommand
()
{
rlib
::
string
getSubCommand
()
{
if
(
args
.
empty
())
throw
std
::
runtime_error
(
"No sub-command available."
);
auto
cmd
=
std
::
move
(
args
[
0
]);
auto
cmd
=
std
::
move
(
args
[
0
]);
args
.
erase
(
args
.
begin
());
args
.
erase
(
args
.
begin
());
return
std
::
move
(
cmd
);
return
std
::
move
(
cmd
);
}
}
rlib
::
string
getSubCommand
(
const
std
::
string
&
def
)
{
if
(
args
.
empty
())
return
def
;
auto
cmd
=
std
::
move
(
args
[
0
]);
args
.
erase
(
args
.
begin
());
return
std
::
move
(
cmd
);
}
rlib
::
string
getSelf
()
{
return
arg0
;
}
rlib
::
string
getValueArg
(
const
std
::
string
&
argName
,
bool
required
=
true
,
const
std
::
string
&
def
=
std
::
string
())
rlib
::
string
getValueArg
(
const
std
::
string
&
argName
,
bool
required
=
true
,
const
std
::
string
&
def
=
std
::
string
())
{
//If required argument not exist, I'll throw. Else, return "" if arg is not read.
{
//If required argument not exist, I'll throw. Else, return "" if arg is not read.
using
rlib
::
literals
::
operator
""
_format
;
using
rlib
::
literals
::
operator
""
_format
;
...
@@ -102,6 +119,7 @@ namespace rlib {
...
@@ -102,6 +119,7 @@ namespace rlib {
}
}
private
:
private
:
std
::
vector
<
std
::
string
>
args
;
std
::
vector
<
std
::
string
>
args
;
std
::
string
arg0
;
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment