Feature #3987
closednfdc: origin argument accepts string
100%
Description
In nfdc command parser, accept strings in addition to numbers for origin field.
Accepted strings should be consistent with ndn::nfd::RouteOrigin
type.
Updated by Junxiao Shi over 7 years ago
- Status changed from New to In Progress
- Assignee set to Junxiao Shi
- % Done changed from 0 to 40
https://gerrit.named-data.net/3816 operator>>(std::istream&, RouteOrigin&)
Updated by Junxiao Shi over 7 years ago
it doesn't seem something general enough to warrant a library implementation. As a matter of fact, FacePersistency is parsed in nfdc itself. Why is RouteOrigin different than FacePersistency?
nfdc only accepts 'persistent' and 'permanent' but not 'on-demand', so a general stream extraction operator of FacePersistency would not be useful. Also, it's unlikely for a new FacePersistency to be added.
nfdc can accept any RouteOrigin value, so it can use the stream extraction operator. Also, when a new RouteOrigin is introduced, only ndn-cxx needs to be changed.
Updated by Davide Pesavento over 7 years ago
nfdc only accepts 'persistent' and 'permanent' but not 'on-demand', so a general stream extraction operator of FacePersistency would not be useful. Also, it's unlikely for a new FacePersistency to be added.
Neither of these justifications are particularly convincing. In particular, nfdc
could use a generic library-provided parsing function and then reject the "on-demand" value.
My point about not being "general enough" though was referred to the API itself. Why providing operator>>
instead of e.g. a "fromString" kind of function?
Updated by Junxiao Shi over 7 years ago
Why providing
operator>>
instead of e.g. a "fromString" kind of function?
What's the benefit?
Updated by Davide Pesavento over 7 years ago
Junxiao Shi wrote:
Why providing
operator>>
instead of e.g. a "fromString" kind of function?What's the benefit?
I don't know. It's more likely that an app has the data to be parsed in a string rather than an istream
. But anyway, that's beside the point. I'm just saying that I'm not sure if an operator>>
API would be general enough. You already made several choices in that API: accepting an istream
, case-insensitive matching, leading/trailing whitespace handling, ...
Updated by Junxiao Shi over 7 years ago
- Status changed from In Progress to Code review
- % Done changed from 40 to 100
https://gerrit.named-data.net/3836 changes both input and output of RouteOrigin
field to use strings.
Updated by Junxiao Shi over 7 years ago
- Status changed from Code review to Closed