regex_program.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
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  ~regex_program();
50 
56  regex_program(regex_program&& other) noexcept;
57 
65 
71  [[nodiscard]] std::string pattern() const;
72 
78  [[nodiscard]] regex_flags flags() const;
79 
85  [[nodiscard]] capture_groups capture() const;
86 
92  [[nodiscard]] int32_t instructions_count() const;
93 
99  [[nodiscard]] int32_t groups_count() const;
100 
107  [[nodiscard]] std::size_t compute_working_memory_size(int32_t num_strings) const;
108 
109  private:
110  std::string _pattern;
111  regex_flags _flags;
112  capture_groups _capture;
113 
114  std::unique_ptr<regex_program_impl> _impl;
115 
121  regex_program(std::string_view pattern, regex_flags flags, capture_groups capture);
122 
123  friend struct regex_device_builder;
124 };
125  // end of doxygen group
127 } // namespace strings
128 } // namespace CUDF_EXPORT cudf
capture_groups
Capture groups setting.
Definition: flags.hpp:97
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.