Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/daniele77/cli
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele77 committed Jun 29, 2023
2 parents a0ed100 + 429ecc8 commit a39d6c1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ namespace cli
Menu* current;
std::unique_ptr<Menu> globalScopeMenu;
std::ostream& out;
std::function< void(std::ostream&)> enterAction = []( std::ostream& ){};
std::function< void(std::ostream&)> exitAction = []( std::ostream& ){};
std::function< void(std::ostream&)> enterAction = []( std::ostream& ) noexcept {};
std::function< void(std::ostream&)> exitAction = []( std::ostream& ) noexcept {};
detail::History history;
bool exit{ false }; // to prevent the prompt after exit command
};
Expand Down
2 changes: 1 addition & 1 deletion include/cli/clifilesession.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CliFileSession : public CliSession
if (!_in.good()) throw std::invalid_argument("istream invalid");
if (!_out.good()) throw std::invalid_argument("ostream invalid");
ExitAction(
[this](std::ostream&)
[this](std::ostream&) noexcept
{
exit = true;
}
Expand Down
10 changes: 4 additions & 6 deletions include/cli/detail/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,12 @@ class Server
Server& operator = ( const Server& ) = delete;

Server(typename ASIOLIB::ContextType& ios, unsigned short port) :
acceptor(ios, asiolib::ip::tcp::endpoint(asiolib::ip::tcp::v4(), port)),
socket(ios)
acceptor(ios, asiolib::ip::tcp::endpoint(asiolib::ip::tcp::v4(), port))
{
Accept();
}
Server(typename ASIOLIB::ContextType& ios, std::string address, unsigned short port) :
acceptor(ios, asiolib::ip::tcp::endpoint(ASIOLIB::IpAddressFromString(address), port)),
socket(ios)
acceptor(ios, asiolib::ip::tcp::endpoint(ASIOLIB::IpAddressFromString(address), port))
{
Accept();
}
Expand All @@ -142,16 +140,16 @@ class Server
private:
void Accept()
{
acceptor.async_accept(socket, [this](asiolibec::error_code ec)
acceptor.async_accept([this](asiolibec::error_code ec, asiolib::ip::tcp::socket socket)
{
if (!ec) CreateSession(std::move(socket))->Start();
Accept();
});
}
asiolib::ip::tcp::acceptor acceptor;
asiolib::ip::tcp::socket socket;
};


} // namespace detail
} // namespace cli

Expand Down
4 changes: 2 additions & 2 deletions test/scheduler_test_templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void SchedulingTest()
{
S scheduler;
bool done = false;
scheduler.Post( [&done](){ done = true; } );
scheduler.Post( [&done]() noexcept { done = true; } );
scheduler.ExecOne();
BOOST_CHECK(done);
}
Expand All @@ -56,7 +56,7 @@ void SameThreadTest()
{
postThreadId = this_thread::get_id();
scheduler.Post(
[&runThreadId]()
[&runThreadId]() noexcept
{
runThreadId = this_thread::get_id();
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_boostasioscheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(BoostAsioNonOwner)
detail::BoostAsioLib::ContextType ioc;
BoostAsioScheduler scheduler(ioc);
bool done = false;
scheduler.Post( [&done](){ done = true; } );
scheduler.Post( [&done]() noexcept { done = true; } );
ioc.run_one();
BOOST_CHECK(done);
}
Expand Down
6 changes: 3 additions & 3 deletions test/test_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(EnterActions)
bool enterActionDone = false;

cli.EnterAction(
[&enterActionDone](std::ostream &) { enterActionDone = true; });
[&enterActionDone](std::ostream &) noexcept { enterActionDone = true; });

stringstream oss;

Expand All @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(ExitActions)

Cli cli(move(rootMenu));
bool exitActionDone = false;
cli.ExitAction([&](std::ostream&){ exitActionDone=true; });
cli.ExitAction([&](std::ostream&) noexcept { exitActionDone=true; });

stringstream oss;

Expand All @@ -425,7 +425,7 @@ BOOST_AUTO_TEST_CASE(Exceptions)

// std exception type, custom handler
bool excActionDone = false;
cli.StdExceptionHandler( [&](std::ostream&, const std::string&, const std::exception&){ excActionDone = true; } );
cli.StdExceptionHandler( [&](std::ostream&, const std::string&, const std::exception&) noexcept { excActionDone = true; } );
BOOST_CHECK_NO_THROW( UserInput(cli, oss, "stdexception") );
BOOST_CHECK(excActionDone);

Expand Down
2 changes: 1 addition & 1 deletion test/test_standaloneasioscheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(StandaloneAsioNonOwner)
detail::StandaloneAsioLib::ContextType ioc;
StandaloneAsioScheduler scheduler(ioc);
bool done = false;
scheduler.Post( [&done](){ done = true; } );
scheduler.Post( [&done]() noexcept { done = true; } );
ioc.run_one();
BOOST_CHECK(done);
}
Expand Down

0 comments on commit a39d6c1

Please sign in to comment.