rcpputils
master
C++ API providing common utilities and data structures.
include
rcpputils
process.hpp
Go to the documentation of this file.
1
// Copyright 2020 Open Source Robotics Foundation, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef RCPPUTILS__PROCESS_HPP_
16
#define RCPPUTILS__PROCESS_HPP_
17
18
#include <rcutils/process.h>
19
20
#include <string>
21
22
namespace
rcpputils
23
{
24
26
35
std::string
get_executable_name
()
36
{
37
rcutils_allocator_t allocator = rcutils_get_default_allocator();
38
char
* executable_name = rcutils_get_executable_name(allocator);
39
if
(
nullptr
== executable_name) {
40
throw
std::runtime_error
(
"Failed to get executable name"
);
41
}
42
std::string
ret(executable_name);
43
allocator.deallocate(executable_name, allocator.state);
44
return
ret;
45
}
46
47
}
// namespace rcpputils
48
49
#endif // RCPPUTILS__PROCESS_HPP_
std::string
rcpputils
Definition:
asserts.hpp:37
rcpputils::get_executable_name
std::string get_executable_name()
Retrieve the current executable name.
Definition:
process.hpp:35
std::runtime_error
Generated by
1.8.17