made most examples build without exception support

This commit is contained in:
Arvid Norberg 2007-12-30 01:59:10 +00:00
parent 07d1fe84c3
commit dfd563dfbb
3 changed files with 13 additions and 3 deletions

View File

@ -53,8 +53,10 @@ int main(int argc, char* argv[])
boost::filesystem::path::default_name_check(boost::filesystem::no_check);
#endif
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
std::ifstream in(argv[1], std::ios_base::binary);
in.unsetf(std::ios_base::skipws);
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
@ -98,11 +100,13 @@ int main(int argc, char* argv[])
<< last << " ]\n";
}
#ifndef BOOST_NO_EXCEPTIONS
}
catch (std::exception& e)
{
std::cout << e.what() << "\n";
}
#endif
return 0;
}

View File

@ -85,8 +85,10 @@ int main(int argc, char* argv[])
return 1;
}
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
boost::intrusive_ptr<torrent_info> t(new torrent_info);
path full_path = complete(path(argv[3]));
ofstream out(complete(path(argv[1])), std::ios_base::binary);
@ -121,11 +123,13 @@ int main(int argc, char* argv[])
// create the torrent and print it to out
entry e = t->create_torrent();
libtorrent::bencode(std::ostream_iterator<char>(out), e);
#ifndef BOOST_NO_EXCEPTIONS
}
catch (std::exception& e)
{
std::cerr << e.what() << "\n";
}
#endif
return 0;
}

View File

@ -35,9 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <iterator>
#include <exception>
#include <boost/format.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp"
@ -57,7 +54,9 @@ int main(int argc, char* argv[])
return 1;
}
#ifndef BOOST_NO_EXCEPTIONS
try
#endif
{
session s;
s.listen_on(std::make_pair(6881, 6889));
@ -72,9 +71,12 @@ int main(int argc, char* argv[])
std::cin.unsetf(std::ios_base::skipws);
std::cin >> a;
}
#ifndef BOOST_NO_EXCEPTIONS
catch (std::exception& e)
{
std::cout << e.what() << "\n";
}
#endif
return 0;
}