database access within wt applications

wt rocks…:).

It has the standalone http server engine, it has also fcgi implementation.

It’s value would probably be significantly increased if some generic database access would be provided (some crazily fancy templates, or polymorfic DAO classes, that could be inelligently connected to widgets. (Yes, the way microsoft does with ocx controls). Another obvious requirement would be to support differet database backends. 

There are some libraries out there, everyone with pluses and minuses. Myself I was spending some time to understand what would fit the best. After studying these libraries I found that on boost’s mailinglist there was already a discussion about the topic. I will write my conclusions soon, but I wanted to ask the wt commmunity what each one uses, and if it would make sense to invent a something and eventually integrate into wt.

the following libraries can be found on internet:

So, can we use or learn something from these libraries?

 

makefile for boost

boost is a wonderfull library, but bjam sucks! The documentation of the config files is ambiguous. I spent few hours to find out how to capture the command lines during build (without hack), and how to influence cxxflags. Did not work. On the other annoying part of bjam is that parallel build does not work either. So I packed together a makefile. This is version 0.0.0.0.1, I will add later several other variables (CXXFLAGS, VERSION, LDFLAGS etc.)… At the moment there are 2 control variables, and they are the source directory and the build directory.

 

BOOST_SRCDIR=/data/build/boost/boost
BOOST_BUILDDIR=/data/build/boost/boostbuild
BOOST_INCLUDEDIR=$(BOOST_SRCDIR)

 

SYSTEM_SOURCEDIR=$(BOOST_SRCDIR)/libs/system/src
SYSTEM_OBJECT_NAMES=error_code.o
SYSTEM_BUILDDIR=$(BOOST_BUILDDIR)/system
SYSTEM_OBJECTS=$(patsubst %.o,$(SYSTEM_BUILDDIR)/%.o, $(SYSTEM_OBJECT_NAMES))
SYSTEM_LIBNAME=system.so
SYSTEM_LIB=$(SYSTEM_BUILDDIR)/$(SYSTEM_LIBNAME)

$(SYSTEM_LIB): $(SYSTEM_BUILDDIR) $(SYSTEM_OBJECTS)
 gcc $(SYSTEM_OBJECTS) -shared  -o $@

$(SYSTEM_BUILDDIR):
 mkdir $(SYSTEM_BUILDDIR)
 
$(SYSTEM_OBJECTS): $(SYSTEM_BUILDDIR)/%.o: $(SYSTEM_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

FILESYSTEM_SOURCEDIR=$(BOOST_SRCDIR)/libs/filesystem/src
FILESYSTEM_OBJECT_NAMES= operations.o \
         path.o \
         portability.o \
         utf8_codecvt_facet.o
FILESYSTEM_BUILDDIR=$(BOOST_BUILDDIR)/filesystem
FILESYSTEM_OBJECTS=$(patsubst %.o,$(FILESYSTEM_BUILDDIR)/%.o, $(FILESYSTEM_OBJECT_NAMES))
FILESYSTEM_LIBNAME=filesystem.so
FILESYSTEM_LIB=$(FILESYSTEM_BUILDDIR)/$(FILESYSTEM_LIBNAME)

$(FILESYSTEM_LIB): $(FILESYSTEM_BUILDDIR) $(FILESYSTEM_OBJECTS)
 gcc $(FILESYSTEM_OBJECTS) -shared  -o $@

$(FILESYSTEM_BUILDDIR):
 mkdir $(FILESYSTEM_BUILDDIR)
 
$(FILESYSTEM_OBJECTS): $(FILESYSTEM_BUILDDIR)/%.o: $(FILESYSTEM_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

REGEX_SOURCEDIR=$(BOOST_SRCDIR)/libs/regex/src
REGEX_OBJECT_NAMES=cpp_regex_traits.o \
       cregex.o \
       c_regex_traits.o \
       fileiter.o \
       icu.o \
       instances.o \
       posix_api.o \
       regex.o \
       regex_debug.o \
       regex_raw_buffer.o \
       regex_traits_defaults.o \
       static_mutex.o \
       usinstances.o \
       w32_regex_traits.o \
       wc_regex_traits.o \
       wide_posix_api.o \
       winstances.o
REGEX_BUILDDIR=$(BOOST_BUILDDIR)/regex
REGEX_OBJECTS=$(patsubst %.o,$(REGEX_BUILDDIR)/%.o, $(REGEX_OBJECT_NAMES))
REGEX_LIBNAME=regex.so
REGEX_LIB=$(REGEX_BUILDDIR)/$(REGEX_LIBNAME)

$(REGEX_LIB): $(REGEX_BUILDDIR) $(REGEX_OBJECTS)
 gcc $(REGEX_OBJECTS) -shared  -o $@

$(REGEX_BUILDDIR):
 mkdir $(REGEX_BUILDDIR)
 
$(REGEX_OBJECTS): $(REGEX_BUILDDIR)/%.o: $(REGEX_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 
PROGRAM_OPTIONS_SOURCEDIR=$(BOOST_SRCDIR)/libs/program_options/src
PROGRAM_OPTIONS_OBJECT_NAMES= cmdline.o \
           config_file.o \
           convert.o \
           options_description.o \
           parsers.o \
           positional_options.o \
           utf8_codecvt_facet.o \
           value_semantic.o \
           variables_map.o \
           winmain.o
PROGRAM_OPTIONS_BUILDDIR=$(BOOST_BUILDDIR)/program_options
PROGRAM_OPTIONS_OBJECTS=$(patsubst %.o,$(PROGRAM_OPTIONS_BUILDDIR)/%.o, $(PROGRAM_OPTIONS_OBJECT_NAMES))
PROGRAM_OPTIONS_LIBNAME=program_options.so
PROGRAM_OPTIONS_LIB=$(PROGRAM_OPTIONS_BUILDDIR)/$(PROGRAM_OPTIONS_LIBNAME)

$(PROGRAM_OPTION_SLIB): $(PROGRAM_OPTIONS_BUILDDIR) $(PROGRAM_OPTIONS_OBJECTS)
 gcc $(PROGRAM_OPTIONSOBJECTS) -shared  -o $@

$(PROGRAM_OPTIONS_BUILDDIR):
 mkdir $(PROGRAM_OPTIONS_BUILDDIR)
 
$(PROGRAM_OPTIONS_OBJECTS): $(PROGRAM_OPTIONS_BUILDDIR)/%.o: $(PROGRAM_OPTIONS_SOURCEDIR)/%.cpp
 gcc -c $< -o $@ -I $(BOOST_INCLUDEDIR) -c  -fPIC -fno-stack-protector

 

LIBS=$(SYSTEM_LIB) $(FILESYSTEM_LIB) $(REGEX_LIB) $(PROGRAM_OPTIONSLIB)

all: $(LIBS)
# echo $(LIBS) $(SYSTEM_LIB) $(SYSTEM_OBJECTS) $(SYSTEM_BUILDDIR)/%.o: $(SYSTEM_SOURCEDIR)/%.cpp

database access for c++

Relational database access is a key component of most of the software applications we use, and this is particularly true for web based applications. Unfortunately as C++ lost a lot of popularity and as Java and scripting languages gained the most of the web applications field, we cannot say that there are lot of open-source C++ frameworks for web development out there. And a good framework for web development means clever sub framework/library for database access.

For one of my projects I was desperately looking for such a framework/library. For the presentation layer I will probably go for Wt, but for database I am a little confused. I will try to compare some of the libraries I found; maybe I will get some valuable feedback from the readers. By writing this it helps me to even better clarify my criteria.

The libraries I found interesting to deeper look at would be:

Relational database access is a key component of most of the software applications we use, and this is particularly true for web based applications. Unfortunately as C++ lost a lot of popularity and as Java and scripting languages gained the most of the web applications field, we cannot say that there are lot of open-source C++ frameworks for web development out there. And a good framework for web development means clever sub framework/library for database access.

For one of my projects I was desperately looking for such a framework/library. For the presentation layer I will probably go for Wt, but for database I am a little confused. I will try to compare some of the libraries I found; maybe I will get some valuable feedback from the readers. By writing this it helps me to even better clarify my criteria.

The libraries I found interesting to deeper look at would be:

… to be continued…

soci c++ on ubuntu 8.10

If you try to build soci-3.0.0 on ubuntu 8.10 you might get some annoying error. I list below the errors and their fixes:

common.h:24: error: ‘std::tm’ has not been declared

fix: add to common.h:

#include <ctime>

errors in file session.cpp:

session.cpp:134: error: ‘strtol’ is not a member of ‘std’

error: ‘INT_MAX’ was not declared in this scope

fix: add to session.cpp

#include <cstdlib>

#include <climits>

in file standard-into-type.cpp:

standard-into-type.cpp:84: error: ‘strncpy’ is not a member of ‘std’

fix:add to standard-into-type.cpp

#include <cstring>

Links related to the soci library:

  • http://soci.sourceforge.net/
  • http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Relational_Database_Access
  • http://www.ddj.com/cpp/188700800?pgno=3
  • http://erdani.org/publications/traits.html
fast web applications

Unfortunately c++ did not make it in the world of web applications. There are however experiences to fill the gap:

  • http://www.appwebserver.org/
  • http://webtoolkit.eu

The first one seems to fit better on low cpu and memory systems, however the second provides much reacher functionality.

json makes it fast…

Another ingredient for fast programs is JSON. The JSON format is a concurrent of XML and YAML. The later stays closer to JSON. I found so far two libraries for C++ that can parse and write JSON structures:

  • http://jsoncpp.sourceforge.net/
  • http://blog.beef.de/projects/tinyjson

… there are even further few listed on the homepage json.org

… There is even a query language jaql