Unicode option in program_options
Here is the problematic part:
namespace po = boost::program_options;
po::options_description common_options("common options");
common_options.add_options()
("help", po::bool_switch(&helpflag), "produce help message")
("dir",
po::valuestd::wstring()->notifier(&datadir_set),
"the directory")
;
I get a huge speil of error output, concluding with
see reference to class template instantiation 'boost::program_options::typed_value
Le 12/08/2010 23:35, John Dlugosz a écrit :
see reference to class template instantiation 'boost::program_options::typed_value
' being compiled with [ T=std::wstring, charT=char ]
You should consider po::wvalue<> template function. -- Mickaël Wolff aka Lupus Michaelis Racine http://lupusmic.org Blog http://blog.lupusmic.org
see reference to class template instantiation 'boost::program_options::typed_value
' being compiled with [ T=std::wstring, charT=char ] You should consider po::wvalue<> template function.
Thanks Mickaël, that is better. So, why does po::value<T> work for whatever type I want my parameter to be _except_ for wstring, which needs to use po::wvalue<T> instead? ("datadir", po::wvaluestd::wstring()->default_value(std::wstring(L"."),"."), "the directory") Now getting default_value to work with that was some trial and error. It didn't take L".", which is exactly what parse_command_line is going to be finding were it not the default. I would expect a token in either wide or narrow forms to work, and give the same results as those tokens would if found in the argv array. Instead, each gives different errors. I have to use the two-arg form, which I believe is a pass-through value which won't be digested and parsed but simply assigned, and a display value to use in printing help. Can someone explain things better? Maybe I can edit the docs or improve the tutorial, once I understand it myself. --John TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
John Dlugosz wrote:
see reference to class template instantiation 'boost::program_options::typed_value
' being compiled with [ T=std::wstring, charT=char ] You should consider po::wvalue<> template function.
Thanks Mickaël, that is better.
So, why does po::value<T> work for whatever type I want my parameter to be
Not really -- it works for whatever type you can extract out of stringstream, not whatever type.
_except_ for wstring,
and wstring cannot be extracted from stringstream.
which needs to use po::wvalue<T> instead?
("datadir", po::wvaluestd::wstring()->default_value(std::wstring(L"."),"."), "the directory")
Now getting default_value to work with that was some trial and error. It didn't take L".", which is exactly what parse_command_line is going to be finding were it not the default. I would expect a token in either wide or narrow forms to work, and give the same results as those tokens would if found in the argv array.
default_value is another victim of the fact that wstring cannot be converted to string. I am not sure much can be done on program_options side. - Volodya
participants (3)
-
John Dlugosz
-
Mickael Wolff
-
Vladimir Prus