POCO POCO is an open-source third-party library, which contains a collection of C++ class libraries that simplify and accelerate the development of network-centric, portable applications in C++. With POCO you can develop network- and internet-based applications that run on desktop, server, mobile and embedded systems.
POCO C++ libraries available at biicode are:
- Poco (develop) at fenix/poco (develop).
- Poco v1.6.0 at fenix/poco (v1.6.0).
- Poco v1.5.4 at fenix/poco (v1.5.4).
- Poco v1.4.7p1 at fenix/poco (v1.4.7p1).
There are so many things you can try with POCO. This example shows a PDF conversion example from strings.
This example is already in biicode. So just open the block:
$ bii init pocoproject
$ cd pocoproject
$ bii open examples/poco_pdf
On Windows, configure Visual Studio.
$ bii configure -G "Visual Studio 12"
Choose your PDF output name, the font and size, the page of the document, the content of the string and the margins from the pdf page you want to generate:
pdf.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include "Poco/PDF/Document.h"
#include "Poco/Path.h"
#include "Poco/File.h"
const std::string fileName = "Text.pdf";
using Poco::PDF::Document;
using Poco::PDF::Font;
using Poco::PDF::Page;
using Poco::Path;
using Poco::File;
using namespace std;
int main(int argc, char** argv)
{
File file(Path::expand(fileName));
if (file.exists()) file.remove();
Document document(file.path());
Font helv = document.font("Helvetica");
Page page = document[0];
page.setFont(helv, 24);
std::string mystring = "PDF generated using POCO C++ Libraries";
float tw = page.textWidth(mystring);
page.writeOnce((page.getWidth() - tw) / 2, page.getHeight() - 50, mystring);
document.save();
cout<<fileName<<" saved correctly"<<endl;
return 0;
}
|
Note that the original [includes]
are mapped in the biicode.conf file of the block.
# Biicode configuration file
[requirements]
fenix/poco(develop): 0
[includes]
Poco/PDF/*.h: fenix/poco/PDF/include
Poco/*.h: fenix/poco/Foundation/include
Now execute bii build to build the project.
$ bii build
Go to bin directory and execute:
$ cd bin
$./examples_poco_pdf_pdf
Text.pdf saved correctly
Your pdf file is ready! Look for it in your /bin folder.
Making a project using NetSSL_OpenSSL and NetSSL_Win libraries is a special use case of original includes. Both libraries have the same relative include headers, so, the only way to resolve successfully your dependencies is writing the full path for them.
For example:
#include "Poco/URIStreamOpener.h"
#include "Poco/StreamCopier.h"
#include "Poco/Path.h"
#include "Poco/URI.h"
#include "Poco/SharedPtr.h"
#include "Poco/Exception.h"
/* headers in Net library */
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/FTPStreamFactory.h"
/* headers in NetSSL_OpenSSL library */
#include "fenix/poco/NetSSL_OpenSSL/include/Poco/Net/HTTPSStreamFactory.h"
//Instead of #include "Poco/Net/HTTPStreamFactory.h" again.
#include "fenix/poco/NetSSL_OpenSSL/include/Poco/Net/SSLManager.h"
//Instead of #include "Poco/Net/SSLManager.h"
#include "fenix/poco/NetSSL_OpenSSL/include/Poco/Net/KeyConsoleHandler.h"
//Instead of #include "Poco/Net/KeyConsoleHandler.h"
#include "fenix/poco/NetSSL_OpenSSL/include/Poco/Net/ConsoleCertificateHandler.h"
//Instead of #include "Poco/Net/ConsoleCertificateHandler.h"
#include <memory>
#include <iostream>
/* Main code */
The biicode.conf would be:
[includes]
Poco/Net/*.h: fenix/poco/Net/include
Poco/*.h: fenix/poco/Foundation/include
Poco/*.h: fenix/poco/Foundation/include
because it should always be at the end of [includes]
section for being a really wide search pattern.Got any doubts? Do not hesitate to contact us, visit our forum and feel free to ask any questions.