CARLA
载入中...
搜索中...
未找到
LibCarla
source
test
client
LibCarla/source/test/client/OpenDrive.cpp
浏览该文件的文档.
1
// Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#include "
OpenDrive.h
"
8
9
// 检测宏 LIBCARLA_TEST_CONTENT_FOLDER 是否被定义,如果没有被定义,则给出错误提示
10
#ifndef LIBCARLA_TEST_CONTENT_FOLDER
11
# error Please define LIBCARLA_TEST_CONTENT_FOLDER.
12
#endif
13
14
#include <
carla/FileSystem.h
>
//包含一个名为FileSystem.h的头文件。这个头文件可能是carla库中与文件系统操作相关的定义文件。
15
16
#include <fstream>
//包含C++标准库中的<fstream>头文件。
17
#include <streambuf>
//包含C++标准库中的<streambuf>头文件。
18
19
namespace
util
{
20
21
// 获取宏定义目录下的OpenDrive目录下所有后缀为xodr的文件名并存储到向量列表中
22
std::vector<std::string>
OpenDrive::GetAvailableFiles
() {
23
return
carla::FileSystem::ListFolder
(
24
LIBCARLA_TEST_CONTENT_FOLDER
"/OpenDrive/"
,
25
"*.xodr"
);
26
}
27
28
// 加载获取宏定义目录下的OpenDrive目录下指定文件的内容为字符串
29
std::string
OpenDrive::Load
(
const
std::string &filename) {
30
const
std::string opendrive_folder = LIBCARLA_TEST_CONTENT_FOLDER
"/OpenDrive/"
;
31
std::ifstream file(opendrive_folder + filename);
32
return
std::string{std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>()};
33
}
34
35
}
// namespace util
FileSystem.h
OpenDrive.h
carla::FileSystem::ListFolder
static std::vector< std::string > ListFolder(const std::string &folder_path, const std::string &wildcard_pattern)
列出 folder_path 中匹配 wildcard_pattern 的常规文件 (不递归)。
Definition
FileSystem.cpp:46
util::OpenDrive::GetAvailableFiles
static std::vector< std::string > GetAvailableFiles()
Definition
LibCarla/source/test/client/OpenDrive.cpp:22
util::OpenDrive::Load
static std::string Load(const std::string &filename)
Definition
LibCarla/source/test/client/OpenDrive.cpp:29
util
Definition
test/Buffer.cpp:14
制作者
1.10.0