Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
cdo
Commits
7fdf5710
Commit
7fdf5710
authored
3 weeks ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
set_query_parameter: parse key=levidx
parent
bfd04761
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!355
M214003/develop
Pipeline
#103593
passed
3 weeks ago
Stage: build
Stage: check
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libcdi
+1
-1
1 addition, 1 deletion
libcdi
src/cdo_query.cc
+31
-9
31 additions, 9 deletions
src/cdo_query.cc
with
32 additions
and
10 deletions
libcdi
@
2c786cad
Compare
12a7893c
...
2c786cad
Subproject commit
12a7893cbae4aa7b33a6d67d2d683fb1204f02
08
Subproject commit
2c786cad0d08c0dfcf59c4cd79bc19f9c2ffe
08
9
This diff is collapsed.
Click to expand it.
src/cdo_query.cc
+
31
−
9
View file @
7fdf5710
...
...
@@ -46,6 +46,27 @@ decode_cell_parameter(std::string const ¶m)
return
cells
;
}
static
std
::
vector
<
int
>
decode_levidx_parameter
(
std
::
string
const
&
param
)
{
const
std
::
string
separator
(
"/to/"
);
std
::
vector
<
int
>
levidx
;
auto
n
=
param
.
find
(
separator
);
if
(
n
==
std
::
string
::
npos
)
{
levidx
.
push_back
(
parameter_to_int
(
param
));
}
else
{
auto
v1
=
parameter_to_int
(
param
.
substr
(
0
,
n
));
auto
v2
=
parameter_to_int
(
param
.
substr
(
n
+
separator
.
size
()));
if
(
v2
<
v1
)
cdo_abort
(
"Second parameter %zu muss be greater than first parameter %zu!"
,
v2
,
v1
);
levidx
.
push_back
(
v1
);
auto
numVals
=
(
v2
-
v1
+
1
);
if
(
numVals
>
1
)
levidx
.
push_back
(
numVals
);
}
return
levidx
;
}
std
::
string
set_query_parameter
(
const
KVList
&
kvlist
,
CdiQuery
*
query
)
{
...
...
@@ -57,14 +78,10 @@ set_query_parameter(const KVList &kvlist, CdiQuery *query)
int
numValues
=
kv
.
nvalues
;
if
(
numValues
<
1
)
cdo_abort
(
"Missing value for parameter key >%s<!"
,
key
);
// clang-format off
if
(
key
==
"name"
)
{
std
::
vector
<
char
*>
queryNames
(
numValues
);
for
(
int
i
=
0
;
i
<
numValues
;
++
i
)
{
queryNames
[
i
]
=
(
char
*
)
kv
.
values
[
i
].
c_str
();
}
std
::
vector
<
char
*>
queryNames
(
numValues
);
for
(
int
i
=
0
;
i
<
numValues
;
++
i
)
{
queryNames
[
i
]
=
(
char
*
)
kv
.
values
[
i
].
c_str
();
}
cdiQuerySetNames
(
query
,
queryNames
.
size
(),
queryNames
.
data
());
}
else
if
(
key
==
"step"
)
...
...
@@ -85,13 +102,18 @@ set_query_parameter(const KVList &kvlist, CdiQuery *query)
auto
queryCells
=
decode_cell_parameter
(
kv
.
values
[
0
]);
cdiQuerySetCellidx
(
query
,
queryCells
.
size
(),
queryCells
.
data
());
}
else
if
(
key
==
"levidx"
)
{
if
(
numValues
>
1
)
cdo_abort
(
"Too many values for key=levidx (maxvalues=1 or range=start/to/end)"
);
auto
queryCells
=
decode_levidx_parameter
(
kv
.
values
[
0
]);
cdiQuerySetLevidx
(
query
,
queryCells
.
size
(),
queryCells
.
data
());
}
else
if
(
key
==
"path"
)
{
path
=
kv
.
values
[
0
];
for
(
int
i
=
1
;
i
<
numValues
;
++
i
)
path
+=
","
+
kv
.
values
[
i
];
for
(
int
i
=
1
;
i
<
numValues
;
++
i
)
{
path
+=
","
+
kv
.
values
[
i
];
}
}
else
cdo_abort
(
"Invalid parameter key >%s<!"
,
key
);
// clang-format on
else
{
cdo_abort
(
"Invalid parameter key >%s<!"
,
key
);
}
}
return
path
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment