Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eos
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Richard Torenvliet
eos
Commits
2b965cd4
Commit
2b965cd4
authored
Jul 12, 2015
by
Patrik Huber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the landmark mapper to return an optional<string> instead of throwing
parent
5f21462e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
include/eos/core/LandmarkMapper.hpp
include/eos/core/LandmarkMapper.hpp
+13
-3
No files found.
include/eos/core/LandmarkMapper.hpp
View file @
2b965cd4
...
...
@@ -26,6 +26,7 @@
#define BOOST_ALL_DYN_LINK // Link against the dynamic boost lib. Seems to be necessary because we use /MD, i.e. link to the dynamic CRT.
#define BOOST_ALL_NO_LIB // Don't use the automatic library linking by boost with VS2010 (#pragma ...). Instead, we specify everything in cmake.
#endif
#include "boost/optional.hpp"
#include "boost/filesystem/path.hpp"
#include "boost/property_tree/ptree.hpp"
#include "boost/property_tree/info_parser.hpp"
...
...
@@ -52,6 +53,8 @@ public:
/**
* Constructs a new landmark mapper from a mappings-file.
* In case the file contains no mappings, a landmark mapper
* that performs an identity mapping is constructed.
*
* @param[in] filename A file with landmark mappings.
* @throws runtime_error exception if there is an error
...
...
@@ -87,18 +90,25 @@ public:
* Converts the given landmark name to the mapped name.
*
* @param[in] landmark_name A landmark name to convert.
* @return The mapped landmark name.
* @return The mapped landmark name
if a mapping exists, an empty optional otherwise
.
* @throws out_of_range exception if there is no mapping
* for the given landmarkName.
*/
std
::
string
convert
(
std
::
string
landmark_name
)
const
boost
::
optional
<
std
::
string
>
convert
(
std
::
string
landmark_name
)
const
{
if
(
landmark_mappings
.
empty
())
{
// perform identity mapping, i.e. return the input
return
landmark_name
;
}
else
{
return
landmark_mappings
.
at
(
landmark_name
);
// throws an out_of_range exception if landmarkName does not match the key of any element in the map
auto
&&
converted_landmark
=
landmark_mappings
.
find
(
landmark_name
);
if
(
converted_landmark
!=
std
::
end
(
landmark_mappings
))
{
// landmark mapping found, return it
return
converted_landmark
->
second
;
}
else
{
// landmark_name does not match the key of any element in the map
return
boost
::
none
;
}
}
};
...
...
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