Modify

Ticket #3264 (closed Feature Requests: fixed)

Opened 5 years ago

Last modified 4 years ago

open config file

Reported by: Diederick C. Niehorster <dcnieho@…> Owned by: s_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.

Attachments

Change History

comment:1 Changed 5 years ago by Diederick C. Niehorster <dcnieho@…>

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.

comment:2 Changed 4 years ago by s.ochsenknecht@…

  • Cc s.ochsenknecht@… 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 Changed 4 years ago by s_ochsenknecht

  • Owner changed from vladimir_prus to s_ochsenknecht
  • Status changed from new to assigned
  • Milestone changed from Boost 1.40.0 to Boost 1.42.0

Implemented option (2). The template parameter is mandatory (char or wchar_t). Default template parameter are not allowed for functions.

Cheers, SAscha

comment:4 Changed 4 years ago by s_ochsenknecht

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [58248]) Allow passing file name to parse_config_file(), Fixes #3264

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.