regex_program.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <cudf/strings/regex/flags.hpp>
8 #include <cudf/types.hpp>
9 
10 #include <memory>
11 #include <string>
12 
13 namespace CUDF_EXPORT cudf {
14 namespace strings {
15 
29 struct regex_program {
30  struct regex_program_impl;
31 
42  static std::unique_ptr<regex_program> create(std::string_view pattern,
44  capture_groups capture = capture_groups::EXTRACT);
45 
46  regex_program() = delete;
47  regex_program(regex_program const&) = delete;
48  regex_program& operator=(regex_program const&) = delete;
49 
55  regex_program(regex_program&& other) noexcept;
56 
64 
70  [[nodiscard]] std::string pattern() const;
71 
77  [[nodiscard]] regex_flags flags() const;
78 
84  [[nodiscard]] capture_groups capture() const;
85 
91  [[nodiscard]] int32_t instructions_count() const;
92 
98  [[nodiscard]] int32_t groups_count() const;
99 
106  [[nodiscard]] std::size_t compute_working_memory_size(int32_t num_strings) const;
107 
108  ~regex_program();
109 
110  private:
111  std::string _pattern;
112  regex_flags _flags;
113  capture_groups _capture;
114 
115  std::unique_ptr<regex_program_impl> _impl;
116 
122  regex_program(std::string_view pattern, regex_flags flags, capture_groups capture);
123 
124  friend struct regex_device_builder;
125 };
126  // end of doxygen group
128 } // namespace strings
129 } // namespace CUDF_EXPORT cudf
capture_groups
Capture groups setting.
Definition: flags.hpp:85
regex_flags
Regex flags.
Definition: flags.hpp:26
@ DEFAULT
default
Definition: flags.hpp:27
cuDF interfaces
Definition: host_udf.hpp:26
Regex program class.
static std::unique_ptr< regex_program > create(std::string_view pattern, regex_flags flags=regex_flags::DEFAULT, capture_groups capture=capture_groups::EXTRACT)
Create a program from a pattern.
int32_t groups_count() const
Return the number of capture groups in this instance.
capture_groups capture() const
Return the capture_groups used to create this instance.
std::string pattern() const
Return the pattern used to create this instance.
regex_program & operator=(regex_program &&other) noexcept
Move operator assignment.
regex_flags flags() const
Return the regex_flags used to create this instance.
int32_t instructions_count() const
Return the number of instructions in this instance.
regex_program(regex_program &&other) noexcept
Move constructor.
std::size_t compute_working_memory_size(int32_t num_strings) const
Return the size of the working memory for the regex execution.
Type declarations for libcudf.