views:

455

answers:

4

Hello.

Hoping that anybody here knows about a good one: I'm looking for a (free to use) C++ library with a class hierarchy and methods resembling the Java API, with at least the I/O & networking part if it, specifically HTTP handling.

I work mainly with C & Java, but for this particular project C++ is recommended, so I thought of adopting a good set of C++ libraries without facing a steep learning curve.

Thanks in advance for any recommendation.

+3  A: 

Have you looked at the Boost libraries?

  • Boost.IOStreams provides a framework for defining streams, stream buffers and i/o filters.
  • Asio - Portable networking, including sockets, timers, hostname resolution and socket iostreams.
  • Many others....

The Boost libraries provide similar capabilities as compared to the Java API, but they very much 'look and feel' - appropriately - like a C++ library.

Brandon E Taylor
Thanks. I checked Boost:Asio, but it handles up to TCP, meaning that if I need to handle HTTP with sessions/cookies and stuff I will have to implement it myself. I wonder if is there any new proposal exclusively for HTTP in the works...
Rafael
The cpp-netlib project - http://sourceforge.net/projects/cpp-netlib - is working on HTTP client support for inclusion in Boost.
Brandon E Taylor
A: 

A C++ library that looked like a Java one would be a bad library, IMHO. The two languages are so very different that what is good design for one will almost inevitably be bad design for the other.

anon
A C++ library that has the same interfaces as a java library wouldn't be a bad design imo. .NET was able to provide the same interfaces for quite a few very different languages and it's C++ libraries are pretty good.
Charles Ma
+2  A: 

Qt is IMHO very java like. I.e. they prefer Java-Style Iterators over the STL ones. Qt includes networking (examples) and much other stuff (like scripting via javascript)

Maik Beckmann
QT. I'm tempted, but going GPL is out of question, that is, it will be rejected by management.
Rafael
Its LGPL as off version 4.5
Maik Beckmann
+1  A: 

There is also the option of using something like POCO, which is slightly simpler than using something like Boost, while still being cross platform.

While the only time I used HTTP in Java was a long time ago, the interface for the POCO library looks fairly simple to use. It gives a example of basic FTP usage a something like this:

Poco::Net::FTPStreamFactory::registerFactory();
std::ofstream localFile(inputFile, std::ios_base::out | std::ios_base::binary);
Poco::URI uri(inputURL);
std::auto_ptr<std::istream> ptrFtpStream(Poco::Net::URIStreamOpener::defaultOpener().open(uri));
Poco::StreamCopier::copyStream(*ptrFtpStream.get(), localFile);
Yacoby
I was checking it before, but I would like to have more feedback from the people here. Thanks.
Rafael
@Rafael, Poco is a great library that builds upon the stl, follows all the C++ idioms, and yet appears to be Java-like. So I think it's a great choice for you.
StackedCrooked