Boost logo

Boost Users :

From: Konstantin (the_pleiades_at_[hidden])
Date: 2006-09-20 16:38:00


Hi!
Try to umderstand boost and... have got a trable. What are wrong?

// no boost:

void CommandLineParser::Parse(void)
{
wostringstream wostr;
m_szArglist = CommandLineToArgvW(GetCommandLineW(), &m_nArgs);
if( NULL == m_szArglist )
{
wostr << L"CommandLineToArgvW failed" << ends;
m_objErrFileWriter->PutLineIntoLogFile(wostr.str());
return ;
}
else
wostr << endl ;
for( int i=0; i < m_nArgs; ++i)
{
wostr << L"Command line parameter " << i << " is " << m_szArglist[i] << endl
;
}
wostr << ends ;
m_objLogFileWriter->PutLineIntoLogFile( wostr.str());

// OK.
//in file
//Command line parameter 0 is C:\UPL\projects\vc\game\ufo_pl.exe
//Command line parameter 1 is --help
}

// with boost:

BOOL CommandLineParser::Parse(BOOL boost)
{
//vector<string> args = po::split_winmain(GetCommandLineW()); // not for
wstring
//vector<string> args = po::split_winmain(lpCmdLine); // not get file name
and path

vector<wstring> args = po::split_winmain(GetCommandLineW());

try {

// po::options_description desc(L"Allowed options"); // not work whith
wstring
po::options_description desc("Allowed options");

desc.add_options()
// (L"help", L"produce help message") // not work
("help", "produce help message");

po::variables_map vm;
po::store(po::wcommand_line_parser(args).options(desc).run(), vm);
po::notify(vm);
if (vm.count("help")) // do not catch a "help" ????????????

{
 // not work
//wostringstream wosstr;
//wosstr << desc << endl;
//MessageBoxW(NULL, wosstr.str().c_str(), L"Allowed options", MB_OK);

ostringstream ostrem;
ostrem << desc << endl;
MessageBoxA(NULL, ostrem.str().c_str(), "Allowed options", MB_OK);
return FALSE;
}
}
catch(exception& e) {
wcerr << "error: " << e.what() << "\n";
return TRUE;
}
catch(...) {
wcerr << "Exception of unknown type!\n";
}
return TRUE;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net