主页
libcudf
cucim
cudf-java
cudf
cugraph
cuml
cuproj
cuspatial
cuvs
cuxfilter
dask-cuda
dask-cudf
kvikio
libcudf
libcuml
libcuproj
libcuspatial
libkvikio
librmm
libucxx
raft
rapids-cmake
rapidsmpf
rmm
稳定版 (25.04)
每夜构建版 (25.06)
稳定版 (25.04)
旧版 (25.02)
include
cudf
strings
regex
regex_program.hpp
1
/*
2
* 版权所有 (c) 2022-2024, NVIDIA CORPORATION.
3
*
4
* 根据 Apache 许可,版本 2.0 (“许可”) 获得许可;
5
* 除非遵守许可,否则您不得使用此文件。
6
* 您可以在以下位置获得许可副本:
7
*
8
* https://apache.ac.cn/licenses/LICENSE-2.0
9
*
10
* 除非适用法律要求或书面同意,否则
11
* 根据许可分发的软件是按“原样”分发的,
12
* 不附带任何明示或暗示的保证或条件。
13
* 有关管理权限和限制的特定语言,请参阅许可。
14
*
15
*/
16
#pragma once
17
18
#include <cudf/strings/regex/flags.hpp>
19
#include <
cudf/types.hpp
>
20
21
#include <memory>
22
#include <string>
23
24
namespace
CUDF_EXPORT
cudf
{
25
namespace
strings {
26
40
/**
38
* @brief 正则表达式程序类。
39
*
40
* 表示一个编译好的正则表达式模式,用于执行正则表达式操作
41
* 字符串。创建后它是不可变的。
42
*/
43
struct
regex_program
{
44
struct
regex_program_impl;
45
53
/**
47
* @brief 从模式创建一个程序。
48
*
49
* @throw cudf::logic_error 如果模式无效
50
*
51
* @param pattern 正则表达式模式字符串。
52
* @param flags 正则表达式标志。
53
* @param capture 捕获组设置。
54
* @return 指向 regex_program 实例的 unique_ptr。
55
*/
56
static
std::unique_ptr<regex_program>
create
(std::string_view pattern,
57
regex_flags
flags =
regex_flags::DEFAULT
,
58
capture_groups
capture = capture_groups::EXTRACT);
59
60
regex_program
() =
delete
;
61
64
/**
63
* @brief 移动构造函数。
64
*/
65
regex_program
(
regex_program
&& other);
66
72
/**
68
* @brief 移动赋值运算符。
69
*/
70
regex_program
&
operator=
(
regex_program
&& other);
71
79
/**
73
* @brief 返回用于创建此实例的模式。
74
*/
75
[[nodiscard]] std::string
pattern
()
const
;
76
86
/**
78
* @brief 返回用于创建此实例的正则表达式标志。
79
*/
80
[[nodiscard]]
regex_flags
flags
()
const
;
81
93
/**
83
* @brief 返回用于创建此实例的捕获组设置。
84
*/
85
[[nodiscard]]
capture_groups
capture
()
const
;
86
100
/**
88
* @brief 返回此实例中的指令数量。
89
*/
cudf
90
[[nodiscard]] int32_t
instructions_count
()
const
;
91
107
/**
93
* @brief 返回此实例中的捕获组数量。
94
*/
95
[[nodiscard]] int32_t
groups_count
()
const
;
96
115
/**
98
* @brief 返回正则表达式执行所需的工作内存大小。
99
*
100
* @param num_strings 正在处理的字符串数量。
101
* @return 字节为单位的大小。
102
*/
103
[[nodiscard]] std::size_t
compute_working_memory_size
(int32_t num_strings)
const
;
104
117
~
regex_program
();
116
117
private
118
std::string _pattern;
119
regex_flags
_flags;
120
capture_groups
_capture;
121
122
std::unique_ptr<regex_program_impl> _impl;
123
131
/**
125
* @brief 构造函数。私有以便强制使用 `create` 静态方法。
126
*/
127
regex_program
(std::string_view pattern,
regex_flags
flags,
capture_groups
capture);
132
133
friend
struct
regex_device_builder;
134
};
135
// doxygen 组结束
137
}
// namespace strings
138
}
// namespace CUDF_EXPORT cudf
cudf::strings::capture_groups