Skip to content

Commit b558b34

Browse files
committed
Remove StringList from python API
Note that this removes the behavior of base == nullptr meaning "*". This was never used and it didn't work as bas_has_upper had UB for base==nullptr.
1 parent f4652ce commit b558b34

44 files changed

Lines changed: 479 additions & 1323 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/include/ert/util/hash.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef ERT_HASH_H
22
#define ERT_HASH_H
33

4-
#include <cstdlib>
5-
64
#include <ert/util/stringlist.hpp>
75
#include <ert/util/type_macros.hpp>
86
#include <ert/util/node_data.hpp>

lib/include/ert/util/stringlist.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ typedef struct stringlist_struct stringlist_type;
1515
typedef int(string_cmp_ftype)(const void *, const void *);
1616
typedef bool(file_pred_ftype)(const char *, const void *);
1717

18-
int stringlist_select_files(stringlist_type *names, const char *path,
19-
file_pred_ftype *predicate, const void *pred_arg);
20-
2118
const char *stringlist_get_last(const stringlist_type *stringlist);
2219
char *stringlist_pop(stringlist_type *stringlist);
2320

@@ -47,8 +44,6 @@ void stringlist_sort(stringlist_type *, string_cmp_ftype *string_cmp);
4744
void stringlist_reverse(stringlist_type *s);
4845
void stringlist_python_sort(stringlist_type *s, int cmp_flag);
4946

50-
int stringlist_select_matching_files(stringlist_type *names, const char *path,
51-
const char *file_pattern);
5247
UTIL_IS_INSTANCE_HEADER(stringlist);
5348

5449
#ifdef __cplusplus

lib/include/resdata/rd_grid.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include <ert/util/double_vector.hpp>
99
#include <ert/util/int_vector.hpp>
10-
#include <ert/util/stringlist.hpp>
1110
#include <ert/util/type_macros.hpp>
1211

1312
#include <resdata/rd_coarse_cell.hpp>

lib/include/resdata/rd_smspec.hpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <string>
88

99
#include <ert/util/float_vector.hpp>
10-
#include <ert/util/stringlist.hpp>
1110

1211
#include <resdata/rd_util.hpp>
1312
#include <resdata/smspec_node.hpp>
@@ -65,22 +64,19 @@ int rd_smspec_get_general_var_params_index(const rd_smspec_type *rd_smspec,
6564
const char *lookup_kw);
6665
bool rd_smspec_has_general_var(const rd_smspec_type *rd_smspec,
6766
const char *lookup_kw);
68-
void rd_smspec_select_matching_general_var_list(const rd_smspec_type *smspec,
69-
const char *pattern,
70-
stringlist_type *keys);
71-
stringlist_type *
72-
rd_smspec_alloc_matching_general_var_list(const rd_smspec_type *smspec,
73-
const char *pattern);
67+
std::vector<std::string>
68+
rd_smspec_select_matching_general_var_list(const rd_smspec_type *smspec,
69+
const char *pattern);
7470

7571
int rd_smspec_get_time_seconds(const rd_smspec_type *rd_smspec);
7672
int rd_smspec_get_time_index(const rd_smspec_type *rd_smspec);
7773
time_t rd_smspec_get_start_time(const rd_smspec_type *);
7874
bool rd_smspec_get_formatted(const rd_smspec_type *rd_smspec);
7975
const char *rd_smspec_get_header_file(const rd_smspec_type *rd_smspec);
80-
stringlist_type *rd_smspec_alloc_well_list(const rd_smspec_type *smspec,
81-
const char *pattern);
82-
stringlist_type *rd_smspec_alloc_group_list(const rd_smspec_type *smspec,
83-
const char *pattern);
76+
std::vector<std::string> rd_smspec_alloc_well_list(const rd_smspec_type *smspec,
77+
const char *pattern);
78+
std::vector<std::string>
79+
rd_smspec_alloc_group_list(const rd_smspec_type *smspec, const char *pattern);
8480
int rd_smspec_get_first_step(const rd_smspec_type *rd_smspec);
8581
int rd_smspec_get_restart_step(const rd_smspec_type *rd_smspec);
8682
const char *rd_smspec_get_restart_case(const rd_smspec_type *rd_smspec);

lib/include/resdata/rd_sum.hpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include <memory>
77
#include <optional>
88
#include <string>
9+
#include <vector>
910

10-
#include <ert/util/stringlist.hpp>
1111
#include <ert/util/time_t_vector.hpp>
1212
#include <ert/util/double_vector.hpp>
1313
#include "ert/util/type_macros.hpp"
@@ -38,7 +38,8 @@ const char *rd_sum_get_unit(const rd_sum_type *sum, const char *gen_key);
3838
double rd_sum_iget(const rd_sum_type *rd_sum, int time_index, int param_index);
3939
int rd_sum_get_data_length(const rd_sum_type *rd_sum);
4040

41-
rd_sum_type *rd_sum_fread_alloc(const char *, const stringlist_type *data_files,
41+
rd_sum_type *rd_sum_fread_alloc(const char *,
42+
const std::vector<std::string> &data_files,
4243
const char *key_join_string,
4344
bool include_restart, bool lazy_load,
4445
FileMode file_options = FileMode::DEFAULT);
@@ -93,16 +94,13 @@ const char *rd_sum_get_case(const rd_sum_type *);
9394
double rd_sum_get_sim_length(const rd_sum_type *rd_sum);
9495
double rd_sum_get_first_day(const rd_sum_type *rd_sum);
9596

96-
stringlist_type *rd_sum_alloc_well_list(const rd_sum_type *rd_sum,
97+
std::vector<std::string> rd_sum_alloc_well_list(const rd_sum_type *rd_sum,
98+
const char *pattern);
99+
std::vector<std::string> rd_sum_alloc_group_list(const rd_sum_type *rd_sum,
100+
const char *pattern);
101+
std::vector<std::string>
102+
rd_sum_select_matching_general_var_list(const rd_sum_type *rd_sum,
97103
const char *pattern);
98-
stringlist_type *rd_sum_alloc_group_list(const rd_sum_type *rd_sum,
99-
const char *pattern);
100-
stringlist_type *
101-
rd_sum_alloc_matching_general_var_list(const rd_sum_type *rd_sum,
102-
const char *pattern);
103-
void rd_sum_select_matching_general_var_list(const rd_sum_type *rd_sum,
104-
const char *pattern,
105-
stringlist_type *keys);
106104
rd_smspec_type *rd_sum_get_smspec(const rd_sum_type *rd_sum);
107105
rd_smspec_var_type rd_sum_identify_var_type(const char *var);
108106

@@ -125,8 +123,8 @@ rd_sum_tstep_type *rd_sum_add_tstep(rd_sum_type *rd_sum, int report_step,
125123
double sim_seconds);
126124

127125
void rd_sum_export_csv(const rd_sum_type *rd_sum, const char *filename,
128-
const stringlist_type *var_list, const char *date_format,
129-
const char *sep);
126+
const std::vector<std::string> &var_list,
127+
const char *date_format, const char *sep);
130128

131129
double_vector_type *rd_sum_alloc_days_solution(const rd_sum_type *rd_sum,
132130
const char *gen_key,

lib/include/resdata/rd_sum_data.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#pragma once
22
#include <cstdio>
3-
#include <cstdlib>
4-
#include <cstdint>
53
#include <ctime>
64

5+
#include <memory>
6+
#include <vector>
7+
#include <string>
8+
79
#include <ert/util/time_t_vector.hpp>
810
#include <ert/util/double_vector.hpp>
9-
#include <ert/util/stringlist.hpp>
1011

11-
#include <memory>
1212
#include <resdata/rd_smspec.hpp>
1313
#include <resdata/rd_sum_tstep.hpp>
1414
#include <resdata/smspec_node.hpp>
@@ -22,8 +22,9 @@ void rd_sum_data_add_case(rd_sum_data_type *self,
2222
void rd_sum_data_fwrite(const rd_sum_data_type *data, const char *rd_case,
2323
bool fmt_case, bool unified);
2424
bool rd_sum_data_can_write(const rd_sum_data_type *data);
25-
bool rd_sum_data_fread(rd_sum_data_type *data, const stringlist_type *filelist,
26-
bool lazy_load, FileMode file_options);
25+
bool rd_sum_data_fread(rd_sum_data_type *data,
26+
const std::vector<std::string> &filelist, bool lazy_load,
27+
FileMode file_options);
2728
rd_sum_data_type *rd_sum_data_alloc_writer(rd_smspec_type *smspec);
2829
rd_sum_data_type *rd_sum_data_alloc(rd_smspec_type *smspec);
2930
double rd_sum_data_time2days(const rd_sum_data_type *data, time_t sim_time);

lib/include/resdata/rd_util.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
#include <memory>
1010
#include <string>
1111
#include <string_view>
12+
#include <vector>
1213

13-
#include <ert/util/stringlist.hpp>
14-
#include <ert/util/time_t_vector.hpp>
1514
#include <ert/util/parser.hpp>
1615

1716
#include <resdata/rd_type.hpp>
@@ -84,8 +83,9 @@ time_t rd_make_datetime(int sec, int min, int hour, int mday, int month,
8483

8584
const char *rd_get_phase_name(Phase phase);
8685

87-
int rd_select_filelist(const char *path, const char *base, FileType file_type,
88-
bool fmt_file, stringlist_type *filelist);
86+
std::vector<std::string> rd_select_filelist(const char *path,
87+
std::string_view base,
88+
FileType file_type, bool fmt_file);
8989
void rd_set_datetime_values(time_t t, int *sec, int *min, int *hour, int *mday,
9090
int *month, int *year);
9191
bool rd_path_access(const char *rd_case);
@@ -155,3 +155,5 @@ inline std::string strip_spaces(std::string_view s) {
155155
return std::string(s.substr(first, last - first + 1));
156156
}
157157
} // namespace rd
158+
std::vector<std::string> select_matching_files(const std::string &path,
159+
const std::string &file_pattern);

lib/private-include/detail/resdata/rd_sum_file_data.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <stdexcept>
99

1010
#include <ert/util/vector.hpp>
11-
#include <ert/util/stringlist.hpp>
1211

1312
#include <resdata/rd_smspec.hpp>
1413
#include <resdata/rd_sum_tstep.hpp>
@@ -138,7 +137,7 @@ class rd_sum_file_data {
138137
bool can_write() const;
139138
void fwrite_unified(ERT::FortIO &fortio) const;
140139
void fwrite_multiple(const std::string &rd_case, bool fmt_case) const;
141-
bool fread(const stringlist_type *filelist, bool lazy_load,
140+
bool fread(const std::vector<std::string> &filelist, bool lazy_load,
142141
FileMode file_options = FileMode::DEFAULT);
143142

144143
private:

lib/resdata/cwrap_pybind.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <resdata/rd_sum_tstep.hpp>
2323

2424
#include <ert/util/double_vector.hpp>
25-
#include <ert/util/stringlist.hpp>
2625
#include <ert/util/time_t_vector.hpp>
2726
#include <ert/util/int_vector.hpp>
2827

@@ -97,21 +96,6 @@ template <> rd_sum_type *from_cwrap<rd_sum_type>(py::handle obj) {
9796
return cast_cwrap<rd_sum_type>(obj);
9897
}
9998

100-
py::object StringList() {
101-
static py::object cls;
102-
if (!cls) {
103-
cls = py::module_::import("resdata.util.util").attr("StringList");
104-
}
105-
return cls;
106-
}
107-
108-
template <> stringlist_type *from_cwrap<stringlist_type>(py::handle obj) {
109-
if (!py::isinstance(obj, StringList()))
110-
throw py::type_error("Expected StringList, got " +
111-
static_cast<std::string>(py::repr(obj)));
112-
return cast_cwrap<stringlist_type>(obj);
113-
}
114-
11599
py::object TimeVector() {
116100
static py::object cls;
117101
if (!cls) {

lib/resdata/rd_grid.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <ert/util/double_vector.hpp>
2323
#include <ert/util/int_vector.hpp>
2424
#include <ert/util/vector.hpp>
25-
#include <ert/util/stringlist.hpp>
2625

2726
#include <ert/geometry/geo_polygon.hpp>
2827

0 commit comments

Comments
 (0)