Skip to content

add transformer and checkedTransformer #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 2, 2019

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Feb 24, 2019

This is the last of the PR's originating from #229.
This builds on the IsMember function and adds Transformer and CheckedTransformer validators

Modifications include disabling the IsMember validator from using the second element of a map, so maps with non-convertible types can be used. IsMember will modify the input to match an element of the set.

Validators added through the transform function are inserted at the beginning of the validators list, this allows transformations to occur before a check regardless of the order added.

Some tweaks and updates to the IsMember function to clean up some loops and remove some unnecessary processing from inside the loop.

@phlptp
Copy link
Collaborator Author

phlptp commented Feb 24, 2019

TODO yet:

  • A few additional tests
  • ReadMe and documentation update
  • fix the help printing with multiple Validators
  • some more refactoring and extracting functions

@henryiii
Copy link
Collaborator

Having three copies of nearly identical code bothers me, three times the maintenance and extra compile cost. Is there a way to combine and/or share bits? Having a way to "uncheck" a Validator would be useful (causing failures to be ignored). I don't think there's a good operator for it, but a method could be used maybe?

@phlptp
Copy link
Collaborator Author

phlptp commented Feb 24, 2019

I was going to take a look at the code duplication once I got it working completely with all the tests. I am pretty sure there are some things that can be done.

@codecov
Copy link

codecov bot commented Feb 25, 2019

Codecov Report

Merging #239 into master will decrease coverage by 0.48%.
The diff coverage is 89.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #239      +/-   ##
==========================================
- Coverage     100%   99.51%   -0.49%     
==========================================
  Files          12       12              
  Lines        2212     2291      +79     
==========================================
+ Hits         2212     2280      +68     
- Misses          0       11      +11
Impacted Files Coverage Δ
include/CLI/StringTools.hpp 100% <100%> (ø) ⬆️
include/CLI/Option.hpp 100% <100%> (ø) ⬆️
include/CLI/TypeTools.hpp 100% <100%> (ø) ⬆️
include/CLI/Validators.hpp 95.75% <87.35%> (-4.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed5cd89...b180752. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 25, 2019

Codecov Report

Merging #239 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #239    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files          12     12            
  Lines        2402   2547   +145     
======================================
+ Hits         2402   2547   +145
Impacted Files Coverage Δ
include/CLI/Validators.hpp 100% <100%> (ø) ⬆️
include/CLI/Option.hpp 100% <100%> (ø) ⬆️
include/CLI/StringTools.hpp 100% <100%> (ø) ⬆️
include/CLI/TypeTools.hpp 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0631189...7242a61. Read the comment docs.

@phlptp
Copy link
Collaborator Author

phlptp commented Feb 25, 2019

I tried extracting out a search function, I think It is working now. I need to run through them some more to make sure they are actually working like I expect. Also tried to remove some of the copying that was going on with the smart_deref and pair_adaptor. Someone should really make sure those templates actually do what they are supposed to do. This deep of template nesting is not something I do everyday. An interesting exercise though.

@phlptp phlptp force-pushed the transform_validators branch from e788f22 to d9425c3 Compare February 27, 2019 17:54
@henryiii henryiii mentioned this pull request Feb 28, 2019
5 tasks
@henryiii henryiii added this to the v1.8 milestone Feb 28, 2019
@phlptp phlptp force-pushed the transform_validators branch 2 times, most recently from f6f4870 to df80011 Compare March 1, 2019 01:42
phlptp and others added 4 commits March 1, 2019 11:01
add Transformer and CheckedTransformer validators
add tests

Make Validators a full Object and remove friend,  move to descriptions instead of overriding type name.

update validators to actually merge the type strings and use all validators in the type outputs

rework join so it works without the start variable,  allow some forwarding references in the validator types, some tests for non-copyable maps, and transforms

merge the search function and enable use of member search function,  make the pair adapters forwarding instead of copying
fix some gcc 4.7 issues and add a few more test cases and more parts of the README

Work on ReadMe and add Bound validator to clamp values
@phlptp phlptp force-pushed the transform_validators branch from 594c7bd to 95109ab Compare March 1, 2019 21:46
@henryiii henryiii merged commit e9934e0 into CLIUtils:master Mar 2, 2019
@phlptp phlptp deleted the transform_validators branch March 2, 2019 13:46
@phlptp phlptp mentioned this pull request Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants