-
Notifications
You must be signed in to change notification settings - Fork 123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some refactoring would be good and the usual things are missing (docu, comments). But looks nice for a first draft!
src/plugins/range/range.c
Outdated
{ | ||
pos = 1; | ||
char * endPtr; | ||
a = strtoll (ptr, &endPtr, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move this code to a base lib? It is so common..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think there's much gain in it, but probably the way the current version handles it (union + enum) ?
src/plugins/range/testmod_range.c
Outdated
|
||
init (argc, argv); | ||
|
||
test ("5", 1, "1-10"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice test code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comments.
src/plugins/range/README.md
Outdated
## Dependencies ## | ||
|
||
None. | ||
|
||
## Examples ## | ||
|
||
None. | ||
```sh | ||
# Backup-and-Restore:/examples/range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure to add the test in tests/shell/shell_recorder/tutorial_wrapper/CMakeLists.txt
or, (even better) let us automatically include all plugins README.md to be checked with the shell recorder!
src/plugins/range/README.md
Outdated
You can use `scripts/copy-range` | ||
to automatically rename everything to your | ||
plugin name: | ||
The plugin checks every Key in the Keyset for the Metakey `check/range` which contains either a single range with the syntax `[-]min-[-]max`, or a list of ranges separated by `,` and tests if the Key value is within the range(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are spaces allowed? Please do not make lines too long.
7084487
to
71fabb9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, nicely done! Please rebase and refactor a bit.
doc/METADATA.ini
Outdated
[check/range/type] | ||
status= implemented | ||
usedby/plugin= range | ||
description= type of range (INT, FLOAT, HEX or CHAR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use check/type
and type
instead?
src/error/specification
Outdated
@@ -1033,3 +1033,17 @@ severity:error | |||
ingroup:plugin | |||
module:date | |||
macro:D_T_FMT | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs rebase
src/plugins/README.md
Outdated
@@ -202,6 +202,7 @@ copied by another plugin just before): | |||
- [conditionals](conditionals/) by using if-then-else like statements | |||
- [required](required/) rejects non-required keys | |||
- [date](date/) validates date and time data | |||
- [range](range/) checks if a value is within a specific range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specific -> given
src/plugins/range/README.md
Outdated
|
||
## Usage ## | ||
|
||
The plugin checks every Key in the Keyset for the Metakey `check/range` which contains either a single range with the syntax `[-]min-[-]max`, or a list of ranges separated by `,` and tests if the Key value is within the range(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it also possible to specify 3,5,7?
src/plugins/range/README.md
Outdated
|
||
The plugin checks every Key in the Keyset for the Metakey `check/range` which contains either a single range with the syntax `[-]min-[-]max`, or a list of ranges separated by `,` and tests if the Key value is within the range(s). | ||
|
||
`check/range/type` can be used to specify the datatype. If not specified otherwise the default value is `INT` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use type
/check/type
here, otherwise this is a unnecessary pitfall.
(For hex we need an extra meta data, see discussion #1388)
Internally, you can use INT
,.. but please not in the user interface.
src/plugins/range/README.md
Outdated
|
||
# should succeed | ||
kdb set /examples/range/value 5 | ||
kdb setmeta user/examples/range/value check/range "1-10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why here a namespace but not at other places? Why not writing it to spec?
src/plugins/range/range.c
Outdated
typedef struct | ||
{ | ||
RangeType type; | ||
union _Value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names starting with _
are reserved.
src/plugins/range/range.c
Outdated
|
||
static int rangeStringToRange (const char * rangeString, RangeValue * min, RangeValue * max, RangeType type) | ||
{ | ||
int factorA = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is factorA and B? Please comment!
src/plugins/range/range.c
Outdated
max.type = type; | ||
int rc = rangeStringToRange (rangeString, &min, &max, type); | ||
/* | ||
switch (type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions are getting too long
move to (commented out) helper function.
src/plugins/range/range.c
Outdated
long long int tmpIB = factorB * b.Value.i; | ||
long double tmpFA = factorA * a.Value.f; | ||
long double tmpFB = factorB * b.Value.f; | ||
switch (type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really long function...
Thank you, great job! For HEX we another decision is pending.. |
Purpose
range plugin preview
Checklist