Opened 13 years ago
Closed 13 years ago
#3264 closed Feature Requests (fixed)
open config file
Reported by: | Owned by: | Sascha Ochsenknecht | |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | program_options |
Version: | Boost 1.39.0 | Severity: | Optimization |
Keywords: | Cc: | s.ochsenknecht@… |
Description
It would be nice if it is possible to call parse_config_file(const std::basic_string<charT>&, const options_description&, bool allow_unregistered = false); also, next to parse_config_file(std::basic_istream<charT>&, const options_description&, bool allow_unregistered = false); where parse_config_file would take care of opening the file. This would allow for less boiler-plate on part of the user and optimizes the interface for parsign the config file.
Change History (4)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Cc: | added |
---|
I see one problem here. How to determine if a ifstream or a wifstream should be used? Both take (const char*) as type for the file name.
One Solution could be: We can implement a template with a basic_string<char> and basic_string<wchar_t> instantiation for the file name. So, if the file name comes with a basic_string<wchar_t> then we use wifstream, the file name has to be converted to (const char* ).
template<charT> parse_config_file(const std::basic_string<charT>&, ...);
Another solution could be: The function takes const char* parameter for file name which is directly passed to ifstream/wifstream:
template<charT> parse_config_file(const char*, ...);
But how the user can choose now between ifstream and wifstream?
comment:3 by , 13 years ago
Milestone: | Boost 1.40.0 → Boost 1.42.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Implemented option (2). The template parameter is mandatory (char or wchar_t). Default template parameter are not allowed for functions.
Cheers, SAscha
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Sorry, that needed some formatting:
It would be nice if it is possible to call
parse_config_file(const std::basic_string<charT>&, const options_description&, bool allow_unregistered = false);
also, next to
parse_config_file(std::basic_istream<charT>&, const options_description&, bool allow_unregistered = false);
where parse_config_file would take care of opening the file. This would allow for less boiler-plate on part of the user and optimizes the interface for parsign the config file.