last changes from bloomberg.

This commit is contained in:
Vahagn Khachatryan
2021-03-25 08:15:36 -04:00
parent 1a17b9fe6c
commit 721e183dc9
20 changed files with 1391 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
/* Check cf5-opt.vim defs.
-VIM-: let g:lcppflags="-std=c++11 -O2 -pthread"
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
VIM: let g:argv=""
*/
#include <iostream>
#include <sstream>
#include <exception>
void test( const std::string& str_to_parse )
{
std::stringstream ss(str_to_parse);
std::string str;
int v;
ss >> str >> v;
std::cout << "str=\"" << str_to_parse << '"' <<std::endl
<< "good()=" << ss.good()
<< " fail()=" << ss.fail()
<< " bad()=" << ss.bad()
<< " eof()=" << ss.eof()
<< std::endl << std::endl;
}
void test2( const std::string& str_to_parse )
{
std::stringstream ss(str_to_parse);
std::string str;
std::string str2;
int v;
ss >> str >> v;
if ( ss.fail() && !ss.eof() )
{
ss.clear();
ss >> str2;
}
std::cout << "str=\"" << str_to_parse << '"' <<std::endl
<< "str2=\"" << str2 << '"' <<std::endl
<< "good()=" << ss.good()
<< " fail()=" << ss.fail()
<< " bad()=" << ss.bad()
<< " eof()=" << ss.eof()
<< std::endl << std::endl;
}
int main ( void )
{try{
test("string 1234");
test("string 1234 ");
test("string 1234 12");
test("string ");
test("string");
test("string aaaa");
test("string aaaa ");
test2("sss tttt");
test2("sss tttt ");
test2("sss 3456tttt");
test2("sss");
test2("sss ");
return 0;
}
catch ( const std::exception& e )
{
std::cerr << std::endl
<< "std::exception(\"" << e.what() << "\")." << std::endl;
return 2;
}
catch ( ... )
{
std::cerr << std::endl
<< "unknown exception." << std::endl;
return 1;
}}