regex_program.hpp
1 /*
2  * Copyright (c) 2022-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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 {
25 namespace strings {
26 
40 struct regex_program {
41  struct regex_program_impl;
42 
53  static std::unique_ptr<regex_program> create(std::string_view pattern,
56 
63 
71 
77  [[nodiscard]] std::string pattern() const;
78 
84  [[nodiscard]] regex_flags flags() const;
85 
91  [[nodiscard]] capture_groups capture() const;
92 
98  [[nodiscard]] int32_t instructions_count() const;
99 
105  [[nodiscard]] int32_t groups_count() const;
106 
113  [[nodiscard]] std::size_t compute_working_memory_size(int32_t num_strings) const;
114 
115  ~regex_program();
116 
117  private:
118  regex_program() = delete;
119 
120  std::string _pattern;
121  regex_flags _flags;
122  capture_groups _capture;
123 
124  std::unique_ptr<regex_program_impl> _impl;
125 
132 
133  friend struct regex_device_builder;
134 };
135  // end of doxygen group
137 } // namespace strings
138 } // namespace cudf
capture_groups
Capture groups setting.
Definition: flags.hpp:82
regex_flags
Regex flags.
Definition: flags.hpp:35
@ EXTRACT
Capture groups processed normally for extract.
@ DEFAULT
default
Definition: flags.hpp:36
cuDF interfaces
Definition: aggregation.hpp:34
Regex program class.
regex_program & operator=(regex_program &&other)
Move operator assignment.
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_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)
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.