Main  /  Edit version 4  /  Edit version 5  /   /  Users Area

Difference "Migrating to CppCMS 1.x.x." ver. 4 versus ver. 5

Content:

## Introduction
In this article we would describe the process of migration of the code-base to new CppCMS version. How to do it in painless way? What should you care of and so on.
## Why to migrate?
Many reasons:
- CppCMS 1.x.x release expects much longer life-time support, providing binary backward compatibility.
- Localization in CppCMS make significant step forward, including decent support based on ICU library.
- New version provides support of Comet applications and event driven programming support.
- Simplifies development providing internal HTTP server.
- Provides full Win32 support.
- Provides great range of supported compilers: Gnu Compilers Collection, Microsoft Visual C++ 2008, Intel Compiler and Sun Studio 12.
- It removes dependencies on low quality CgiCC library that makes CppCMS interfaces inconsistent and removes dependency on specific Boost version.
## How to migrate?
_TODO_
### Templates
Namespaces or now called skins. So change
<% namespace view %>
<% end namespace %>
to something like
<% skin my_skin %>
<% end skin %>
Classes are now called views. So change
<% class master uses data::message %>
<% end class %>
to something like
<% view master uses content::message %>
<% end view %>
To output content, the syntax now changed from
<% foo %>
to
<%= foo %>
### Includes
The data (content) holder now needs to be changed to include
#include <cppcms/view.h>
instead of
#include <cppcms/base_view.h>
The applications now have as constructor
my_app (cppcms::service &srv);
instead of
my_app (cppcms::worker_thread &worker);
You need to include:
#include <cppcms/applications_pool.h>
#include <cppcms/service.h>
#include <cppcms/http_response.h>
instead of the cgicc headers:
#include <cgicc/HTTPHeader.h>
#include <cgicc/HTTPStatusHeader.h>
### Configuration
To access configuration you now use:
settings().get("").
instead of:
app.config.sval("")
Unfortunately settings() is not const, so you need to unconst your methods or use an ugly const_cast like:
cppcms::json::value config =
const_cast<my_app*>(this)->settings();
### URL Remapping
TODO not finished..
To bind urls to a method, you now include:
#include <cppcms/url_dispatcher.h>
#include <cppcms/url_mapper.h>
and then you can use (untested):
dispatcher().assign("/(.*)",&hello::execute,this,1);
mapper().assign("/{1}");
instead of
url.add("^/?(.*?)/?$", boost::bind(&hello::execute, this, _1));
use_template("view");
is no longer needed?

About

CppCMS is a web development framework for performance demanding applications.

Support This Project

SourceForge.net Logo

Поддержать проект

CppCMS needs You


Navigation

Main Page


Valid CSS | Valid XHTML 1.0