acceptor.h   acceptor.h 
skipping to change at line 23 skipping to change at line 23
#include <booster/hold_ptr.h> #include <booster/hold_ptr.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
#include <booster/aio/endpoint.h> #include <booster/aio/endpoint.h>
#include <booster/aio/basic_socket.h> #include <booster/aio/basic_socket.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class io_service; class io_service;
class stream_socket; class stream_socket;
///
/// \brief this class represents a socket that accepts incoming conn
ections
///
class BOOSTER_API acceptor : public basic_socket { class BOOSTER_API acceptor : public basic_socket {
public: public:
///
/// Create a new acceptor object
///
acceptor(); acceptor();
///
/// Create a new acceptor object with assigned \ref io_servi
ce \a srv)
///
acceptor(io_service &srv); acceptor(io_service &srv);
~acceptor(); ~acceptor();
///
/// Opens a new stream socket of a \ref family_type \a d
///
/// Throws system::system_error if error occurs.
///
void open(family_type d); void open(family_type d);
///
/// Opens a new stream socket of a \ref family_type \a d
///
/// If a error occurs it is assigned to \a e.
///
void open(family_type d,system::error_code &e); void open(family_type d,system::error_code &e);
void accept(stream_socket &); ///
void accept(stream_socket &,system::error_code &e); /// Accepts a new incoming connection to the socket \a s
///
void bind(endpoint const &); /// Throws system::system_error if error occurs.
void bind(endpoint const &,system::error_code &e); ///
void accept(stream_socket &s);
///
/// Accepts a new incoming connection to the socket \a s
///
/// If a error occurs it is assigned to \a e.
///
void accept(stream_socket &s,system::error_code &e);
///
/// Bind the opended socket the \ref endpoint \a ep
///
/// Throws system::system_error if error occurs.
///
void bind(endpoint const &ep);
///
/// Bind the opended socket the \ref endpoint \a ep
///
/// If a error occurs it is assigned to \a e.
///
void bind(endpoint const &ep,system::error_code &e);
///
/// Starts listening on the socket with backlog parameter \a
backlog
///
/// Throws system::system_error if error occurs.
///
void listen(int backlog); void listen(int backlog);
///
/// Starts listening on the socket with backlog parameter \a
backlog
///
/// If a error occurs it is assigned to \a e.
///
void listen(int backlog,system::error_code &e); void listen(int backlog,system::error_code &e);
void async_accept(stream_socket &,event_handler const &h); ///
/// Accept the connection asynchronously. The reference \a s
must be valid until h is called.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_accept(stream_socket &s,event_handler const &h);
private: private:
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
}; };
} // aio } // aio
} // booster } // booster
#endif #endif
 End of changes. 9 change blocks. 
6 lines changed or deleted 66 lines changed or added


 aio_category.h   aio_category.h 
skipping to change at line 21 skipping to change at line 21
#include <booster/system_error.h> #include <booster/system_error.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
/// ///
/// \brief This namespace includes Booster.Aio specific error codes /// \brief This namespace includes Booster.Aio specific error codes
/// ///
namespace aio_error { namespace aio_error {
enum { enum {
ok, ok, ///< No error
canceled, canceled, ///< Operation was canceled
select_failed, select_failed, ///< It was impossible to pe
eof, rform select operation on the file descriptor
invalid_endpoint, eof, ///< End of file occured
no_service_provided, invalid_endpoint, ///< The provided endpoint (
prefork_not_enabled address) is not valid
no_service_provided, ///< The io_service was not
assigned
prefork_not_enabled ///< Prefork acceptor suppor
t is not enabled
}; };
///
/// Error category for booster::aio objects
///
class BOOSTER_API category : public system::error_category { class BOOSTER_API category : public system::error_category {
public: public:
/// Get category name
virtual char const *name() const; virtual char const *name() const;
/// Get message from code
virtual std::string message(int cat) const; virtual std::string message(int cat) const;
}; };
///
/// get aio category object
///
BOOSTER_API aio_error::category const &get_category(); BOOSTER_API aio_error::category const &get_category();
} }
///
/// aio category object reference
///
static aio_error::category const &aio_error_cat = aio_error::get_cat egory(); static aio_error::category const &aio_error_cat = aio_error::get_cat egory();
} }
} // booster } // booster
#endif #endif
 End of changes. 6 change blocks. 
7 lines changed or deleted 22 lines changed or added


 backtrace.h   backtrace.h 
skipping to change at line 269 skipping to change at line 268
} }
private: private:
backtrace const *tr_; backtrace const *tr_;
}; };
inline std::ostream &operator<<(std::ostream &out,details::trace_ma nip const &t) inline std::ostream &operator<<(std::ostream &out,details::trace_ma nip const &t)
{ {
return t.write(out); return t.write(out);
} }
} }
/// \endcond /// \endcond
/// ///
/// \brief manipulator that print stack trace for the exception \a e if it is derived from backtrace. /// \brief manipulator that print stack trace for the exception \a e if it is derived from backtrace.
/// ///
/// For example: /// For example:
///
/// \code /// \code
///
/// catch(std::exception const &e) { /// catch(std::exception const &e) {
/// std::cerr << e.what() << std::endl; /// std::cerr << e.what() << std::endl;
/// std::cerr << booster::trace(e); /// std::cerr << booster::trace(e);
/// } /// }
/// ///
/// \endcode
///
template<typename E> template<typename E>
details::trace_manip trace(E const &e) details::trace_manip trace(E const &e)
{ {
backtrace const *tr = dynamic_cast<backtrace const *>(&e); backtrace const *tr = dynamic_cast<backtrace const *>(&e);
return details::trace_manip(tr); return details::trace_manip(tr);
} }
} // booster } // booster
#endif #endif
 End of changes. 4 change blocks. 
1 lines changed or deleted 4 lines changed or added


 basic_io_device.h   basic_io_device.h 
skipping to change at line 21 skipping to change at line 21
#include <booster/aio/types.h> #include <booster/aio/types.h>
#include <booster/hold_ptr.h> #include <booster/hold_ptr.h>
#include <booster/callback.h> #include <booster/callback.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class io_service; class io_service;
class endpoint; class endpoint;
///
/// \brief This is a basic object that allows execution of asynchron
ous operations.
///
/// It represents a generic "select"able file descriptor or SOCKET o
n Windows platform.
///
/// It does following:
///
/// - Connects an object with the event loop - \ref io_service
/// - Allows to connect and disconnect native file descriptor/socket
object to it,
/// and close it
/// - Asynchronously poll the object for readability and writeabilit
y via \ref io_service object
/// and cancel such operations
/// - Switch blocking and non-blocking mode of the descriptor.
///
///
class BOOSTER_API basic_io_device : public noncopyable { class BOOSTER_API basic_io_device : public noncopyable {
public: public:
///
/// Create a new device not attached to event loop
///
basic_io_device(); basic_io_device();
///
/// Create a new device that is attached to the event loop \
a srv
///
basic_io_device(io_service &srv); basic_io_device(io_service &srv);
~basic_io_device(); ///
/// Destroy the object. If it owns the file descriptor or so
cket it closes it
///
virtual ~basic_io_device();
///
/// Check if the basic_io_device is connected to the io_serv
ice
///
bool has_io_service(); bool has_io_service();
///
/// Returns the connected io_service, throws system::system_
error if no \ref io_service connected
///
io_service &get_io_service(); io_service &get_io_service();
///
/// Sets new io_service. Cancels all pending asynchronous op
erations on the connected io_service.
///
void set_io_service(io_service &srv); void set_io_service(io_service &srv);
///
/// Detaches the object from io_service. Cancels all pendin
g asynchronous operations.
///
void reset_io_service(); void reset_io_service();
///
/// Attach the file descriptor \a fd to the device. The owne
rship is not transferred to the object.
///
/// If basic_io_device owns other file descriptor, it is clo
sed.
///
void attach(native_type fd); void attach(native_type fd);
///
/// Assign existing file descriptor \a fd to the device. The
ownership is transferred to the object
///
void assign(native_type fd); void assign(native_type fd);
///
/// Release the ownership on the current file descriptor. Th
e user is responsible to close it.
///
/// \note it just changes the "ownership" flag in the object
, nothing else is done
///
native_type release(); native_type release();
///
/// Get the underlying file descriptor. Returns invalid_sock
et if the file descriptor was not assigned
///
native_type native(); native_type native();
///
/// Cancels all pending asynchronous events. If the ownershi
p belongs to it closes the file descriptor.
///
/// Throws system::system_error if error occurs.
///
void close(); void close();
///
/// Cancels all pending asynchronous events. If the ownershi
p belongs to it closes the file descriptor.
///
/// If a error occurs it is assigned to \a e.
///
void close(system::error_code &e); void close(system::error_code &e);
///
/// Start asynchronous polling for readability. The result i
s reported via callback \a r.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via \a r.
///
void on_readable(event_handler const &r); void on_readable(event_handler const &r);
///
/// Start asynchronous polling for writeability. The result
is reported via callback \a r.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via \a r.
///
void on_writeable(event_handler const &r); void on_writeable(event_handler const &r);
///
/// Cancel all asynchronous operations.
///
void cancel(); void cancel();
///
/// Returns *this
///
basic_io_device &lowest_layer(); basic_io_device &lowest_layer();
///
/// Set the object to blocking or non-blocking mode.
///
/// Throws system::system_error if error occurs.
///
void set_non_blocking(bool nonblocking); void set_non_blocking(bool nonblocking);
///
/// Set the object to blocking or non-blocking mode.
///
/// If a error occurs it is assigned to \a e.
///
void set_non_blocking(bool nonblocking,system::error_code &e ); void set_non_blocking(bool nonblocking,system::error_code &e );
///
/// Check if a error code \a e reports that the non-blocking
operation would block
///
static bool would_block(system::error_code const &e); static bool would_block(system::error_code const &e);
protected: protected:
bool dont_block(event_handler const &); ///
bool dont_block(io_handler const &); /// Set non-blocking mode. If error occurs returns false and
the error is reported via callback c
///
bool dont_block(event_handler const &c);
///
/// Set non-blocking mode. If error occurs returns false and
the error is reported via callback c
///
bool dont_block(io_handler const &c);
private: private:
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
native_type fd_; native_type fd_;
bool owner_; bool owner_;
bool nonblocking_was_set_; bool nonblocking_was_set_;
io_service *srv_; io_service *srv_;
}; };
 End of changes. 22 change blocks. 
3 lines changed or deleted 125 lines changed or added


 basic_socket.h   basic_socket.h 
skipping to change at line 22 skipping to change at line 22
#include <booster/hold_ptr.h> #include <booster/hold_ptr.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
#include <booster/aio/endpoint.h> #include <booster/aio/endpoint.h>
#include <booster/aio/basic_io_device.h> #include <booster/aio/basic_io_device.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class io_service; class io_service;
///
/// \brief This class represents a basic Socket object.
///
class BOOSTER_API basic_socket : public basic_io_device { class BOOSTER_API basic_socket : public basic_io_device {
public: public:
///
/// Create a new socket object
///
basic_socket(); basic_socket();
///
/// Create a new socket object and connect to the io_service
\a srv
///
basic_socket(io_service &srv); basic_socket(io_service &srv);
~basic_socket(); ~basic_socket();
///
/// Open a socket of \ref family_type \a d and of the protoc
ol (\ref socket_type) \a t
///
/// Throws system::system_error if error occurs.
///
void open(family_type d,socket_type t); void open(family_type d,socket_type t);
///
/// Opens a new stream socket of a \ref family_type \a d
///
/// If a error occurs it is assigned to \a e.
///
void open(family_type d,socket_type t,system::error_code &e) ; void open(family_type d,socket_type t,system::error_code &e) ;
///
/// Get a local endpoint for the socket
///
/// If a error occurs it is assigned to \a e.
///
endpoint local_endpoint(system::error_code &e); endpoint local_endpoint(system::error_code &e);
///
/// Get a local endpoint for the socket
///
/// Throws system::system_error if error occurs.
///
endpoint local_endpoint(); endpoint local_endpoint();
///
/// Get a remote endpoint for the socket
///
/// If a error occurs it is assigned to \a e.
///
endpoint remote_endpoint(system::error_code &e); endpoint remote_endpoint(system::error_code &e);
///
/// Get a remote endpoint for the socket
///
/// Throws system::system_error if error occurs.
///
endpoint remote_endpoint(); endpoint remote_endpoint();
///
/// Boolean socket options list
///
typedef enum { typedef enum {
tcp_no_delay, tcp_no_delay, //< TCP_NODELAY options - disables N
keep_alive, agle's algorithm
reuse_address keep_alive, //< SO_KEEPALIVE socket option
reuse_address //< SO_REUSEADDR socket option
} boolean_option_type; } boolean_option_type;
///
/// Get a value for a boolean_option_type
///
/// If a error occurs it is assigned to \a e.
///
bool get_option(boolean_option_type opt,system::error_code & e); bool get_option(boolean_option_type opt,system::error_code & e);
///
/// Get a value for a boolean_option_type
/// Throws system::system_error if error occurs.
///
bool get_option(boolean_option_type opt); bool get_option(boolean_option_type opt);
///
/// Set a value for a boolean_option_type
///
/// If a error occurs it is assigned to \a e.
///
void set_option(boolean_option_type opt,bool v,system::error _code &e); void set_option(boolean_option_type opt,bool v,system::error _code &e);
///
/// Set a value for a boolean_option_type
///
/// Throws system::system_error if error occurs.
///
void set_option(boolean_option_type opt,bool v); void set_option(boolean_option_type opt,bool v);
private: private:
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
}; };
} // aio } // aio
} // booster } // booster
 End of changes. 15 change blocks. 
3 lines changed or deleted 67 lines changed or added


 buffer.h   buffer.h 
skipping to change at line 16 skipping to change at line 16
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_AIO_BUFFER_H #ifndef BOOSTER_AIO_BUFFER_H
#define BOOSTER_AIO_BUFFER_H #define BOOSTER_AIO_BUFFER_H
#include <vector> #include <vector>
#include <string> #include <string>
namespace booster { namespace booster {
namespace aio { namespace aio {
///
/// \brief This is a base class that represents a buffer - a
set of
/// contiguous chunks of memory that can be transfered over
network.
///
/// The \a Pointer parameter should be either <tt>char const
*</tt> or
/// <tt>char *</tt>
///
template<typename Pointer> template<typename Pointer>
class buffer_impl { class buffer_impl {
public: public:
///
/// One chunk - pointer and its size
///
struct entry { struct entry {
Pointer ptr; Pointer ptr;
size_t size; size_t size;
}; };
///
/// Create an empty buffer
///
buffer_impl() : buffer_impl() :
size_(0) size_(0)
{ {
} }
/// A pair that defined the chunk
typedef std::pair<entry const *,size_t> buffer_data_ type; typedef std::pair<entry const *,size_t> buffer_data_ type;
///
/// Get a first chunk
///
std::pair<entry const *,size_t> get() const std::pair<entry const *,size_t> get() const
{ {
if(size_ == 0) { if(size_ == 0) {
buffer_data_type bt; buffer_data_type bt;
bt.first=0; bt.first=0;
bt.second=0; bt.second=0;
return bt; return bt;
} }
else if(size_ == 1) else if(size_ == 1)
return buffer_data_type(&entry_,1); return buffer_data_type(&entry_,1);
else else
return buffer_data_type(&vec_.front( ),vec_.size()); return buffer_data_type(&vec_.front( ),vec_.size());
} }
///
/// Append a chunk to the buffer
///
void add(Pointer p,size_t s) void add(Pointer p,size_t s)
{ {
if(s==0) if(s==0)
return; return;
if(size_ == 0) { if(size_ == 0) {
entry_.ptr = p; entry_.ptr = p;
entry_.size = s; entry_.size = s;
size_ = 1; size_ = 1;
return; return;
} }
else if(size_ == 1) { else if(size_ == 1) {
vec_.push_back(entry_); vec_.push_back(entry_);
} }
entry tmp = { p,s }; entry tmp = { p,s };
vec_.push_back(tmp); vec_.push_back(tmp);
size_ = vec_.size(); size_ = vec_.size();
} }
///
/// Check if the buffer is empty
///
bool empty() const bool empty() const
{ {
return size_ == 0; return size_ == 0;
} }
private: private:
int size_; int size_;
entry entry_; entry entry_;
std::vector<entry> vec_; std::vector<entry> vec_;
}; };
///
/// \brief A mutable buffer - a buffer for read operations
///
class mutable_buffer : public buffer_impl<char *> { class mutable_buffer : public buffer_impl<char *> {
public: public:
mutable_buffer() {} mutable_buffer() {}
}; };
///
/// \brief An immutable buffer - buffer for write operations
///
class const_buffer : public buffer_impl<const char *> { class const_buffer : public buffer_impl<const char *> {
public: public:
const_buffer() {} const_buffer() {}
///
/// Create a const buffer from mutable buffer
///
const_buffer(mutable_buffer const &other) const_buffer(mutable_buffer const &other)
{ {
mutable_buffer::buffer_data_type data = othe r.get(); mutable_buffer::buffer_data_type data = othe r.get();
for(unsigned i=0;i<data.second;i++) for(unsigned i=0;i<data.second;i++)
add(data.first[i].ptr,data.first[i]. size); add(data.first[i].ptr,data.first[i]. size);
} }
}; };
///
/// Create a buffer from POD object of size \a n
///
inline const_buffer buffer(void const *p,size_t n) inline const_buffer buffer(void const *p,size_t n)
{ {
const_buffer tmp; const_buffer tmp;
tmp.add(reinterpret_cast<char const *>(p),n); tmp.add(reinterpret_cast<char const *>(p),n);
return tmp; return tmp;
} }
///
/// Create a buffer from POD object of size \a n
///
inline mutable_buffer buffer(void *p,size_t n) inline mutable_buffer buffer(void *p,size_t n)
{ {
mutable_buffer tmp; mutable_buffer tmp;
tmp.add(reinterpret_cast<char *>(p),n); tmp.add(reinterpret_cast<char *>(p),n);
return tmp; return tmp;
} }
///
/// Create a buffer from std::vector<char>
///
inline const_buffer buffer(std::vector<char> const &d) inline const_buffer buffer(std::vector<char> const &d)
{ {
return buffer(&d.front(),d.size()); return buffer(&d.front(),d.size());
} }
///
/// Create a buffer from std::vector<char>
///
inline mutable_buffer buffer(std::vector<char> &d) inline mutable_buffer buffer(std::vector<char> &d)
{ {
return buffer(&d.front(),d.size()); return buffer(&d.front(),d.size());
} }
///
/// Create a buffer from std::string
///
inline const_buffer buffer(std::string const &d) inline const_buffer buffer(std::string const &d)
{ {
return buffer(d.c_str(),d.size()); return buffer(d.c_str(),d.size());
} }
/// \cond internal
namespace details { namespace details {
template<typename Buffer> template<typename Buffer>
Buffer advance(Buffer const &buf,size_t n) Buffer advance(Buffer const &buf,size_t n)
{ {
Buffer res; Buffer res;
typename Buffer::buffer_data_type data=buf.g et(); typename Buffer::buffer_data_type data=buf.g et();
while(data.second > 0 && n > 0) { while(data.second > 0 && n > 0) {
if(data.first->size <= n) { if(data.first->size <= n) {
n-= data.first->size; n-= data.first->size;
data.second--; data.second--;
skipping to change at line 146 skipping to change at line 195
return res; return res;
} }
template<typename Buffer> template<typename Buffer>
void add(Buffer &left,Buffer const &right) void add(Buffer &left,Buffer const &right)
{ {
typename Buffer::buffer_data_type data=right .get(); typename Buffer::buffer_data_type data=right .get();
for(unsigned i=0;i<data.second;i++) for(unsigned i=0;i<data.second;i++)
left.add(data.first[i].ptr,data.firs t[i].size); left.add(data.first[i].ptr,data.firs t[i].size);
} }
} // details } // details
/// \endcond
///
/// Create a new buffer by "consuming" \a n bytes. For examp
le if the
/// buffer has 100 bytes then adding 50 to it would create a
buffer
/// with remaining 50 bytes
///
inline const_buffer operator+(const_buffer const &buf,size_t n) inline const_buffer operator+(const_buffer const &buf,size_t n)
{ {
return details::advance(buf,n); return details::advance(buf,n);
} }
///
/// Create a new buffer by "consuming" \a n bytes. For examp
le if the
/// buffer has 100 bytes then adding 50 to it would create a
buffer
/// with remaining 50 bytes
///
inline mutable_buffer operator+(mutable_buffer const &buf,si ze_t n) inline mutable_buffer operator+(mutable_buffer const &buf,si ze_t n)
{ {
return details::advance(buf,n); return details::advance(buf,n);
} }
///
/// Consume \a n bytes from the buffer.
///
inline const_buffer &operator+=(const_buffer &buf,size_t n) inline const_buffer &operator+=(const_buffer &buf,size_t n)
{ {
buf = details::advance(buf,n); buf = details::advance(buf,n);
return buf; return buf;
} }
///
/// Consume \a n bytes from the buffer.
///
inline mutable_buffer &operator+=(mutable_buffer &buf,size_t n) inline mutable_buffer &operator+=(mutable_buffer &buf,size_t n)
{ {
buf = details::advance(buf,n); buf = details::advance(buf,n);
return buf; return buf;
} }
///
/// Append two buffers
///
inline const_buffer operator+(const_buffer const &b1,const_b uffer const &b2) inline const_buffer operator+(const_buffer const &b1,const_b uffer const &b2)
{ {
const_buffer tmp=b1; const_buffer tmp=b1;
details::add(tmp,b2); details::add(tmp,b2);
return tmp; return tmp;
} }
///
/// Append one buffer to another
///
inline const_buffer &operator+=(const_buffer &b1,const_buffe r const &b2) inline const_buffer &operator+=(const_buffer &b1,const_buffe r const &b2)
{ {
details::add(b1,b2); details::add(b1,b2);
return b1; return b1;
} }
///
/// Append two buffers
///
inline mutable_buffer operator+(mutable_buffer const &b1,mut able_buffer const &b2) inline mutable_buffer operator+(mutable_buffer const &b1,mut able_buffer const &b2)
{ {
mutable_buffer tmp=b1; mutable_buffer tmp=b1;
details::add(tmp,b2); details::add(tmp,b2);
return tmp; return tmp;
} }
///
/// Append one buffer to another
///
inline mutable_buffer &operator+=(mutable_buffer &b1,mutable _buffer const &b2) inline mutable_buffer &operator+=(mutable_buffer &b1,mutable _buffer const &b2)
{ {
details::add(b1,b2); details::add(b1,b2);
return b1; return b1;
} }
} // aio } // aio
} // booster } // booster
#endif #endif
 End of changes. 24 change blocks. 
0 lines changed or deleted 87 lines changed or added


 build_config.h   build_config.h 
skipping to change at line 66 skipping to change at line 66
#define BOOSTER_HAVE_INTTYPES_H #define BOOSTER_HAVE_INTTYPES_H
// //
// Have IPv6 support // Have IPv6 support
// //
#define BOOSTER_AIO_HAVE_PF_INET6 #define BOOSTER_AIO_HAVE_PF_INET6
#define BOOSTER_HAVE_EXECINFO #define BOOSTER_HAVE_EXECINFO
/* Define to module suffix. */
#define BOOSTER_LIBRARY_SUFFIX ".so"
/* Define to module suffix. */
#define BOOSTER_LIBRARY_PREFIX "lib"
#endif #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 6 lines changed or added


 callback.h   callback.h 
skipping to change at line 43 skipping to change at line 43
}; };
#ifdef BOOSTER_DOXYGEN_DOCS #ifdef BOOSTER_DOXYGEN_DOCS
/// ///
/// \brief This is Booster's implementation of std::tr1::callback/bo oster::callback. /// \brief This is Booster's implementation of std::tr1::callback/bo oster::callback.
/// ///
/// This callback is created from generic object that can be "called " i.e. /// This callback is created from generic object that can be "called " i.e.
/// a class with operator() or callback pointer that has same signat ure as /// a class with operator() or callback pointer that has same signat ure as
/// the callback. /// the callback.
/// ///
/// See: http://www.boost.org/doc/html/callback.html /// See: http://www.boost.org/doc/html/function.html
/// ///
/// Notes: /// Notes:
/// ///
/// - this code is not taken from Boost and has slightly different i nterface. /// - this code is not taken from Boost and has slightly different i nterface.
/// - as most of compilers do not support Variadic templates yet, th is class /// - as most of compilers do not support Variadic templates yet, th is class
/// is explicitly specialized for Params of size 0 to 8. So maxima l amout /// is explicitly specialized for Params of size 0 to 8. So maxima l amout
/// of parameters that can be used is 8. /// of parameters that can be used is 8.
/// ///
/// ///
template<typename Result,typename ...Params> template<typename Result,typename ...Params>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 collator.h   collator.h 
skipping to change at line 253 skipping to change at line 253
} // locale } // locale
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
/// ///
/// \example collate.cpp /// collate.cpp
/// Example of using collation functions /// Example of using collation functions
/// ///
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 conversion.h   conversion.h 
skipping to change at line 367 skipping to change at line 367
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
/// ///
/// \example conversions.cpp /// conversions.cpp
/// ///
/// Example of using various text conversion functions. /// Example of using various text conversion functions.
/// ///
/// \example wconversions.cpp /// wconversions.cpp
/// ///
/// Example of using various text conversion functions with wide strings. /// Example of using various text conversion functions with wide strings.
/// ///
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 cppcms_error.h   cppcms_error.h 
skipping to change at line 47 skipping to change at line 47
/// Create an object with error code err (errno) and a message \a er ror /// Create an object with error code err (errno) and a message \a er ror
/// ///
cppcms_error(int err,std::string const &error); cppcms_error(int err,std::string const &error);
/// ///
/// Create an object with message \a error /// Create an object with message \a error
/// ///
cppcms_error(std::string const &error) : booster::runtime_error(erro r) {}; cppcms_error(std::string const &error) : booster::runtime_error(erro r) {};
}; };
} }
#endif /* _HTTP_ERROR_H */ #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added


 crypto.h   crypto.h 
skipping to change at line 169 skipping to change at line 169
/// ///
static std::auto_ptr<message_digest> sha1(); static std::auto_ptr<message_digest> sha1();
/// ///
/// Create message digest by name, more then sha1 an d md5 may be supported, /// Create message digest by name, more then sha1 an d md5 may be supported,
/// if CppCMS is compiled with cryptography library like libgcrypt or openssl /// if CppCMS is compiled with cryptography library like libgcrypt or openssl
/// ///
static std::auto_ptr<message_digest> create_by_name( std::string const &name); static std::auto_ptr<message_digest> create_by_name( std::string const &name);
}; };
/// ///
/// This object calculates the HMAC signature for the input data /// \brief This object calculates the HMAC signature for the input data
/// ///
class CPPCMS_API hmac : public booster::noncopyable { class CPPCMS_API hmac : public booster::noncopyable {
public: public:
/// ///
/// Create hmac that uses given \a digest algorithm and a binary key - \a key /// Create hmac that uses given \a digest algorithm and a binary key - \a key
/// ///
hmac(std::auto_ptr<message_digest> digest,key const &k); hmac(std::auto_ptr<message_digest> digest,key const &k);
/// ///
/// Create hmac that uses message digest algorithm c alled \a name and use a binary key - \a key /// Create hmac that uses message digest algorithm c alled \a name and use a binary key - \a key
/// ///
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 date_time.h   date_time.h 
skipping to change at line 1133 skipping to change at line 1133
} // locale } // locale
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
/// ///
/// \example calendar.cpp /// calendar.cpp
/// ///
/// Example of using date_time functions for generating calendar for curren t year. /// Example of using date_time functions for generating calendar for curren t year.
/// ///
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 deadline_timer.h   deadline_timer.h 
skipping to change at line 21 skipping to change at line 21
#include <booster/config.h> #include <booster/config.h>
#include <booster/posix_time.h> #include <booster/posix_time.h>
#include <booster/hold_ptr.h> #include <booster/hold_ptr.h>
#include <booster/callback.h> #include <booster/callback.h>
#include <booster/aio/types.h> #include <booster/aio/types.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
///
/// \brief A timer object
///
class BOOSTER_API deadline_timer : public noncopyable { class BOOSTER_API deadline_timer : public noncopyable {
public: public:
///
/// Create a new timer object
///
deadline_timer(); deadline_timer();
///
/// Create a new timer object connected to the \ref
io_service \a srv
///
deadline_timer(io_service &srv); deadline_timer(io_service &srv);
~deadline_timer(); ~deadline_timer();
///
/// Returns the connected io_service, throws system:
:system_error if no \ref io_service connected
///
io_service &get_io_service(); io_service &get_io_service();
///
/// Sets new io_service. Cancels all pending asynchr
onous operations on the connected io_service.
///
void set_io_service(io_service &srv); void set_io_service(io_service &srv);
///
/// Unsets the io_service. Cancels all pending async
hronous operations on the connected io_service.
///
void reset_io_service(); void reset_io_service();
///
/// Set an expiration time relativelty to the curren
t point with an offset \a t
///
/// If the function is called during the wait operat
ion the behavior is undefined
///
void expires_from_now(ptime t); void expires_from_now(ptime t);
///
/// Get an expiration time relativelty to the curren
t point with an offset \a t
///
ptime expires_from_now(); ptime expires_from_now();
///
/// Set an absolute expiration time
///
/// If the function is called during the wait operat
ion the behavior is undefined
///
void expires_at(ptime t); void expires_at(ptime t);
///
/// Get an absolute expiration time
///
ptime expires_at(); ptime expires_at();
///
/// Wait synchronously for the timer
///
void wait(); void wait();
///
/// Wait asynchronously for the timer.
///
/// If io_service is not assigned throws system::sys
tem_error, all other errors reported via \a h
///
void async_wait(event_handler const &h); void async_wait(event_handler const &h);
///
/// Cancel asynchronous operation. The active handle
r is immediately scheduled for execution
/// with booster::aio::aio_error::cancel error code
in booster::aio::aio_error_cat category.
///
/// It allows to distinguish between operation cance
llation and normal completion
///
void cancel(); void cancel();
private: private:
struct waiter; struct waiter;
friend struct waiter; friend struct waiter;
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
io_service *srv_; io_service *srv_;
ptime deadline_; ptime deadline_;
 End of changes. 13 change blocks. 
0 lines changed or deleted 61 lines changed or added


 endpoint.h   endpoint.h 
skipping to change at line 22 skipping to change at line 22
#include <booster/copy_ptr.h> #include <booster/copy_ptr.h>
#include <booster/aio/types.h> #include <booster/aio/types.h>
#include <string> #include <string>
extern "C" { extern "C" {
struct sockaddr; struct sockaddr;
}; };
namespace booster { namespace booster {
namespace aio { namespace aio {
///
/// \brief this class represents the connection endpoint, that is ge
nerally sockaddr structure
/// in Berkeley sockets API.
///
class BOOSTER_API endpoint { class BOOSTER_API endpoint {
public: public:
endpoint(); endpoint();
endpoint(endpoint const &); endpoint(endpoint const &);
endpoint const &operator = (endpoint const &); endpoint const &operator = (endpoint const &);
~endpoint(); ~endpoint();
// Inet protocols ///
/// Create a new IP endpoint using \a ip address and \a port
///
/// Throws system::system_error if the port or the address a
re invalid or not supported
///
endpoint(std::string const &ip,int port); endpoint(std::string const &ip,int port);
///
/// Set an IP address
///
/// Throws system::system_error if the address is invalid or
not supported
///
void ip(std::string const &); void ip(std::string const &);
///
/// Set a port
///
/// Throws system::system_error if the port is invalid
///
void port(int); void port(int);
///
/// Get an ip
///
/// Throws system::system_error if the endpoint is not assig
ned or does not belong to IP protocol
///
std::string ip() const; std::string ip() const;
///
/// Get a port
///
/// Throws system::system_error if the endpoint is not assig
ned or does not belong to IP protocol
///
int port() const; int port() const;
#ifndef BOOSTER_WIN32 #ifndef BOOSTER_WIN32
// Unix domain protocols ///
/// Create a Unix domain socket endpoint,
///
/// Throws system::system_error if the path is not valid Uni
x domain socket path
///
endpoint(std::string const &); endpoint(std::string const &);
///
/// Define a endpoint as a Unix domain socket endpoint
///
/// Throws system::system_error if the path is not valid Uni
x domain socket path
///
void path(std::string const &); void path(std::string const &);
///
/// Get a endpoint path.
///
/// Throws system::system_error if it is not assigned or the
endpoint is not Unix domain
/// socket endpoint
///
std::string path() const; std::string path() const;
#endif #endif
///
/// Get the endpoint family
///
/// Throws system::system_error if it is not assigned or the
endpoint family is not supported
///
family_type family() const; family_type family() const;
void raw(sockaddr const *p,int); ///
/// Set the native sockaddr structure as endpoint of size \a
size
///
void raw(sockaddr const *p,int size);
///
/// The native sockaddr structure and its size type
///
typedef std::pair<sockaddr const *,int> native_address_type; typedef std::pair<sockaddr const *,int> native_address_type;
///
/// Get the native endpoint data structure
///
native_address_type raw() const; native_address_type raw() const;
private: private:
void throw_invalid() const; void throw_invalid() const;
struct data; struct data;
copy_ptr<data> d; copy_ptr<data> d;
}; };
} // aio } // aio
} // booster } // booster
 End of changes. 12 change blocks. 
3 lines changed or deleted 70 lines changed or added


 filters.h   filters.h 
skipping to change at line 39 skipping to change at line 39
#include <cppcms/localization.h> #include <cppcms/localization.h>
namespace cppcms { namespace cppcms {
/// ///
/// \brief This namespace various filters that can be used in templa tes for filtering data /// \brief This namespace various filters that can be used in templa tes for filtering data
/// ///
/// ///
namespace filters { namespace filters {
/// ///
/// \brief A special proxy object for writing any object to
a std::ostream
///
/// This is special object that is used to store a reference to any other object /// This is special object that is used to store a reference to any other object
/// that can be written to std::ostream, giving as easy way to write a filter for /// that can be written to std::ostream, giving as easy way to write a filter for
/// any object that can be written to stream /// any object that can be written to stream
/// ///
class CPPCMS_API streamable { class CPPCMS_API streamable {
public: public:
/// \cond INTERNAL /// \cond INTERNAL
typedef void (*to_stream_type)(std::ostream &,void c onst *ptr); typedef void (*to_stream_type)(std::ostream &,void c onst *ptr);
typedef std::string (*to_string_type)(std::ios &,voi d const *ptr); typedef std::string (*to_string_type)(std::ios &,voi d const *ptr);
/// \endcond /// \endcond
 End of changes. 1 change blocks. 
0 lines changed or deleted 3 lines changed or added


 form.h   form.h 
skipping to change at line 182 skipping to change at line 182
}; };
/// ///
/// \brief This class is the base class for any form or form widget used in CppCMS. /// \brief This class is the base class for any form or form widget used in CppCMS.
/// ///
/// It provides basic, abstract operations that every widget or form should implement. /// It provides basic, abstract operations that every widget or form should implement.
/// ///
class CPPCMS_API base_form : public form_flags { class CPPCMS_API base_form : public form_flags {
public: public:
/// ///
/// Render the widget to std::ostream \a output with the con /// Render the widget to the output set in \a cppcms::form_c
trol flags \a flags. ontext::out()
/// according to the control flags set in \a cppcms::form_fl
ags.
/// Usually this function is called directly by the template rendering functions. /// Usually this function is called directly by the template rendering functions.
/// ///
virtual void render(form_context &context) = 0; virtual void render(form_context &context) = 0;
/// ///
/// Load the form information from the provided http::contex t \a context. /// Load the form information from the provided http::contex t \a context.
/// A user can call this function to load all information fr om the raw POST/GET /// A user can call this function to load all information fr om the raw POST/GET
/// data into the internal widget representation. /// data into the internal widget representation.
/// ///
virtual void load(http::context &context) = 0; virtual void load(http::context &context) = 0;
skipping to change at line 206 skipping to change at line 207
/// true is returned. If some widget or form fails, false is returned. /// true is returned. If some widget or form fails, false is returned.
/// ///
virtual bool validate() = 0; virtual bool validate() = 0;
/// ///
/// Clear the form from all user provided data. /// Clear the form from all user provided data.
/// ///
virtual void clear() = 0; virtual void clear() = 0;
/// ///
/// Set a parent of this form. Used internally. You should n ot use it. /// Set the parent of this form. Used internally. You should not use it.
/// ///
virtual void parent(base_form *subform) = 0; virtual void parent(base_form *subform) = 0;
/// ///
/// Get the parent of this form. If this is the topmost form , NULL is returned. /// Get the parent of this form. If this is the topmost form , NULL is returned.
/// ///
virtual base_form *parent() = 0; virtual base_form *parent() = 0;
base_form(); base_form();
virtual ~base_form(); virtual ~base_form();
}; };
/// ///
/// \brief The \a form is a container used to collect other widgets and forms into a single unit. /// \brief The \a form is a container used to collect other widgets and forms into a single unit.
/// ///
/// Generally various widgets and forms are combined into a single f /// Generally various widgets and forms are combined into a single f
orm in order to simplify the rendering orm in order to simplify their rendering
/// and validation of forms that include more than one widget. /// and validation of the forms that include more than one widget.
/// ///
class CPPCMS_API form : public booster::noncopyable, class CPPCMS_API form : public booster::noncopyable,
public base_form public base_form
{ {
public: public:
form(); form();
virtual ~form(); virtual ~form();
/// ///
/// Render all the widgets and sub-forms to the \a output, u sing /// Render all the widgets and sub-forms to the \a output, u sing
/// the base_form \a flags. /// the flags defined in the \a context.
/// ///
virtual void render(form_context &context); virtual void render(form_context &context);
/// ///
/// Load all the widget information from http::context \a co nt. /// Load all the widget information from http::context \a co nt.
/// ///
virtual void load(http::context &cont); virtual void load(http::context &cont);
/// ///
/// Validate all subforms and widgets. If at least one of th em fails, /// Validate all subforms and widgets. If at least one of th em fails,
skipping to change at line 309 skipping to change at line 310
return *this; return *this;
} }
/// ///
/// Set the parent of this form. It is used internally; you should not use it. It is called /// Set the parent of this form. It is used internally; you should not use it. It is called
/// when the form is added or attached to another form. /// when the form is added or attached to another form.
/// ///
virtual void parent(base_form *subform); virtual void parent(base_form *subform);
/// ///
/// Get parent of this form. If this is the topmost form, NU LL is returned. /// Get the parent of this form. If this is the topmost form , NULL is returned.
/// It is assumed that the parent is always a form. /// It is assumed that the parent is always a form.
/// ///
virtual form *parent(); virtual form *parent();
/// ///
/// \brief Input iterator used to iterate over all the widge ts in a form. /// \brief Input iterator used to iterate over all the widge ts in a form.
/// ///
/// This class is mainly used by templates to render widgets . It /// This class is mainly used by templates to render widgets . It
/// walks over all widgets and subforms recursively. /// recursively iterates over all the widgets and subforms.
/// ///
/// Note: it walks over widgets only: /// \note it iterates over widgets only and never \ref
/// form objects.
/// ///
/// \code /// \code
/// iterator p=f.begin(); /// iterator p=f.begin();
/// if(p!=f.end()) /// if(p!=f.end())
/// if p!=f.end() --> *p is derived from widgets::base_wid get. /// if p!=f.end() --> *p is derived from widgets::base_wid get.
/// \endcode /// \endcode
/// ///
class CPPCMS_API iterator : public std::iterator<std::input_ iterator_tag,widgets::base_widget> class CPPCMS_API iterator : public std::iterator<std::input_ iterator_tag,widgets::base_widget>
{ {
public: public:
skipping to change at line 389 skipping to change at line 391
/// ///
/// Check if two iterators point to different elemen ts. /// Check if two iterators point to different elemen ts.
/// ///
bool operator!=(iterator const &other) const bool operator!=(iterator const &other) const
{ {
return !equal(other); return !equal(other);
} }
/// ///
/// Post Increment operator, it forward the iterator /// Post increment operator. It forwards the iterato
no text widget. r to the next widget.
/// Note it does not point to higher level form cont /// Note it does not point to the higher level form
ainer. container.
/// ///
/// Note: it is preferable to use ++i rather than i+ + as copying iterators is not cheap. /// Note: it is preferable to use ++i rather than i+ + as copying iterators is not cheap.
/// ///
iterator operator++(int /*unused*/) iterator operator++(int /*unused*/)
{ {
iterator tmp(*this); iterator tmp(*this);
next(); next();
return tmp; return tmp;
} }
/// ///
/// Increment operator. It forward the iterator no t /// Increment operator. It forwards the iterator to
ext widget. the next widget.
/// Note it does not point to higher level form cont /// Note it does not point to the higher level form
ainer container.
/// ///
iterator &operator++() iterator &operator++()
{ {
next(); next();
return *this; return *this;
} }
private: private:
friend class form; friend class form;
skipping to change at line 429 skipping to change at line 431
std::stack<unsigned> return_positions_; std::stack<unsigned> return_positions_;
form *current_; form *current_;
unsigned offset_; unsigned offset_;
struct _data; struct _data;
booster::copy_ptr<_data> d; booster::copy_ptr<_data> d;
}; };
/// ///
/// Returns an iterator to the first widget. /// Returns the iterator to the first widget.
/// ///
iterator begin(); iterator begin();
/// ///
/// Returns the end-iterator for walking over all widgets. /// Returns the end of the range iterator.
/// ///
iterator end(); iterator end();
private: private:
friend class iterator; friend class iterator;
struct _data; struct _data;
// Widget and ownership true mine // Widget and ownership - true means I own it.
typedef std::pair<base_form *,bool> widget_type; typedef std::pair<base_form *,bool> widget_type;
std::vector<widget_type> elements_; std::vector<widget_type> elements_;
form *parent_; form *parent_;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// \brief This namespace includes all widgets (html-forms) supporte d by cppcms /// \brief This namespace includes all the widgets (i.e. parts of HT ML forms) supported by cppcms.
/// ///
namespace widgets { namespace widgets {
/// ///
/// \brief this class is the base class of all renderable wi /// \brief this class is the base class of all renderable wi
dgets that can be dgets which
/// used together with forms /// can be used with CppCMS form system.
/// ///
/// All cppcms widgets are derived from this class. User, wh /// All cppcms widgets are derived from this class. Users wh
o want to create o want to create
/// its own custom widgets must derive them from this class /// their own custom widgets must derive them from this clas
s.
/// ///
class CPPCMS_API base_widget : class CPPCMS_API base_widget :
public base_form, public base_form,
public booster::noncopyable public booster::noncopyable
{ {
public: public:
/// ///
/// Default constructor /// Default constructor.
/// ///
base_widget(); base_widget();
virtual ~base_widget(); virtual ~base_widget();
/// ///
/// Check if a value was assigned to widget. Usually /// Check if a value has been assigned to the widget
becomes true . It is usually true
/// when user assignees value to widget or the widge /// when the user has assigned a value to the widget
t is loaded. or when the widget is loaded.
/// ///
/// If there is exist a reasonable default value for a widget /// If there is a reasonable default value for the w idget
/// then set() should be true. For widgets like file or numeric /// then set() should be true. For widgets like file or numeric
/// where explicit parsing is required the set() val /// where explicit parsing is required, the set() va
ue would indecate lue would indicate
/// that user provided some value (uploaded a file, /// that user provided some value (i.e. uploaded a f
had gave a number) ile or entered a number).
/// ///
bool set(); bool set();
/// ///
/// After executing validation, each widget can be t ested for validity /// After having executed the validation process, ea ch widget can be tested for validity.
/// ///
bool valid(); bool valid();
/// ///
/// Get html id attribute /// Get the HTML \a id attribute.
/// ///
std::string id(); std::string id();
/// ///
/// Get html name attribute /// Get the HTML \a name attribute.
/// ///
std::string name(); std::string name();
/// ///
/// Get short message that would be displayed near t he widget /// Get the short message that would be displayed ne ar the widget.
/// ///
locale::message message(); locale::message message();
/// ///
/// Check if message is set /// Check if a message is set.
/// ///
bool has_message(); bool has_message();
/// ///
/// Get associated error message that would be displ /// Get the error message that would be displayed ne
ayed near the widget ar the widget
/// if widget validation failed. /// if the widget validation failed.
/// ///
locale::message error_message(); locale::message error_message();
/// ///
/// Check if error message is set /// Check if an error message is set.
/// ///
bool has_error_message(); bool has_error_message();
/// ///
/// Get long description for specific widget /// Get the eventual long description of the wigget.
/// ///
locale::message help(); locale::message help();
/// ///
/// Check if help message is set /// Check if a help message is set.
/// ///
bool has_help(); bool has_help();
/// ///
/// Get disabled html attribute /// Get the HTML \c disabled attribute.
/// ///
bool disabled(); bool disabled();
/// ///
/// Set/Unset disabled html attribute /// Set/Unset the HTML \c disabled attribute.
/// ///
void disabled(bool); void disabled(bool);
/// ///
/// Get the general user defined attributes string t hat can be added to widget /// Get the general user defined attribute string th at can be added to the widget.
/// ///
std::string attributes_string(); std::string attributes_string();
/// ///
/// Set the existence of content for widget. By defa /// Set the existence of content for the widget. By
ult the widget is not set. default the widget is not set.
/// Any value fetch from "unset" widget by conventio /// By convention, trying to fetch a value from a wi
n should throw an exception dget that is "unset" will throw an exception.
/// Calling set with true -- changes state to "set" /// Call set(true) to change the state to "set" and
and with false to "unset" call set(false) to change it to "unset".
/// ///
void set(bool); void set(bool);
/// ///
/// Set validity state of widget. By default the wid /// Set th validity state of the widget. By default
get is valid. When it the widget is valid. If it fails to pass
/// passes validation its validity state is changed /// the validation, its validity state is changed by
by calling this function calling this function.
/// ///
/// Note: widget maybe not-set but still valid and i t may be set but not-valid /// Note: a widget may be "unset" and still be valid . Conversely, it may be set but be not-valid.
/// ///
void valid(bool); void valid(bool);
/// ///
/// Set html id attribute of the widget /// Set the HTML \c id attribute of the widget.
/// ///
void id(std::string); void id(std::string);
/// ///
/// Set html name attribute of the widget. Note: if /// Set the HTML \c name attribute of the widget. No
this attribute te: if this attribute
/// is not set, the widget would not be able to be l /// is not set, the widget will not be able to be lo
oaded from POST/GET aded from the POST/GET
/// data. /// data.
/// ///
void name(std::string); void name(std::string);
/// ///
/// Set short description for the widget. Generally it is good idea to /// Set a short description for the widget. Generall y, it is a good idea to
/// define this value. /// define this value.
/// ///
/// Short message can be also set using base_widget constructor /// The short message can also be set using the base _widget constructor.
/// ///
void message(std::string); void message(std::string);
/// ///
/// Set short translatable description for the widge t. Generally it is good idea to /// Set a short translatable description for the wid get. Generally, it is a good idea to
/// define this value. /// define this value.
/// ///
/// Short message can be also set using base_widget constructor /// The short message can also be set using the base _widget constructor.
/// ///
void message(locale::message const &); void message(locale::message const &);
/// ///
/// Set error message that is displayed for invalid widgets. /// Set the error message that is displayed for inva lid widgets.
/// ///
/// If it is not set, simple "*" is shown /// If it is not set, a simple "*" is shown instead.
/// ///
void error_message(std::string); void error_message(std::string);
/// ///
/// Set translatable error message that is displayed for invalid widgets. /// Set the translatable error message that is displ ayed for invalid widgets.
/// ///
/// If it is not set, simple "*" is shown /// If it is not set, a simple "*" is shown instead.
/// ///
void error_message(locale::message const &); void error_message(locale::message const &);
/// ///
/// Set longer help message that describes this widg et /// Set a longer help message that describes this wi dget.
/// ///
void help(std::string); void help(std::string);
/// ///
/// Set translatable help message that describes thi s widget /// Set a translatable help message that describes t his widget.
/// ///
void help(locale::message const &msg); void help(locale::message const &msg);
/// ///
/// Set general html attributes that are not support /// Set general HTML attributes that are not directl
ed y supported
/// directly. For example: /// For example:
/// ///
/// \code /// \code
/// my_widget.attributes_string("style='direction:r tl' onclick='return foo()'"); /// my_widget.attributes_string("style='direction:r tl' onclick='return foo()'");
/// \endcode /// \endcode
/// ///
/// This string is inserted as-is just behind render _input_start /// This string is inserted as-is just after render_ input_start.
/// ///
void attributes_string(std::string v); void attributes_string(std::string v);
/// ///
/// Render full widget with error messages and decor /// Render the full widget together with error messa
ations as paragraphs ges and decorations as paragraphs
/// or table elements to \a output /// or table elements to the output set in \a cppcms
::form_context::out().
/// ///
virtual void render(form_context &context); virtual void render(form_context &context);
/// ///
/// This is a virtual member function that should be /// This is a virtual member function that should be
implemented by each widget implemented by each widget.
/// It executes actual rendering of the input HTML f /// It executes the actual rendering of the HTML for
orm m.
/// ///
virtual void render_input(form_context &context) = 0 ; virtual void render_input(form_context &context) = 0 ;
/// ///
/// Clean the form. Calls set(false) as well /// Clear the form. It also calls set(false).
/// ///
virtual void clear(); virtual void clear();
/// ///
/// Validate form. If not overridden it sets widget to valid /// Validate the form. If not overridden, it sets th e widget to \a valid.
/// ///
virtual bool validate(); virtual bool validate();
/// ///
/// Render standard common attributes like id, name, disabled etc. /// Render standard common attributes like \a id, \a name, \a disabled, etc.
/// ///
virtual void render_attributes(form_context &context ); virtual void render_attributes(form_context &context );
/// ///
/// Set parent of this widget. Used internaly, shoul /// Set the parent of this widget. It is used intern
d not be used. It is called ally; you should not use it. It is called
/// when the form is added or attached to other form /// when the form is added or attached to another fo
. rm.
/// ///
virtual void parent(base_form *subform); virtual void parent(base_form *subform);
/// ///
/// Get parent of this form. If this is topmost form /// Get the parent of this form. If this is the topm
, NULL is returned ost form, NULL is returned.
/// Note widget is assumed to be assigned to forms o /// It is assumed that the parent is always a form.
nly
/// ///
virtual form *parent(); virtual form *parent();
/// ///
/// This function should be called before actual loa ding /// This function should be called before actual loa ding
/// of widgets, it performs cross widgets validation /// of widgets, it performs cross widgets validation
/// and causes automatic generation of undefined nam es /// and causes automatic generation of undefined nam es
/// ///
void pre_load(http::context &); void pre_load(http::context &);
protected: protected:
/// ///
/// This function should be called by overloaded loa /// This function should be called by overloadeding
d/render methods the load/render methods
/// before rendering/loading starts /// before the loading/rendering starts.
/// ///
void auto_generate(form_context *context = 0); void auto_generate(form_context *context = 0);
private:
private:
void generate(int position,form_context *context = 0 ); void generate(int position,form_context *context = 0 );
std::string id_; std::string id_;
std::string name_; std::string name_;
locale::message message_; locale::message message_;
locale::message error_message_; locale::message error_message_;
locale::message help_; locale::message help_;
std::string attr_; std::string attr_;
form *parent_; form *parent_;
skipping to change at line 715 skipping to change at line 705
uint32_t has_message_ : 1; uint32_t has_message_ : 1;
uint32_t has_error_ : 1; uint32_t has_error_ : 1;
uint32_t has_help_ : 1; uint32_t has_help_ : 1;
uint32_t reserverd_ : 25; uint32_t reserverd_ : 25;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// \brief this is the widget that is used as base for text input field representation /// \brief This widget is used as base for text input fields .
/// ///
/// This widget is used as base class for other widgets that /// This widget is used as the base class for other widgets
are used for that are used for
/// text input like: text, textarea, etc. /// text input like: \ref text, \ref textarea, etc.
/// ///
/// This widget does much more then reading simple filed dat /// This widget does much more than reading simple text data
a from the POST from the POST
/// or GET form, it performs charset validation and if requi /// or GET form. It also performs charset validation.
red conversion
/// to and from Unicode charset to locale charset.
/// ///
class CPPCMS_API base_text : virtual public base_widget { class CPPCMS_API base_text : virtual public base_widget {
public: public:
base_text(); base_text();
virtual ~base_text(); virtual ~base_text();
/// ///
/// Get the string that contains input value of the widget. /// Get the string that contains the input value of the widget.
/// ///
std::string value(); std::string value();
/// ///
/// Set the widget content before rendering, the val ue \a v /// Set the widget content to the value \a v before rendering.
/// ///
void value(std::string v); void value(std::string v);
/// ///
/// Acknowledge the validator that this text widget /// Inform the validator that this text widget shoul
should contain some text. d contain some text.
/// similar to limits(1,-1) /// It is similar to limits(1,-1).
/// ///
void non_empty(); void non_empty();
/// ///
/// Set minimum and maximum limits for text size. No /// Set the minimum and maximum limits of the text s
te max == -1 indicates that there ize. Note: max == -1 indicates that there
/// is no maximal limit, min==0 indicates that there /// is no maximum limit; min==0 indicates that there
is no minimal limit. is no minimum limit.
/// ///
/// Note: these numbers represent the length in Unic ode code points (even if the encoding /// Note: these numbers represent the length in Unic ode code points (even if the encoding
/// is not Unicode). If character set validation is disabled, then these number represent /// is not Unicode). If the character set validation is disabled, then these numbers represent
/// the number of octets in the string. /// the number of octets in the string.
/// ///
void limits(int min,int max); void limits(int min,int max);
/// ///
/// Get minimal and maximal size limits, /// Get the minimum and maximum size limits,
/// ///
std::pair<int,int> limits(); std::pair<int,int> limits();
/// ///
/// Acknowledge the validator if it should not check /// Inform the validator whether it should check the
the validity of the charset. validity of the charset.
/// Default -- enabled /// The default is enabled (true).
/// ///
/// Generally you should not use this option unless /// Generally you should not use this option to disa
you want to load some raw data as ble the charset validation
/// form input, or the character set is different fr /// unless you want to load some raw data as
om the defined in locale. /// form input, or the character set is different fr
om the one defined in the locale.
/// ///
void validate_charset(bool ); void validate_charset(bool );
/// ///
/// Returns true if charset validation is enabled. /// Return true if the charset validation is enabled .
/// ///
bool validate_charset(); bool validate_charset();
/// ///
/// Validate the widget content according to rules a nd charset encoding. /// Validate the widget content according to the rul es and to the charset encoding.
/// ///
/// Notes: /// Notes:
/// ///
/// - The charset validation is very efficient for /// - The charset validation is very efficient for
variable length UTF-8 encoding, variable length UTF-8 encoding as well as
/// and most popular fixed length ISO-8859-*, win /// for most popular fixed length encodings like
dows-125* and koi8* encodings, for other ISO-8859-*, windows-125* and koi8*.
/// encodings iconv conversion is used for actual /// For other encodings, character set conversion
validation. is used for the actual validation.
/// - Special characters (that not allowed in HTML) /// - Special characters (that are not allowed in H
are assumed as forbidden, even if they are TML) are assumed to be forbidden, even if they are
/// valid code points (like NUL = 0 or DEL=127). /// valid code points (like NUL = 0 or DEL=127).
/// ///
virtual bool validate(); virtual bool validate();
/// ///
/// Load the widget for http::context. It used the l /// Load the widget for http::context. It uses the l
ocale given in the context for ocale given in the context to
/// validation of text. /// validate the text.
/// ///
virtual void load(http::context &); virtual void load(http::context &);
private: private:
std::string value_; std::string value_;
int low_; int low_;
int high_; int high_;
bool validate_charset_; bool validate_charset_;
size_t code_points_; size_t code_points_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
skipping to change at line 808 skipping to change at line 795
std::string value_; std::string value_;
int low_; int low_;
int high_; int high_;
bool validate_charset_; bool validate_charset_;
size_t code_points_; size_t code_points_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// This class represents a basic widget that generates html /// \brief This class represents a basic widget that generat
for common widgets es HTML form elements
/// that use <input \/> HTML tag. /// the widgets that use the <input \/> HTML tag.
/// ///
/// It allows you creating your own widgets easier as it doe /// It allows you to create your own widgets more easily. It
s most of job required for does most of job required to
/// generating the HTML and user is required only to generat /// generate the HTML. The user is only required to generate
e actual value like the actual value like
/// value="10.34" as for numeric widget. /// value="10.34" as with a numeric widget.
/// ///
class CPPCMS_API base_html_input : virtual public base_widge t { class CPPCMS_API base_html_input : virtual public base_widge t {
public: public:
/// ///
/// Creates new instance, \a type is HTML type tag o f the input element, for example "text" or /// Create a new instance. \a type is the HTML type tag of the input element, for example "text" or
/// "password". /// "password".
/// ///
base_html_input(std::string const &type); base_html_input(std::string const &type);
/// ///
/// Virtual destructor... /// Virtual destructor.
/// ///
virtual ~base_html_input(); virtual ~base_html_input();
/// ///
/// This function is actual HTML generation function that calls render_value where needed. /// This function generates the actual HTML. It call s render_value where needed.
/// ///
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
protected: protected:
/// ///
/// This is what user actually expected to implement . Write actual value HTML tag. /// Write the actual value of the HTML tag. Derived classes must implement this.
/// ///
virtual void render_value(form_context &context) = 0 ; virtual void render_value(form_context &context) = 0 ;
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
std::string type_; std::string type_;
}; };
/// ///
/// \brief This class represents html input of type text /// \brief This class represents an HTML form input element of type text.
/// ///
class CPPCMS_API text : public base_html_input, public base_ text class CPPCMS_API text : public base_html_input, public base_ text
{ {
public: public:
/// ///
/// Create text field widget /// Create a text field widget.
/// ///
text(); text();
/// ///
/// This constructor is provided for use by derived classes where it is required /// This constructor is provided for use by derived classes where it is required
/// to change the type of widget, like text, passwor d, etc. /// to change the type of the widget, like text, pas sword, etc.
/// ///
text(std::string const &type); text(std::string const &type);
~text(); ~text();
/// ///
/// Set html attribute size of the widget /// Set the HTML size attribute of the widget.
/// ///
void size(int n); void size(int n);
/// ///
/// Get html attribute size of the widget, -1 undefi ned /// Get the HTML size attribute size of the widget. It returns -1 if it is undefined.
/// ///
int size(); int size();
virtual void render_attributes(form_context &context ); virtual void render_attributes(form_context &context );
virtual void render_value(form_context &context); virtual void render_value(form_context &context);
private: private:
int size_; int size_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// This widget represents hidden input form type. It is use /// \brief This widget represents a hidden input form elemen
d to provide t. It is used to provide
/// some invisible to user information. /// information invisible to the user.
/// ///
/// I has same properties that text widget has but it does n /// I has the same properties as a text widget has but it do
ot render any HTML es not render any HTML
/// related to message(), help() and other informational typ /// for message(), help() and other informational types.
es.
/// ///
/// When your render the form in templates it is good idea t /// When you render the form in templates, it is a good idea
o render it separately to render it separately
/// to make sure that no invalid HTML would be created. /// to make sure that no invalid HTML is created.
/// ///
class CPPCMS_API hidden : public text class CPPCMS_API hidden : public text
{ {
public: public:
hidden(); hidden();
~hidden(); ~hidden();
/// ///
/// Actual rendering function that is redefined /// Render the HTML of the widget. It overrides
/// the default HTML rendering as hidden widget
/// is never displayed.
/// ///
virtual void render(form_context &context); virtual void render(form_context &context);
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// This text widget behaves similarly to text widget but us /// \brief This text widget behaves similarly to the text wi
es rather HTML dget but uses
/// textarea and not input HTML tags /// the \c textarea HTML tag rather than the \c input HTML t
ag.
/// ///
class CPPCMS_API textarea : public base_text class CPPCMS_API textarea : public base_text
{ {
public: public:
textarea(); textarea();
~textarea(); ~textarea();
/// ///
/// Get number of rows in textarea -- default -1 -- undefined /// Get the number of rows in the textarea. The defa ult is -1 -- undefined.
/// ///
int rows(); int rows();
/// ///
/// Get number of columns in textarea -- default -1 -- undefined /// Get the number of columns in the textarea. The d efault is -1 -- undefined.
/// ///
int cols(); int cols();
/// ///
/// Set number of rows in textarea /// Set the number of rows in the textarea.
/// ///
void rows(int n); void rows(int n);
/// ///
/// Set number of columns in textarea /// Set the number of columns in the textarea.
/// ///
void cols(int n); void cols(int n);
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
private: private:
int rows_,cols_; int rows_,cols_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// \brief Widget for number input. It is template class tha t assumes that T is number /// \brief Widget for number input. It is a template class t hat assumes that T is a number.
/// ///
/// This class parses the input and checks if it is value va /// This class parses the input and checks if it is input te
lue. If it is set() would xt is a valid
/// numeric value. If it is valid, the set() would return tr
ue
/// be true. /// be true.
/// ///
/// If the value was not defined access to value() would thr ow an exception /// If the value was not defined, access to value() will thr ow an exception.
/// ///
template<typename T> template<typename T>
class numeric: public base_html_input { class numeric: public base_html_input {
public: public:
numeric() : numeric() :
base_html_input("text"), base_html_input("text"),
check_low_(false), check_low_(false),
check_high_(false), check_high_(false),
non_empty_(false) non_empty_(false)
{ {
} }
skipping to change at line 966 skipping to change at line 957
public: public:
numeric() : numeric() :
base_html_input("text"), base_html_input("text"),
check_low_(false), check_low_(false),
check_high_(false), check_high_(false),
non_empty_(false) non_empty_(false)
{ {
} }
/// ///
/// Defines that this widget should have some value /// Inform the validator that this widget should con tain some value.
/// ///
void non_empty() void non_empty()
{ {
non_empty_=true; non_empty_=true;
} }
/// ///
/// Get loaded widget value /// Get numeric value that was loaded from the POST
or
/// GET data.
///
/// \note if the value was not set (empty field for
example)
/// then this function will throw. So it is good ide
a to
/// check if \ref set() returns true before using th
is
/// function.
/// ///
T value() T value()
{ {
if(!set()) if(!set())
throw cppcms_error("Value not loaded "); throw cppcms_error("Value not loaded ");
return value_; return value_;
} }
/// ///
/// Set widget value /// Set the value of the widget.
/// ///
void value(T v) void value(T v)
{ {
set(true); set(true);
value_=v; value_=v;
} }
/// ///
/// Set minimal input number value /// Set the minimum valid value.
/// ///
void low(T a) void low(T a)
{ {
min_=a; min_=a;
check_low_=true; check_low_=true;
non_empty(); non_empty();
} }
/// ///
/// Set maximal input number value /// Set the maximum valid value.
/// ///
void high(T b) void high(T b)
{ {
max_=b; max_=b;
check_high_=true; check_high_=true;
non_empty(); non_empty();
} }
/// ///
/// Same as low(a); high(b); /// Same as low(a); high(b);
/// ///
skipping to change at line 1023 skipping to change at line 1019
/// ///
/// Same as low(a); high(b); /// Same as low(a); high(b);
/// ///
void range(T a,T b) void range(T a,T b)
{ {
low(a); low(a);
high(b); high(b);
} }
/// ///
/// Render first part of widget /// Render the first part of the widget.
/// ///
virtual void render_value(form_context &context) virtual void render_value(form_context &context)
{ {
if(set()) if(set())
context.out()<<"value=\""<<value_<<" \" "; context.out()<<"value=\""<<value_<<" \" ";
else else
context.out()<<"value=\""<<util::esc ape(loaded_string_)<<"\" "; context.out()<<"value=\""<<util::esc ape(loaded_string_)<<"\" ";
} }
virtual void clear() virtual void clear()
{ {
skipping to change at line 1041 skipping to change at line 1036
context.out()<<"value=\""<<util::esc ape(loaded_string_)<<"\" "; context.out()<<"value=\""<<util::esc ape(loaded_string_)<<"\" ";
} }
virtual void clear() virtual void clear()
{ {
base_html_input::clear(); base_html_input::clear();
loaded_string_.clear(); loaded_string_.clear();
} }
/// ///
/// Load widget data /// Load the widget data.
/// ///
virtual void load(http::context &context) virtual void load(http::context &context)
{ {
pre_load(context); pre_load(context);
loaded_string_.clear(); loaded_string_.clear();
set(false); set(false);
valid(true); valid(true);
http::request::form_type::const_iterator p; http::request::form_type::const_iterator p;
skipping to change at line 1075 skipping to change at line 1069
ss.imbue(context.locale()); ss.imbue(context.locale());
ss>>value_; ss>>value_;
if(ss.fail() || !ss.eof()) if(ss.fail() || !ss.eof())
valid(false); valid(false);
else else
set(true); set(true);
} }
} }
/// ///
/// Validate widget /// Validate the widget.
/// ///
virtual bool validate() virtual bool validate()
{ {
if(!valid()) if(!valid())
return false; return false;
if(!set()) { if(!set()) {
if(non_empty_) { if(non_empty_) {
valid(false); valid(false);
return false; return false;
} }
skipping to change at line 1110 skipping to change at line 1104
T min_,max_,value_; T min_,max_,value_;
bool check_low_; bool check_low_;
bool check_high_; bool check_high_;
bool non_empty_; bool non_empty_;
std::string loaded_string_; std::string loaded_string_;
}; };
/// ///
/// \brief The password widget is a simple text widget with some different /// \brief The password widget is a simple text widget with few, obvious differences.
// //
class CPPCMS_API password: public text { class CPPCMS_API password: public text {
public: public:
password(); password();
~password(); ~password();
/// ///
/// Set equality constraint to password widget -- th /// Set the equality constraint to another password
is password should be widget. This password should be
/// equal to other one \a p2. Usefull for creation o /// equal to the one in \a p2. It is usefull when cr
f new passwords -- if passwords eating new passwords: if the passwords
/// are not equal, validation would fail /// are not equal, the validation will fail.
/// ///
void check_equal(password &p2); void check_equal(password &p2);
virtual bool validate(); virtual bool validate();
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
password *password_to_check_; password *password_to_check_;
}; };
/// ///
/// \brief This class is extinction of text widget that vali dates it using additional regular expression /// \brief This class is extending a simple text widget by u sing additional regular expression validation.
/// ///
class CPPCMS_API regex_field : public text { class CPPCMS_API regex_field : public text {
public: public:
regex_field(); regex_field();
/// ///
/// Create widget using regular expression \a e /// Create a widget using the regular expression \a e.
/// ///
regex_field(booster::regex const &e); regex_field(booster::regex const &e);
/// ///
/// Create widget using regular expression \a e /// Create a widget using the regular expression \a e.
/// ///
regex_field(std::string const &e); regex_field(std::string const &e);
/// ///
/// Set regular expression /// Set the regular expression.
/// ///
void regex(booster::regex const &e); void regex(booster::regex const &e);
~regex_field(); ~regex_field();
virtual bool validate(); virtual bool validate();
private: private:
booster::regex expression_; booster::regex expression_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// \brief widget that checks that input is valid e-mail /// \brief This widget checks that the input is a valid emai l address.
/// ///
class CPPCMS_API email : public regex_field { class CPPCMS_API email : public regex_field {
public: public:
email(); email();
~email(); ~email();
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
skipping to change at line 1179 skipping to change at line 1172
email(); email();
~email(); ~email();
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// This class represent an html checkbox input widget /// \brief This class represent an HTML checkbox input eleme nt.
/// ///
class CPPCMS_API checkbox: public base_html_input { class CPPCMS_API checkbox: public base_html_input {
public: public:
/// ///
/// The constructor that allows you to specify other /// The constructor that allows you to specify \c ty
type like "radio" pe HTML
/// attribute. It is passed to the constructor of th
e
/// \ref base_html_input class.
/// ///
checkbox(std::string const &type); checkbox(std::string const &type);
/// ///
/// Default constructor, type checkbox /// Default constructor.
/// ///
checkbox(); checkbox();
virtual ~checkbox(); virtual ~checkbox();
/// ///
/// Returns true of box was checked (selected) /// Return true if the checkbox was checked (selecte d).
/// ///
bool value(); bool value();
/// ///
/// Set checked state /// Set the state as \a checked.
/// ///
void value(bool is_set); void value(bool is_set);
/// ///
/// Get unique identification of the checkbox /// Get the unique identification string of the chec kbox.
/// ///
std::string identification(); std::string identification();
/// ///
/// Set unique identification to the checkbox, usefu /// Set the unique identification string of the chec
l when you want to kbox. It is useful when you want to
/// have many options with same name /// have many options with the same name.
/// ///
void identification(std::string const &); void identification(std::string const &);
virtual void render_value(form_context &context); virtual void render_value(form_context &context);
virtual void load(http::context &context); virtual void load(http::context &context);
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
std::string identification_; std::string identification_;
bool value_; bool value_;
}; };
/// ///
/// Select multiple elements widget /// \brief This widget represents an HTML multiple select fo rm element.
/// ///
class CPPCMS_API select_multiple : public base_widget { class CPPCMS_API select_multiple : public base_widget {
public: public:
select_multiple(); select_multiple();
~select_multiple(); ~select_multiple();
/// ///
/// Add a new option to list with display name \a ms /// Add to the multiple select a new option with the
g, and specify if it is initially display name \a msg, and specify if it is initially
/// selected, default false /// selected. The default is \a false.
/// ///
void add(std::string const &msg,bool selected=false) ; void add(std::string const &msg,bool selected=false) ;
/// ///
/// Add a new option to list with display name \a ms /// Add to the multiple select a new option with the
g, and specify if it is initially display name \a msg, and specify if it is initially
/// selected, default false, providing unique identi /// selected (the default is \a false), providing a
fication for the element \a id unique identification string to use as the element's \a id.
/// ///
void add(std::string const &msg,std::string const &i d,bool selected=false); void add(std::string const &msg,std::string const &i d,bool selected=false);
/// ///
/// Add a new option to list with localized display /// Add to the multiple select a new option with the
name \a msg, and specify if it is initially localized display name \a msg, and specify if it is initially
/// selected, default false /// selected. The default is \a false.
/// ///
void add(locale::message const &msg,bool selected=fa lse); void add(locale::message const &msg,bool selected=fa lse);
/// ///
/// Add a new option to list with localized display /// Add to the multiple select a new option with the
name \a msg, and specify if it is initially localized display name \a msg, and specify if it is initially
/// selected, default false, providing unique identi /// selected (the default is \a false), providing a
fication for the element \a id unique identification string to use as the element's \a id.
/// ///
void add(locale::message const &msg,std::string cons t &id,bool selected=false); void add(locale::message const &msg,std::string cons t &id,bool selected=false);
/// ///
/// Get the mapping of all selected items according to the order they where added to the list /// Get the mapping of all the selected items accord ing to the order they where added to the multiple select list.
/// ///
std::vector<bool> selected_map(); std::vector<bool> selected_map();
/// ///
/// Get all selected items ids according to the orde /// Get all the selected items ids according to the
r they where added to the list, if no order they where added to the list. If no
/// specific id was given, strings "0", "1"... would /// specific id was given, a string like "0", "1"...
be used will be used.
/// ///
std::set<std::string> selected_ids(); std::set<std::string> selected_ids();
/// ///
/// Get minimal amount of options that should be cho sen, default = 0 /// Get the minimum amount of options that can be ch osen. The default is \a 0.
/// ///
unsigned at_least(); unsigned at_least();
/// ///
/// Set minimal amount of options that should be cho sen, default = 0 /// Set the minimum amount of options that can be ch osen. The default is \a 0.
/// ///
void at_least(unsigned v); void at_least(unsigned v);
/// ///
/// Get maximal amount of options that should be cho sen, default unlimited /// Get the maximum amount of options that can be ch osen. The default is unlimited.
/// ///
unsigned at_most(); unsigned at_most();
/// ///
/// Set maximal amount of options that should be cho sen, default unlimited /// Set the maximum amount of options that can be ch osen. The default is unlimited.
/// ///
void at_most(unsigned v); void at_most(unsigned v);
/// ///
/// Same as at_least(1) /// Same as at_least(1).
/// ///
void non_empty(); void non_empty();
/// ///
/// Get the number of rows used for widget, default 0 -- undefined /// Get the number of rows used to display the widge t. The default is \a 0 -- undefined.
/// ///
unsigned rows(); unsigned rows();
/// ///
/// Set the number of rows used for widget, default 0 -- undefined /// Set the number of rows used to display the widge t. The default is \a 0 -- undefined.
/// ///
void rows(unsigned n); void rows(unsigned n);
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
virtual bool validate(); virtual bool validate();
virtual void load(http::context &context); virtual void load(http::context &context);
virtual void clear(); virtual void clear();
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
struct element { struct element {
element(); element();
element(std::string const &v,locale::message const &msg,bool sel); element(std::string const &v,locale::message const &msg,bool sel);
element(std::string const &v,std::string con st &msg,bool sel); element(std::string const &v,std::string con st &msg,bool sel);
uint32_t selected : 1; uint32_t selected : 1;
uint32_t need_translation : 1; uint32_t need_translation : 1;
skipping to change at line 1325 skipping to change at line 1330
std::vector<element> elements_; std::vector<element> elements_;
unsigned low_; unsigned low_;
unsigned high_; unsigned high_;
unsigned rows_; unsigned rows_;
}; };
/// ///
/// This is the base class for "select" like widgets which i /// \brief This is the base class for "select" like widgets
ncludes dropdown list which include dropdown lists
/// and radio buttons set. /// and radio button sets.
/// ///
class CPPCMS_API select_base : public base_widget { class CPPCMS_API select_base : public base_widget {
public: public:
select_base(); select_base();
virtual ~select_base(); virtual ~select_base();
/// ///
/// Add new entry to selection list /// Add a new entry to the selection list.
/// ///
void add(std::string const &string); void add(std::string const &string);
/// ///
/// Add new entry to selection list giving the uniqu e entry identification \a id /// Add to the selection list a new entry with the u nique identification string \a id.
/// ///
void add(std::string const &string,std::string const &id); void add(std::string const &string,std::string const &id);
/// ///
/// Add new localized entry to selection list /// Add a new localized entry to the selection list.
/// ///
void add(locale::message const &msg); void add(locale::message const &msg);
/// ///
/// Add new localized entry to selection list giving the unique entry identification \a id /// Add to the selection list a new localized entry with the unique identification string \a id.
/// ///
void add(locale::message const &msg,std::string cons t &id); void add(locale::message const &msg,std::string cons t &id);
/// ///
/// Return the selected entry number in the list sta rting from 0. -1 indicates that nothing /// Return the number of the selected entry in the l ist. Entries are numbered starting from 0. -1 indicates that nothing
/// was selected. /// was selected.
/// ///
int selected(); int selected();
/// ///
/// Return the identification string of the selected /// Return the identification string of the selected
entry, empty string indicates that entry in the list. An empty string indicates that
/// nothing was selected /// nothing was selected.
/// ///
std::string selected_id(); std::string selected_id();
/// ///
/// Select entry number \a no in the list for render ing /// Select the entry numbered \a no.
/// ///
void selected(int no); void selected(int no);
/// ///
/// Select entry with identification \a id in the li st for rendering /// Select the entry with the identification string \a id.
/// ///
void selected_id(std::string id); void selected_id(std::string id);
/// ///
/// Require that item should be selected (for valida tion) /// Require that one item in the list should be sele cted (for the validation).
/// ///
void non_empty(); void non_empty();
virtual void render_input(form_context &context) = 0 ; virtual void render_input(form_context &context) = 0 ;
virtual bool validate(); virtual bool validate();
virtual void load(http::context &context); virtual void load(http::context &context);
virtual void clear(); virtual void clear();
protected:
protected:
struct CPPCMS_API element { struct CPPCMS_API element {
element(); element();
element(std::string const &v,locale::message const &msg); element(std::string const &v,locale::message const &msg);
element(std::string const &v,std::string con st &msg); element(std::string const &v,std::string con st &msg);
element(element const &); element(element const &);
element const &operator=(element const &); element const &operator=(element const &);
~element(); ~element();
uint32_t need_translation : 1; uint32_t need_translation : 1;
skipping to change at line 1417 skipping to change at line 1426
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
int selected_; int selected_;
int default_selected_; int default_selected_;
uint32_t non_empty_ : 1; uint32_t non_empty_ : 1;
uint32_t reserverd : 32; uint32_t reserverd : 32;
}; };
/// ///
/// Select widget that uses drop-down list /// \brief The widget that uses a drop-down list for selecti on.
/// ///
class CPPCMS_API select : public select_base { class CPPCMS_API select : public select_base {
public: public:
select(); select();
virtual ~select(); virtual ~select();
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// Select widget that uses a set of radio buttons /// \brief The widget that uses a set of radio buttons..
/// ///
class CPPCMS_API radio : public select_base { class CPPCMS_API radio : public select_base {
public: public:
radio(); radio();
virtual ~radio(); virtual ~radio();
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
/// ///
/// Return the rendering order /// Return the rendering order
/// ///
skipping to change at line 1443 skipping to change at line 1452
class CPPCMS_API radio : public select_base { class CPPCMS_API radio : public select_base {
public: public:
radio(); radio();
virtual ~radio(); virtual ~radio();
virtual void render_input(form_context &context); virtual void render_input(form_context &context);
/// ///
/// Return the rendering order /// Return the rendering order
/// ///
bool vertical(); bool vertical();
/// ///
/// Set rendering order of the list one behind other /// Set rendering order of the list one behind other
(default) or in same line. (default)
/// or in same line.
///
/// Baiscally it defines whether the radio buttons s
hould
/// appear in row (false) or in column (true).
/// ///
void vertical(bool); void vertical(bool);
private: private:
uint32_t vertical_ : 1; uint32_t vertical_ : 1;
uint32_t reserved_ : 31; uint32_t reserved_ : 31;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// \brief Class that represents file upload form entry /// \brief This class represents a file upload form entry.
/// ///
/// If the file was not uploaded set() would be false and /// If the file was not uploaded, set() will be false and
/// on attempt to access value() member function it would th /// an attempt to access the member function value() will th
row row.
/// ///
class CPPCMS_API file : public base_html_input { class CPPCMS_API file : public base_html_input {
public: public:
/// ///
/// Ensure that file is uploaded. /// Ensure that a file is uploaded (for the validati on).
/// ///
void non_empty(); void non_empty();
/// ///
/// Set minimum and maximum limits for file size. No /// Set the minimum and maximum limits for the file
te max == -1 indicates that there size. Note: max == -1 indicates that there
/// is no maximal limit, min==0 indicates that there /// is no maximum limit; min==0 indicates that there
is no minimal limit. is no minimum limit.
/// ///
/// ///
void limits(int min,int max); void limits(int min,int max);
/// ///
/// Get minimal and maximal size limits, /// Get the minimum and maximum size limits.
/// ///
std::pair<int,int> limits(); std::pair<int,int> limits();
/// ///
/// Set filename validation pattern. For example ".* \\.(jpg|jpeg|png)" /// Set the filename validation pattern. For example ".*\\.(jpg|jpeg|png)".
/// ///
/// Please, note that it is good idea to check magic /// Please, note that it is a good idea to check mag
number as well. ic numbers as well
/// and not rely on file name only.
///
/// See add_valid_magic() function
/// ///
void filename(booster::regex const &fn); void filename(booster::regex const &fn);
/// ///
/// Get regular expression for filename validation /// Get the regular expression for the filename vali dation.
/// ///
booster::regex filename(); booster::regex filename();
/// ///
/// Validate the filename's charset (default is on) /// Validate or not the filename's charset. The defa ult is \a true.
/// ///
void validate_filename_charset(bool); void validate_filename_charset(bool);
/// ///
/// Get validation option for filename's charset /// Get the validation option for the filename's cha rset.
/// ///
bool validate_filename_charset(); bool validate_filename_charset();
/// ///
/// Get uploaded file, throws cppcms_error if set() /// Get the uploaded file. This throws cppcms_error
== false, i.e. if the file if set() == false, i.e. if no file
/// was not uploaded /// was uploaded.
/// ///
booster::shared_ptr<http::file> value(); booster::shared_ptr<http::file> value();
/// ///
/// Set required file mime type /// Set the required file mime type.
/// ///
void mime(std::string const &); void mime(std::string const &);
/// ///
/// Set regular expression that checks for valid mim e type /// Set the regular expression to validate the mime type.
/// ///
void mime(booster::regex const &expr); void mime(booster::regex const &expr);
/// ///
/// Add a string that represents a valid magic numbe r that shoud exist on begging of file /// Add a string that represents a valid magic numbe r that shoud exist on begging of file.
/// ///
/// By default no tests are performed /// By default no tests are performed.
/// ///
void add_valid_magic(std::string const &); void add_valid_magic(std::string const &);
virtual void load(http::context &context); virtual void load(http::context &context);
virtual void render_value(form_context &context); virtual void render_value(form_context &context);
virtual bool validate(); virtual bool validate();
file(); file();
~file(); ~file();
skipping to change at line 1554 skipping to change at line 1572
uint32_t check_non_empty_ : 1; uint32_t check_non_empty_ : 1;
uint32_t reserved_ : 30; uint32_t reserved_ : 30;
booster::shared_ptr<http::file> file_; booster::shared_ptr<http::file> file_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// Submit button widget /// \brief Submit button widget.
/// ///
class CPPCMS_API submit : public base_html_input { class CPPCMS_API submit : public base_html_input {
public: public:
submit(); submit();
~submit(); ~submit();
/// ///
/// Returns true if this specific button was pressed /// Return true if this specific button was pressed.
/// ///
bool value(); bool value();
/// ///
/// Sets the text on button /// Set the text on the button.
/// ///
void value(std::string val); void value(std::string val);
/// ///
/// Sets the text on button /// Set the text on the button.
/// ///
void value(locale::message const &msg); void value(locale::message const &msg);
virtual void render_value(form_context &context); virtual void render_value(form_context &context);
virtual void load(http::context &context); virtual void load(http::context &context);
private: private:
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
bool pressed_; bool pressed_;
locale::message value_; locale::message value_;
}; };
} // widgets } // widgets
} //cppcms } //cppcms
 End of changes. 227 change blocks. 
316 lines changed or deleted 343 lines changed or added


 format.h   format.h 
skipping to change at line 496 skipping to change at line 496
} }
} }
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
/// ///
/// \example hello.cpp /// hello.cpp
/// ///
/// Basic example of using various functions provided by this library /// Basic example of using various functions provided by this library
/// ///
/// \example whello.cpp /// whello.cpp
/// ///
/// Basic example of using various functions with wide strings provided by this library /// Basic example of using various functions with wide strings provided by this library
/// ///
/// ///
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 fstream.h   fstream.h 
skipping to change at line 56 skipping to change at line 56
} }
return 0; return 0;
} }
catch(bad_utf const &e) { catch(bad_utf const &e) {
return 0; return 0;
} }
} }
}; };
#else // not msvc #else // not msvc
/// \cont INTERNAL
/// \cond INTERNAL
namespace details { namespace details {
class stdio_iodev : public booster::io_device { class stdio_iodev : public booster::io_device {
stdio_iodev(stdio_iodev const &); stdio_iodev(stdio_iodev const &);
void operator=(stdio_iodev const &); void operator=(stdio_iodev const &);
public: public:
stdio_iodev(FILE *f) : stdio_iodev(FILE *f) :
file_(f) file_(f)
{ {
} }
 End of changes. 1 change blocks. 
1 lines changed or deleted 3 lines changed or added


 http_context.h   http_context.h 
skipping to change at line 135 skipping to change at line 135
std::string skin(); std::string skin();
/// ///
/// Set current views skin name /// Set current views skin name
/// ///
void skin(std::string const &name); void skin(std::string const &name);
typedef enum { typedef enum {
operation_completed, ///< Asynchronous opera tion completed successfully operation_completed, ///< Asynchronous opera tion completed successfully
operation_aborted ///< Asynchronous opera tion was canceled operation_aborted ///< Asynchronous opera tion was canceled
} complition_type; } completion_type;
typedef booster::callback<void(complition_type)> han dler; typedef booster::callback<void(completion_type)> han dler;
/// ///
/// Send all pending output data to the client and /// Send all pending output data to the client and
/// finalize the connection. Note, you can't use thi s /// finalize the connection. Note, you can't use thi s
/// object for communication any more. /// object for communication any more.
/// ///
void complete_response(); void complete_response();
/// ///
/// Send all pending output data to the client and /// Send all pending output data to the client and
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 index.h   index.h 
skipping to change at line 1090 skipping to change at line 1090
#ifdef BOOSTER_HAS_CHAR32_T #ifdef BOOSTER_HAS_CHAR32_T
typedef boundary_point_index<char32_t const *> u32cboundary_poi nt_index;///< convenience typedef typedef boundary_point_index<char32_t const *> u32cboundary_poi nt_index;///< convenience typedef
#endif #endif
} // boundary } // boundary
} // locale } // locale
} // boost } // boost
/// ///
/// \example boundary.cpp /// boundary.cpp
/// Example of using segment_index /// Example of using segment_index
/// \example wboundary.cpp /// wboundary.cpp
/// Example of using segment_index over wide strings /// Example of using segment_index over wide strings
/// ///
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 io_service.h   io_service.h 
skipping to change at line 33 skipping to change at line 33
class ptime; class ptime;
namespace aio { namespace aio {
class event_loop_impl; class event_loop_impl;
/// ///
/// \brief this is the central event loop that dispatches all reques ts. /// \brief this is the central event loop that dispatches all reques ts.
/// ///
/// This all this class member functions are thread safe unless spec ified otherwise. /// This all this class member functions are thread safe unless spec ified otherwise.
/// ///
/// Sinlge or multiple threads may execute run() member function and dispatch its handlers, this class /// However only \b single thread may execute run() member function and dispatch its handlers, this class
/// also can be safely created before fork and used after it /// also can be safely created before fork and used after it
/// ///
class BOOSTER_API io_service : public noncopyable, public io_events { class BOOSTER_API io_service : public noncopyable, public io_events {
public: public:
/// ///
/// Create io service using specific reactor type and not de fault one (see reactor's class use_* constants) /// Create io service using specific reactor type and not de fault one (see reactor's class use_* constants)
/// ///
io_service(int reactor_type); io_service(int reactor_type);
/// ///
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 json.h   json.h 
skipping to change at line 41 skipping to change at line 41
namespace cppcms { namespace cppcms {
/// ///
/// \brief This namespace includes all JSON parsing and formatting related classes and functions /// \brief This namespace includes all JSON parsing and formatting related classes and functions
/// ///
namespace json { namespace json {
class value; class value;
/// ///
/// Special object that is convertible to null json value /// \brief Special object that is convertible to null json value
/// ///
struct null {}; struct null {};
/// ///
/// Special object that is convertible to undefined json value /// \brief Special object that is convertible to undefined json valu e
/// ///
struct undefined {}; struct undefined {};
inline bool operator==(undefined const &/*l*/,undefined const &/*r*/ ) {return true;} inline bool operator==(undefined const &/*l*/,undefined const &/*r*/ ) {return true;}
inline bool operator!=(undefined const &/*l*/,undefined const &/*r*/ ) {return false;} inline bool operator!=(undefined const &/*l*/,undefined const &/*r*/ ) {return false;}
inline bool operator==(null const &/*l*/,null const &/*r*/) {return true;} inline bool operator==(null const &/*l*/,null const &/*r*/) {return true;}
inline bool operator!=(null const &/*l*/,null const &/*r*/) {return false;} inline bool operator!=(null const &/*l*/,null const &/*r*/) {return false;}
/// ///
/// The json::array - std::vector of json::value's /// \brief The json::array - std::vector of json::value's
/// ///
typedef std::vector<value> array; typedef std::vector<value> array;
/// ///
/// The json::object - std::map of json::value's /// \brief The json::object - std::map of json::value's
/// ///
typedef std::map<string_key,value> object; typedef std::map<string_key,value> object;
#ifdef CPPCMS_DOXYGEN_DOCS #ifdef CPPCMS_DOXYGEN_DOCS
/// ///
/// The type traits schema for converting json values to/from orinar y objects /// \brief The type traits schema for converting json values to/from orinary objects
/// i.e. serialization from JSON to C++ object /// i.e. serialization from JSON to C++ object
/// ///
template<typename T> template<typename T>
struct traits { struct traits {
/// ///
/// Convert json value \a v to an object of type T and retur n it /// Convert json value \a v to an object of type T and retur n it
/// ///
static T get(value const &v); static T get(value const &v);
/// ///
/// Convert an object \a in to a json::value \a v /// Convert an object \a in to a json::value \a v
skipping to change at line 143 skipping to change at line 143
/// Write json object to output stream /// Write json object to output stream
/// ///
std::ostream CPPCMS_API &operator<<(std::ostream &out,value const &v ); std::ostream CPPCMS_API &operator<<(std::ostream &out,value const &v );
/// ///
/// Write human readable representation of json_type /// Write human readable representation of json_type
/// ///
std::ostream CPPCMS_API &operator<<(std::ostream &out,json_type); std::ostream CPPCMS_API &operator<<(std::ostream &out,json_type);
/// ///
/// This class is central representation of json objects. It can be /// \brief This class is central representation of json objects.
a value from any type ///
/// including object, array and undefined /// It can be a value from any type
/// including scalar, object, array and undefined
/// ///
class CPPCMS_API value { class CPPCMS_API value {
public: public:
/// ///
/// Get the type of the value /// Get the type of the value
/// ///
json_type type() const; json_type type() const;
/// ///
 End of changes. 6 change blocks. 
8 lines changed or deleted 9 lines changed or added


 log.h   log.h 
skipping to change at line 229 skipping to change at line 229
/// ///
/// \brief This namespace includes various output devices (sinks) fo r logger. /// \brief This namespace includes various output devices (sinks) fo r logger.
/// ///
/// It includes several standard devices that can be used in most ap plications /// It includes several standard devices that can be used in most ap plications
/// ///
namespace sinks { namespace sinks {
/// ///
/// Convert a logging message to a string with all the data that can be /// Convert a logging message to a string with all the data that can be
/// written to file. /// written to file, the displayed time is local time
/// ///
BOOSTER_API std::string format_plain_text_message(message co nst &msg); BOOSTER_API std::string format_plain_text_message(message co nst &msg);
/// ///
/// stderr based sink - sends messages to standard error out /// Convert a logging message to a string with all the data
put that can be
/// written to file, the displayed time is GMT+\a timezone_o
ffset.
/// timezone_offset should be represented in seconds, for ex
ample
/// for timezone GMT+2:00 it should be 7200
///
BOOSTER_API std::string format_plain_text_message_tz(message
const &msg,int timezone_offset = 0);
///
/// \brief stderr based sink - sends messages to standard er
ror output
/// ///
class BOOSTER_API standard_error : public sink { class BOOSTER_API standard_error : public sink {
public: public:
standard_error(); standard_error();
virtual void log(message const &); virtual void log(message const &);
virtual ~standard_error(); virtual ~standard_error();
private: private:
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
}; };
/// ///
/// stderr based sink - sends messages to log file /// \brief log file based sink - sends messages to log file
/// ///
class BOOSTER_API file : public sink { class BOOSTER_API file : public sink {
public: public:
/// ///
/// Creates new object but does not open a file /// Creates new object but does not open a file
/// ///
file(); file();
virtual ~file(); virtual ~file();
/// ///
skipping to change at line 273 skipping to change at line 281
/// ///
/// Each time the log opened, the old files are rena med, if there are more files /// Each time the log opened, the old files are rena med, if there are more files
/// then \a limit, the oldest is removed /// then \a limit, the oldest is removed
/// ///
void max_files(unsigned limit); void max_files(unsigned limit);
/// ///
/// Append to output file rather then create new one . /// Append to output file rather then create new one .
/// ///
void append(); void append();
///
/// Set the time-zone name that should be used in th
e message.
///
/// It should have a format GMT+XX:YY like "GMT+2:00
" or "GMT-3".
/// "GMT" can be used as well
///
/// If name is empty local time is used which is the
default
///
void set_timezone(std::string const &name);
/// Send message to the log /// Send message to the log
virtual void log(message const &); virtual void log(message const &);
private: private:
void shift(std::string const &base); void shift(std::string const &base);
std::string format_file(std::string const &,int); std::string format_file(std::string const &,int);
unsigned max_files_; unsigned max_files_;
size_t max_size_; size_t max_size_;
size_t current_size_; size_t current_size_;
bool opened_; bool opened_;
bool append_; bool append_;
bool use_local_time_;
int tz_offset_;
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
}; };
#ifdef BOOSTER_POSIX #ifdef BOOSTER_POSIX
/// ///
/// POSIX syslog sink. /// \brief POSIX syslog sink
///
/// Available only on POSIX platforms
/// ///
class BOOSTER_API syslog : public sink { class BOOSTER_API syslog : public sink {
public: public:
/// ///
/// Create a new logger. Note: it does not call open log, if you want /// Create a new logger. Note: it does not call open log, if you want
/// to provide non-default parameters, you need to c all it on your own /// to provide non-default parameters, you need to c all it on your own
/// ///
syslog(); syslog();
/// ///
/// Send the message to the log /// Send the message to the log
 End of changes. 6 change blocks. 
5 lines changed or deleted 34 lines changed or added


 mount_point.h   mount_point.h 
skipping to change at line 29 skipping to change at line 29
#ifndef CPPCMS_MOUNT_POINT_H #ifndef CPPCMS_MOUNT_POINT_H
#define CPPCMS_MOUNT_POINT_H #define CPPCMS_MOUNT_POINT_H
#include <cppcms/defs.h> #include <cppcms/defs.h>
#include <string> #include <string>
#include <booster/perl_regex.h> #include <booster/perl_regex.h>
#include <booster/copy_ptr.h> #include <booster/copy_ptr.h>
namespace cppcms { namespace cppcms {
/// ///
/// This class represents application's mount point or the rule on w /// \brief This class represents application's mount point or the ru
hich specific application le on which specific application
/// is selected to process the query. It is used by applications_poo /// is selected to process the query.
l class for mounting applications, ///
/// It is used by applications_pool class for mounting applications,
/// and by forwarding managers to match forwarding requests /// and by forwarding managers to match forwarding requests
/// ///
class CPPCMS_API mount_point { class CPPCMS_API mount_point {
public: public:
/// ///
/// Type that describes what parameter should be passed to a pplication::main(std::string) function /// Type that describes what parameter should be passed to a pplication::main(std::string) function
/// ///
/// When the application selected specific string is passed for matching with application's member function /// When the application selected specific string is passed for matching with application's member function
/// or application's children. This can be CGI variable PATH _INFO or SCRIPT_NAME or their substring taken /// or application's children. This can be CGI variable PATH _INFO or SCRIPT_NAME or their substring taken
/// with regular expression. /// with regular expression.
 End of changes. 1 change blocks. 
4 lines changed or deleted 5 lines changed or added


 reactor.h   reactor.h 
skipping to change at line 25 skipping to change at line 25
namespace aio { namespace aio {
class reactor_impl; class reactor_impl;
/// ///
/// \brief This class is an abstraction of platform dependent pollin g API. /// \brief This class is an abstraction of platform dependent pollin g API.
/// ///
/// It abstracts platform specific APIs like epoll, /dev/poll, kqueu e, poll /// It abstracts platform specific APIs like epoll, /dev/poll, kqueu e, poll
/// and select. /// and select.
/// ///
/// It provides platform indepenent functionality for polling file d /// It provides platform independent functionality for polling file
escriptions descriptions
/// in efficient way /// in an efficient way
/// ///
class BOOSTER_API reactor : public io_events { class BOOSTER_API reactor : public io_events {
reactor(reactor const &); reactor(reactor const &);
void operator=(reactor const &); void operator=(reactor const &);
public: public:
static const int use_default = 0; //< Best polling device available on the OS static const int use_default = 0; //< Best polling device available on the OS
static const int use_select = 1; //< select() API, defau lt on Windows static const int use_select = 1; //< select() API, defau lt on Windows
static const int use_poll = 2; //< poll() API default on POSIX platforms without better polling support static const int use_poll = 2; //< poll() API default on POSIX platforms without better polling support
static const int use_epoll = 3; //< epoll() available a nd default on Linux static const int use_epoll = 3; //< epoll() available a nd default on Linux
 End of changes. 1 change blocks. 
3 lines changed or deleted 3 lines changed or added


 regex_match.h   regex_match.h 
skipping to change at line 105 skipping to change at line 105
/// ///
sub_match() : matched(false) sub_match() : matched(false)
{ {
} }
}; };
typedef sub_match<char const *> csub_match; typedef sub_match<char const *> csub_match;
typedef sub_match<std::string::const_iterator> ssub_match; typedef sub_match<std::string::const_iterator> ssub_match;
/// ///
/// The object that hold the result of matching a regular expression against the text /// \brief The object that hold the result of matching a regular exp ression against the text
/// using regex_match and regex_search functions /// using regex_match and regex_search functions
/// ///
template<typename Iterator> template<typename Iterator>
class match_results { class match_results {
public: public:
/// ///
/// Creates default empty matched result. /// Creates default empty matched result.
/// ///
match_results() match_results()
{ {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 rpc_json.h   rpc_json.h 
skipping to change at line 28 skipping to change at line 28
/////////////////////////////////////////////////////////////////////////// //// /////////////////////////////////////////////////////////////////////////// ////
#ifndef CPPCMS_RPC_JSON_OBJECT_H #ifndef CPPCMS_RPC_JSON_OBJECT_H
#define CPPCMS_RPC_JSON_OBJECT_H #define CPPCMS_RPC_JSON_OBJECT_H
#include <cppcms/application.h> #include <cppcms/application.h>
#include <booster/function.h> #include <booster/function.h>
#include <cppcms/json.h> #include <cppcms/json.h>
#include <cppcms/cppcms_error.h> #include <cppcms/cppcms_error.h>
namespace cppcms { namespace cppcms {
///
/// \brief This namespace holds API for implementing various RPC APIs, like
JsonRPC
///
namespace rpc { namespace rpc {
/// ///
/// The error thrown in case of bad call - parameters mismatch or /// \brief The error thrown in case of bad call - parameters mismatc h or
/// invalid request. /// invalid request.
/// ///
/// User should may throw it case of a error as invalid request insi de the /// User should may throw it case of a error as invalid request insi de the
/// method. However return_error() is preferred. /// method. However return_error() is preferred.
/// ///
class CPPCMS_API call_error : public cppcms_error { class CPPCMS_API call_error : public cppcms_error {
public: public:
/// ///
/// Define error message /// Define error message
/// ///
call_error(std::string const &message); call_error(std::string const &message);
}; };
class json_rpc_server; class json_rpc_server;
/// ///
/// This class represents single call of json-rpc method. It is used /// \brief This class represents single call of json-rpc method.
///
/// It is used
/// for handling asynchronous responses only. Similar API is provide d /// for handling asynchronous responses only. Similar API is provide d
/// in json_rpc_server class for synchronous methods. /// in json_rpc_server class for synchronous methods.
/// ///
class CPPCMS_API json_call : public booster::noncopyable { class CPPCMS_API json_call : public booster::noncopyable {
public: public:
/// ///
/// Destructor. Automatically deletes appropriate context as once it given to user it owns it. /// Destructor. Automatically deletes appropriate context as once it given to user it owns it.
/// ///
~json_call(); ~json_call();
skipping to change at line 114 skipping to change at line 119
json::value id_; json::value id_;
json::array params_; json::array params_;
std::string method_; std::string method_;
bool notification_; bool notification_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// ///
/// JSON-RPC service provider /// \brief JSON-RPC service application.
///
/// User is expected to derive his own objects from this class in or
der to implement Json-RPC calls
/// similarly to how cppcms::application is used.
/// ///
class CPPCMS_API json_rpc_server : public application { class CPPCMS_API json_rpc_server : public application {
public: public:
/// ///
/// The role of the method - receives notification, returns result or any one of them /// The role of the method - receives notification, returns result or any one of them
/// ///
typedef enum { typedef enum {
any_role, ///< Method may receive noti fication and return result any_role, ///< Method may receive noti fication and return result
method_role, ///< Method can't be used wi th notification calls method_role, ///< Method can't be used wi th notification calls
notification_role ///< Method should be used w ith notification calls only notification_role ///< Method should be used w ith notification calls only
skipping to change at line 205 skipping to change at line 213
typedef std::map<std::string,method_data> methods_map_type; typedef std::map<std::string,method_data> methods_map_type;
methods_map_type methods_; methods_map_type methods_;
booster::shared_ptr<json_call> current_call_; booster::shared_ptr<json_call> current_call_;
std::string smd_; std::string smd_;
struct _data; struct _data;
booster::hold_ptr<_data> d; booster::hold_ptr<_data> d;
}; };
/// \cond INTERNAL
namespace details {
template<typename T> struct fw_ret { typedef T type; };
template<typename T> struct fw_ret<T const &> { typedef T ty
pe; };
template<typename T> struct fw_ret<T const> { typedef T type
; };
template<> struct fw_ret<json::value> { typedef json::value
const &type; };
template<> struct fw_ret<json::object> { typedef json::objec
t const &type; };
template<> struct fw_ret<json::array> { typedef json::array
const &type; };
template<> struct fw_ret<std::string> { typedef std::string
const &type; };
template<> struct fw_ret<json::value const &> { typedef jso
n::value const &type; };
template<> struct fw_ret<json::object const &> { typedef jso
n::object const &type; };
template<> struct fw_ret<json::array const &> { typedef jso
n::array const &type; };
template<> struct fw_ret<std::string const &> { typedef std
::string const &type; };
template<> struct fw_ret<json::value const> { typedef json:
:value const &type; };
template<> struct fw_ret<json::object const> { typedef json:
:object const &type; };
template<> struct fw_ret<json::array const> { typedef json:
:array const &type; };
template<> struct fw_ret<std::string const> { typedef std::
string const &type; };
template<typename T>
struct fw_ret_handle {
static typename fw_ret<T>::type extract(json::value
const &v)
{
return v.get_value<typename fw_ret<T>::type>
();
}
};
template<>
struct fw_ret_handle<json::value const &>
{
static json::value const &extract(json::value const
&v)
{
return v;
}
};
template<>
struct fw_ret_handle<json::array const &>
{
static json::array const &extract(json::value const
&v)
{
return v.array();
}
};
template<>
struct fw_ret_handle<json::object const &>
{
static json::object const &extract(json::value const
&v)
{
return v.object();
}
};
template<>
struct fw_ret_handle<std::string const &>
{
static std::string const &extract(json::value const
&v)
{
return v.str();
}
};
template <typename T>
inline typename fw_ret<T>::type forward_value(json::value co
nst &v)
{
typedef typename fw_ret<T>::type return_type;
return fw_ret_handle<return_type>::extract(v);
}
}
#define CPPCMS_JSON_RPC_BINDER(N) \ #define CPPCMS_JSON_RPC_BINDER(N) \
namespace details { \ namespace details { \
template<typename Class,typename Ptr CPPCMS_TEMPLATE_PARAMS> \ template<typename Class,typename Ptr CPPCMS_TEMPLATE_PARAMS> \
struct binder##N { \ struct binder##N { \
Ptr object; \ Ptr object; \
void (Class::*member)(CPPCMS_FUNC_PARAMS); \ void (Class::*member)(CPPCMS_FUNC_PARAMS); \
void operator()(json::array const &a) const \ void operator()(json::array const &a) const \
{ \ { \
if(a.size()!=N) \ if(a.size()!=N) \
throw call_error("Invalid parametres number"); \ throw call_error("Invalid parametres number"); \
skipping to change at line 236 skipping to change at line 320
#define CPPCMS_CALL_PARAMS #define CPPCMS_CALL_PARAMS
#define CPPCMS_BINDER_PARAMS #define CPPCMS_BINDER_PARAMS
CPPCMS_JSON_RPC_BINDER(0) CPPCMS_JSON_RPC_BINDER(0)
#undef CPPCMS_TEMPLATE_PARAMS #undef CPPCMS_TEMPLATE_PARAMS
#undef CPPCMS_FUNC_PARAMS #undef CPPCMS_FUNC_PARAMS
#undef CPPCMS_CALL_PARAMS #undef CPPCMS_CALL_PARAMS
#undef CPPCMS_BINDER_PARAMS #undef CPPCMS_BINDER_PARAMS
#define CPPCMS_TEMPLATE_PARAMS ,typename P1 #define CPPCMS_TEMPLATE_PARAMS ,typename P1
#define CPPCMS_FUNC_PARAMS P1 #define CPPCMS_FUNC_PARAMS P1
#define CPPCMS_CALL_PARAMS a[0].get_value<P1>() #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0])
#define CPPCMS_BINDER_PARAMS ,P1 #define CPPCMS_BINDER_PARAMS ,P1
CPPCMS_JSON_RPC_BINDER(1) CPPCMS_JSON_RPC_BINDER(1)
#undef CPPCMS_TEMPLATE_PARAMS #undef CPPCMS_TEMPLATE_PARAMS
#undef CPPCMS_FUNC_PARAMS #undef CPPCMS_FUNC_PARAMS
#undef CPPCMS_CALL_PARAMS #undef CPPCMS_CALL_PARAMS
#undef CPPCMS_BINDER_PARAMS #undef CPPCMS_BINDER_PARAMS
#define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2 #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2
#define CPPCMS_FUNC_PARAMS P1,P2 #define CPPCMS_FUNC_PARAMS P1,P2
#define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>( ) #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2 >(a[1])
#define CPPCMS_BINDER_PARAMS ,P1,P2 #define CPPCMS_BINDER_PARAMS ,P1,P2
CPPCMS_JSON_RPC_BINDER(2) CPPCMS_JSON_RPC_BINDER(2)
#undef CPPCMS_TEMPLATE_PARAMS #undef CPPCMS_TEMPLATE_PARAMS
#undef CPPCMS_FUNC_PARAMS #undef CPPCMS_FUNC_PARAMS
#undef CPPCMS_CALL_PARAMS #undef CPPCMS_CALL_PARAMS
#undef CPPCMS_BINDER_PARAMS #undef CPPCMS_BINDER_PARAMS
#define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3
#define CPPCMS_FUNC_PARAMS P1,P2,P3 #define CPPCMS_FUNC_PARAMS P1,P2,P3
#define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>( ),a[2].get_value<P3>() #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2 >(a[1]), forward_value<P3>(a[2])
#define CPPCMS_BINDER_PARAMS ,P1,P2,P3 #define CPPCMS_BINDER_PARAMS ,P1,P2,P3
CPPCMS_JSON_RPC_BINDER(3) CPPCMS_JSON_RPC_BINDER(3)
#undef CPPCMS_TEMPLATE_PARAMS #undef CPPCMS_TEMPLATE_PARAMS
#undef CPPCMS_FUNC_PARAMS #undef CPPCMS_FUNC_PARAMS
#undef CPPCMS_CALL_PARAMS #undef CPPCMS_CALL_PARAMS
#undef CPPCMS_BINDER_PARAMS #undef CPPCMS_BINDER_PARAMS
#define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3, typename P4 #define CPPCMS_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3, typename P4
#define CPPCMS_FUNC_PARAMS P1,P2,P3,P4 #define CPPCMS_FUNC_PARAMS P1,P2,P3,P4
#define CPPCMS_CALL_PARAMS a[0].get_value<P1>(),a[1].get_value<P2>( #define CPPCMS_CALL_PARAMS forward_value<P1>(a[0]), forward_value<P2
),a[2].get_value<P3>(), \ >(a[1]), forward_value<P3>(a[2]), forward_value<P4>(a[3])
a[3].get_value<P4>()
#define CPPCMS_BINDER_PARAMS ,P1,P2,P3,P4 #define CPPCMS_BINDER_PARAMS ,P1,P2,P3,P4
CPPCMS_JSON_RPC_BINDER(4) CPPCMS_JSON_RPC_BINDER(4)
#undef CPPCMS_TEMPLATE_PARAMS #undef CPPCMS_TEMPLATE_PARAMS
#undef CPPCMS_FUNC_PARAMS #undef CPPCMS_FUNC_PARAMS
#undef CPPCMS_CALL_PARAMS #undef CPPCMS_CALL_PARAMS
#undef CPPCMS_BINDER_PARAMS #undef CPPCMS_BINDER_PARAMS
#undef CPPCMS_JSON_RPC_BINDER #undef CPPCMS_JSON_RPC_BINDER
/// \endcond
} // rpc } // rpc
} // cppcms } // cppcms
#endif #endif
 End of changes. 10 change blocks. 
9 lines changed or deleted 117 lines changed or added


 serialization_classes.h   serialization_classes.h 
skipping to change at line 34 skipping to change at line 34
#include <string> #include <string>
#include <booster/backtrace.h> #include <booster/backtrace.h>
#include <booster/traits/enable_if.h> #include <booster/traits/enable_if.h>
#include <booster/traits/is_base_of.h> #include <booster/traits/is_base_of.h>
namespace cppcms { namespace cppcms {
#ifdef CPPCMS_DOXYGEN_DOCS #ifdef CPPCMS_DOXYGEN_DOCS
/// ///
/// Special traits class that describes how to serialize various /// \brief Special traits class that describes how to serialize vari ous
/// objects that are not defived from serializable_base. /// objects that are not defived from serializable_base.
/// ///
template<typename Object> template<typename Object>
struct archive_traits struct archive_traits
{ {
/// ///
/// Save object to archive function /// Save object to archive function
/// ///
static void save(Object const &d,archive &a); static void save(Object const &d,archive &a);
/// ///
skipping to change at line 57 skipping to change at line 57
static void load(Object &d,archive &a); static void load(Object &d,archive &a);
}; };
#else #else
template<typename Object,typename Enable = void> template<typename Object,typename Enable = void>
struct archive_traits; struct archive_traits;
#endif #endif
/// ///
/// Error thrown in case of serialization error /// \brief Error thrown in case of serialization error
/// ///
class archive_error : public booster::runtime_error { class archive_error : public booster::runtime_error {
public: public:
archive_error(std::string const &e) : booster::runtime_error ("cppcms::archive_error: " + e) archive_error(std::string const &e) : booster::runtime_error ("cppcms::archive_error: " + e)
{ {
} }
}; };
/// ///
/// Class that represents a binary archive that can be stored in per sistent storage or /// \brief Class that represents a binary archive that can be stored in persistent storage or
/// transfered. /// transfered.
/// ///
class CPPCMS_API archive { class CPPCMS_API archive {
public: public:
/// ///
/// Reserve some memory before we write actual data /// Reserve some memory before we write actual data
/// ///
void reserve(size_t size); void reserve(size_t size);
skipping to change at line 167 skipping to change at line 167
std::string buffer_; std::string buffer_;
size_t ptr_; size_t ptr_;
mode_type mode_; mode_type mode_;
struct _data; struct _data;
booster::copy_ptr<_data> d; booster::copy_ptr<_data> d;
}; };
/// ///
/// Opererator that performs load or store \a object operations /// Operator that performs load or store \a object operations
/// on archive \a /// on archive \a
/// ///
template<typename Archivable> template<typename Archivable>
archive & operator &(archive &a,Archivable &object) archive & operator &(archive &a,Archivable &object)
{ {
if(a.mode() == archive::save_to_archive) if(a.mode() == archive::save_to_archive)
archive_traits<Archivable>::save(object,a); archive_traits<Archivable>::save(object,a);
else else
archive_traits<Archivable>::load(object,a); archive_traits<Archivable>::load(object,a);
return a; return a;
} }
///
/// Operator that saves an object to the archive
///
template<typename Archivable> template<typename Archivable>
archive & operator <<(archive &a,Archivable const &object) archive & operator <<(archive &a,Archivable const &object)
{ {
archive_traits<Archivable>::save(object,a); archive_traits<Archivable>::save(object,a);
return a; return a;
} }
///
/// Operator that loads an object from the archive
///
template<typename Archivable> template<typename Archivable>
archive & operator >>(archive &a,Archivable &object) archive & operator >>(archive &a,Archivable &object)
{ {
archive_traits<Archivable>::load(object,a); archive_traits<Archivable>::load(object,a);
return a; return a;
} }
/// ///
/// Base abstract class for object that can be serialized into std:: string /// \brief Base abstract class for object that can be serialized int o std::string
/// ///
class serializable_base { class serializable_base {
public: public:
/// ///
/// Load object from archive /// Load object from archive
/// ///
virtual void load(archive &serialized_object) = 0; virtual void load(archive &serialized_object) = 0;
/// ///
/// Save object to archive /// Save object to archive
/// ///
virtual void save(archive &serialized_object) const = 0; virtual void save(archive &serialized_object) const = 0;
virtual ~serializable_base() virtual ~serializable_base()
{ {
} }
}; };
/// ///
/// Abstract class for serialization object /// \brief Abstract class for serialization object
/// ///
class serializable : public serializable_base { class serializable : public serializable_base {
public: public:
/// ///
/// Abstract function that should be implemented for correct serialization /// Abstract function that should be implemented for correct serialization
/// of an object, it allows implementing only one function f or load and save instead of two. /// of an object, it allows implementing only one function f or load and save instead of two.
/// ///
/// For example: /// For example:
/// ///
skipping to change at line 260 skipping to change at line 266
/// ///
virtual void save(archive &a) const virtual void save(archive &a) const
{ {
const_cast<serializable *>(this)->serialize(a); const_cast<serializable *>(this)->serialize(a);
} }
}; };
#ifdef CPPCMS_DOXYGEN_DOCS #ifdef CPPCMS_DOXYGEN_DOCS
/// ///
/// This is the traits class for serialization traits. It allows use /// \brief This is the traits class for serialization traits.
r to use ///
/// It allows user to use
/// arbitrary serialization libraries or use its own serialization r ules, /// arbitrary serialization libraries or use its own serialization r ules,
/// for example you can use boost::serialization. /// for example you can use boost::serialization.
/// ///
/// For this purpose user should specialize the serialization_traits struct for his type. /// For this purpose user should specialize the serialization_traits struct for his type.
/// ///
/// For example: We want to allow a serialization of a point class: /// For example: We want to allow a serialization of a point class:
/// ///
/// \code /// \code
/// ///
//// namespace cppcms { //// namespace cppcms {
skipping to change at line 310 skipping to change at line 318
/// ///
static void save(Object const &real_object,std::string &seri alized_object); static void save(Object const &real_object,std::string &seri alized_object);
}; };
#else #else
template<typename Object,typename Enable = void> template<typename Object,typename Enable = void>
struct serialization_traits; struct serialization_traits;
/// ///
/// Traits for serializable objects - converts object to and from st ring /// \brief Traits for serializable objects - converts object to and from string
/// using archive class /// using archive class
/// ///
template<typename D> template<typename D>
struct serialization_traits<D,typename booster::enable_if<booster::i s_base_of<serializable_base,D> >::type> { struct serialization_traits<D,typename booster::enable_if<booster::i s_base_of<serializable_base,D> >::type> {
/// ///
/// Convert string to object /// Convert string to object
/// ///
static void load(std::string const &serialized_object,serial izable_base &real_object) static void load(std::string const &serialized_object,serial izable_base &real_object)
{ {
archive a; archive a;
 End of changes. 10 change blocks. 
9 lines changed or deleted 16 lines changed or added


 service.h   service.h 
skipping to change at line 53 skipping to change at line 53
class service; class service;
namespace cgi { namespace cgi {
class acceptor; class acceptor;
} }
} }
class applications_pool; class applications_pool;
class thread_pool; class thread_pool;
class session_pool; class session_pool;
class cache_pool; class cache_pool;
class views_pool;
class forwarder; class forwarder;
namespace json { namespace json {
class value; class value;
} }
namespace views {
class manager;
}
/// ///
/// \brief This class represent the central event loop of the CppCMS applications. /// \brief This class represent the central event loop of the CppCMS applications.
/// ///
/// This is the central class that is responsible for management of CppCMS services: management of HTTP requests and /// This is the central class that is responsible for management of CppCMS services: management of HTTP requests and
/// responses, sessions, cache and much more services. It is the cen tral class that runs during execution of any CppCMS /// responses, sessions, cache and much more services. It is the cen tral class that runs during execution of any CppCMS
/// service. /// service.
/// ///
class CPPCMS_API service : public booster::noncopyable class CPPCMS_API service : public booster::noncopyable
skipping to change at line 129 skipping to change at line 131
cppcms::applications_pool &applications_pool(); cppcms::applications_pool &applications_pool();
/// ///
/// Get a cppcms::thread_pool instance of this service /// Get a cppcms::thread_pool instance of this service
/// ///
cppcms::thread_pool &thread_pool(); cppcms::thread_pool &thread_pool();
/// ///
/// Get a cppcms::session_pool instance of this service, nev er used directly by user level applications /// Get a cppcms::session_pool instance of this service, nev er used directly by user level applications
/// ///
cppcms::session_pool &session_pool(); cppcms::session_pool &session_pool();
/// ///
/// Get the cppcms::views_pool instance, note the skins mana gement is still performed in the singleton instance of cppcms::views_pool /// Get the cppcms::views::manager instance
/// ///
cppcms::views_pool &views_pool(); cppcms::views::manager &views_pool();
/// ///
/// Get the cppcms::cache_pool instance of this service, nev er used directly by user level applications /// Get the cppcms::cache_pool instance of this service, nev er used directly by user level applications
/// ///
cppcms::cache_pool &cache_pool(); cppcms::cache_pool &cache_pool();
/// ///
/// Get cppcms::forwarder instance of this service /// Get cppcms::forwarder instance of this service
/// ///
cppcms::forwarder &forwarder(); cppcms::forwarder &forwarder();
/// ///
 End of changes. 4 change blocks. 
3 lines changed or deleted 5 lines changed or added


 session_cookies.h   session_cookies.h 
skipping to change at line 83 skipping to change at line 83
/// ///
virtual std::auto_ptr<encryptor> get() = 0; virtual std::auto_ptr<encryptor> get() = 0;
/// ///
/// Destructor - cleanup everything /// Destructor - cleanup everything
/// ///
virtual ~encryptor_factory() {} virtual ~encryptor_factory() {}
}; };
/// ///
/// The implementation of session_api using encrypted or signed cook ies /// \brief The implementation of session_api using encrypted or sign ed cookies
/// ///
class CPPCMS_API session_cookies : public session_api { class CPPCMS_API session_cookies : public session_api {
public: public:
/// ///
/// Create a new object passing it a pointer ecryptor as par ameter /// Create a new object passing it a pointer ecryptor as par ameter
/// ///
session_cookies(std::auto_ptr<encryptor> encryptor); session_cookies(std::auto_ptr<encryptor> encryptor);
/// ///
/// Destroy it and destroy an encryptor it was created with /// Destroy it and destroy an encryptor it was created with
/// ///
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 session_storage.h   session_storage.h 
skipping to change at line 28 skipping to change at line 28
/////////////////////////////////////////////////////////////////////////// //// /////////////////////////////////////////////////////////////////////////// ////
#ifndef CPPCMS_SESSION_STORAGE_H #ifndef CPPCMS_SESSION_STORAGE_H
#define CPPCMS_SESSION_STORAGE_H #define CPPCMS_SESSION_STORAGE_H
#include <cppcms/defs.h> #include <cppcms/defs.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
#include <booster/shared_ptr.h> #include <booster/shared_ptr.h>
#include <string> #include <string>
namespace cppcms { namespace cppcms {
namespace json {
class value;
}
namespace sessions { namespace sessions {
/// ///
/// \a session_server_storage is an abstract class that allows user to implements /// \brief session_server_storage is an abstract class that allows u ser to implements
/// custom session storage device like, database storage device /// custom session storage device like, database storage device
/// ///
/// Note: if the member functions save/load/remove are thread safe - - can be called /// Note: if the member functions save/load/remove are thread safe - - can be called
/// from different threads, than you may create a single session and return \a shared_ptr /// from different threads, than you may create a single session and return \a shared_ptr
/// to a single instance, otherwise you have to create multiple inst ances of object /// to a single instance, otherwise you have to create multiple inst ances of object
/// ///
class session_storage : public booster::noncopyable class session_storage : public booster::noncopyable
{ {
public: public:
skipping to change at line 99 skipping to change at line 102
/// Actual garbage collection job (if required). If requires _gc returns true it will be called once-in-a-while to remove /// Actual garbage collection job (if required). If requires _gc returns true it will be called once-in-a-while to remove
/// all expired objects from the DB. /// all expired objects from the DB.
/// ///
virtual void gc_job() {} virtual void gc_job() {}
/// ///
/// Delete the object, cleanup /// Delete the object, cleanup
/// ///
virtual ~session_storage_factory() {} virtual ~session_storage_factory() {}
}; };
extern "C" {
typedef session_storage_factory *(*cppcms_session_storage_ge
nerator_type)(cppcms::json::value const &options);
}
} // sessions } // sessions
} // cppcms } // cppcms
#endif #endif
 End of changes. 3 change blocks. 
1 lines changed or deleted 9 lines changed or added


 steal_buf.h   steal_buf.h 
skipping to change at line 123 skipping to change at line 123
private: private:
void init() void init()
{ {
on_heap_ = 0; on_heap_ = 0;
setp(on_stack_,on_stack_+OnStackSize); setp(on_stack_,on_stack_+OnStackSize);
} }
char *on_heap_; char *on_heap_;
char on_stack_[OnStackSize + 1]; char on_stack_[OnStackSize + 1];
}; };
///
/// \brief This is a special buffer that allows to "steal" some chun
k
/// of text from the output stream.
///
/// It does this by replacing stream's streambuf object with tempora
ry
/// stream buffer that records all data written to the stream and th
en
/// returns the original buffer upon call to release() member functi
on
/// it steal_buffer destruction.
///
/// The \a Size parameter defines the default chunk of memory alloca
ted
/// on the stack before heap is used.
///
template<size_t Size = 128> template<size_t Size = 128>
class steal_buffer : public stackbuf<Size> { class steal_buffer : public stackbuf<Size> {
public: public:
///
/// Create the buffer and "Steal" the buffer from \a out
///
steal_buffer(std::ostream &out) steal_buffer(std::ostream &out)
{ {
stolen_ = 0; stolen_ = 0;
stream_ = 0; stream_ = 0;
steal(out); steal(out);
} }
///
/// Create an empty buffer
///
steal_buffer() steal_buffer()
{ {
stolen_ = 0; stolen_ = 0;
stream_ = 0; stream_ = 0;
} }
///
/// Steal the buffer from \a out
///
void steal(std::ostream &out) void steal(std::ostream &out)
{ {
release(); release();
stolen_ = out.rdbuf(this); stolen_ = out.rdbuf(this);
stream_ = &out; stream_ = &out;
} }
///
/// Release the "stolen" buffer back, now the buffer contain
s all
/// the data that was recorded.
///
void release() void release()
{ {
if(stream_ && stolen_) { if(stream_ && stolen_) {
stream_->rdbuf(stolen_); stream_->rdbuf(stolen_);
} }
stream_ = 0; stream_ = 0;
stolen_ = 0; stolen_ = 0;
} }
~steal_buffer() ~steal_buffer()
{ {
release(); release();
} }
private: private:
std::streambuf *stolen_; std::streambuf *stolen_;
std::ostream *stream_; std::ostream *stream_;
}; };
///
/// \brief Fast output stream object.
///
/// This is a special ostream that uses stack in order
/// to receive the data and faster then std::stringstream for
/// small chunks, also it is not limited for any particular size.
///
template<size_t Size = 128> template<size_t Size = 128>
class stackstream : public std::ostream { class stackstream : public std::ostream {
public: public:
///
/// Create a new stackstream
///
stackstream() : std::ostream(0) stackstream() : std::ostream(0)
{ {
rbbuf(&buf_); rbbuf(&buf_);
} }
///
/// Get the pointer to the first character in the range
///
char *begin() char *begin()
{ {
return buf_->begin(); return buf_->begin();
} }
///
/// Get the pointer to the one past last character in the ra
nge
///
char *end() char *end()
{ {
return buf_->end(); return buf_->end();
} }
///
/// Get a NUL terminated recorded string
///
char *c_str() char *c_str()
{ {
return buf_.c_str(); return buf_.c_str();
} }
///
/// Get a recorded string
///
std::string str() std::string str()
{ {
return buf_.str(); return buf_.str();
} }
private: private:
stackbuf<Size> buf_; stackbuf<Size> buf_;
}; };
} // util } // util
} // cppcms } // cppcms
 End of changes. 11 change blocks. 
0 lines changed or deleted 54 lines changed or added


 stream_socket.h   stream_socket.h 
skipping to change at line 25 skipping to change at line 25
#include <booster/aio/endpoint.h> #include <booster/aio/endpoint.h>
#include <booster/aio/basic_io_device.h> #include <booster/aio/basic_io_device.h>
#include <booster/aio/basic_socket.h> #include <booster/aio/basic_socket.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class mutable_buffer; class mutable_buffer;
class const_buffer; class const_buffer;
class io_service; class io_service;
///
/// \brief This object represents a stream socket: TCP/IP IPv4 or IP
v6 or Unix domain
/// stream socket
///
class BOOSTER_API stream_socket : public basic_socket { class BOOSTER_API stream_socket : public basic_socket {
public: public:
///
/// Shutdown option type
///
typedef enum { typedef enum {
shut_rd,shut_wr,shut_rdwr shut_rd, //< Shutdown read operations
shut_wr, //< Shutdown write operations
shut_rdwr //< Shutdown both read and write operation
s
} how_type; } how_type;
///
/// Create a new (closed) stream socket
///
stream_socket(); stream_socket();
///
/// Create a new (closed) stream socket and attach the objec
t to \ref io_service \a srv
///
stream_socket(io_service &srv); stream_socket(io_service &srv);
~stream_socket(); ~stream_socket();
///
/// Opens a new stream socket of a \ref family_type \a d
///
/// Throws system::system_error if error occurs.
///
void open(family_type d); void open(family_type d);
///
/// Opens a new stream socket of a \ref family_type \a d
///
/// If a error occurs it is assigned to \a e.
///
void open(family_type d,system::error_code &e); void open(family_type d,system::error_code &e);
///
/// Notify the other side on connection shutdown of a type \
a h
///
/// Throws system::system_error if error occurs.
///
void shutdown(how_type h); void shutdown(how_type h);
///
/// Notify the other side on connection shutdown of a type \
a h
///
/// If a error occurs it is assigned to \a e.
///
void shutdown(how_type h,system::error_code &e); void shutdown(how_type h,system::error_code &e);
void connect(endpoint const &); ///
void connect(endpoint const &,system::error_code &e); /// Connect to the remote endpoint \a ep
void async_connect(endpoint const &,event_handler const &h); ///
/// Throws system::system_error if error occurs.
///
void connect(endpoint const &ep);
///
/// Connect to the remote endpoint \a ep
///
/// If a error occurs it is assigned to \a e.
///
void connect(endpoint const &ep,system::error_code &e);
///
/// Connect asynchronously to the remote endpoint \a ep.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_connect(endpoint const &ep,event_handler const &h
);
///
/// Read from the socket to the \a buffer. Returns the numbe
r of bytes transfered
///
/// Throws system::system_error if error occurs.
///
size_t read_some(mutable_buffer const &buffer); size_t read_some(mutable_buffer const &buffer);
///
/// Read from the socket to the \a buffer. Returns the numbe
r of bytes transfered
///
/// If a error occurs it is assigned to \a e.
///
size_t read_some(mutable_buffer const &buffer,system::error_ code &e); size_t read_some(mutable_buffer const &buffer,system::error_ code &e);
///
/// Write to the socket from the \a buffer. Returns the numb
er of bytes transfered
///
/// Throws system::system_error if error occurs.
///
size_t write_some(const_buffer const &buffer); size_t write_some(const_buffer const &buffer);
///
/// Write to the socket from the \a buffer. Returns the numb
er of bytes transfered
///
/// If a error occurs it is assigned to \a e.
///
size_t write_some(const_buffer const &buffer,system::error_c ode &e); size_t write_some(const_buffer const &buffer,system::error_c ode &e);
///
/// Read from the socket to the \a buffer until all required
data is transferred.
/// Returns the number of bytes transfered
///
/// Throws system::system_error if error occurs.
///
size_t read(mutable_buffer const &buffer); size_t read(mutable_buffer const &buffer);
///
/// Write to the socket from the \a buffer until all require
d data is transferred.
/// Returns the number of bytes transfered
///
/// Throws system::system_error if error occurs.
///
size_t write(const_buffer const &buffer); size_t write(const_buffer const &buffer);
///
/// Read from the socket to the \a buffer until all required
data is transferred.
/// Returns the number of bytes transfered
///
/// If a error occurs it is assigned to \a e.
///
size_t read(mutable_buffer const &buffer,system::error_code &e); size_t read(mutable_buffer const &buffer,system::error_code &e);
///
/// Write to the socket from the \a buffer until all require
d data is transferred.
/// Returns the number of bytes transfered
///
/// If a error occurs it is assigned to \a e.
///
size_t write(const_buffer const &buffer,system::error_code & e); size_t write(const_buffer const &buffer,system::error_code & e);
///
/// Read asynchronously from the socket to the \a buffer.
///
/// The error and the amount of bytes that are transfered ar
e reported via callback.
/// During the operation the buffers (the data range it poin
ts to) must remain valid.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_read_some(mutable_buffer const &buffer,io_handler const &h); void async_read_some(mutable_buffer const &buffer,io_handler const &h);
///
/// Write asynchronously to the socket from the \a buffer.
///
/// The error and the amount of bytes that are transfered ar
e reported via callback.
/// During the operation the buffers (the data range it poin
ts to) must remain valid.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_write_some(const_buffer const &buffer,io_handler const &h); void async_write_some(const_buffer const &buffer,io_handler const &h);
///
/// Read asynchronously from the socket to the \a buffer unt
il all required mount of data is transfered.
///
/// The error and the amount of bytes that are transfered ar
e reported via callback.
/// During the operation the buffers (the data range it poin
ts to) must remain valid.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_read(mutable_buffer const &buffer,io_handler cons t &h); void async_read(mutable_buffer const &buffer,io_handler cons t &h);
///
/// Write asynchronously to the socket from the \a buffer un
til all required mount of data is transfered.
///
/// The error and the amount of bytes that are transfered ar
e reported via callback.
/// During the operation the buffers (the data range it poin
ts to) must remain valid.
///
/// If io_service is not assigned throws system::system_erro
r, all other errors reported via
/// the callback \a h.
///
void async_write(const_buffer const &buffer,io_handler const &h); void async_write(const_buffer const &buffer,io_handler const &h);
private: private:
int readv(mutable_buffer const &b); int readv(mutable_buffer const &b);
int writev(const_buffer const &b); int writev(const_buffer const &b);
struct data; struct data;
hold_ptr<data> d; hold_ptr<data> d;
}; };
 End of changes. 22 change blocks. 
4 lines changed or deleted 164 lines changed or added


 string_key.h   string_key.h 
skipping to change at line 29 skipping to change at line 29
#ifndef CPPCMS_STRING_KEY_H #ifndef CPPCMS_STRING_KEY_H
#define CPPCMS_STRING_KEY_H #define CPPCMS_STRING_KEY_H
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#include <ostream> #include <ostream>
namespace cppcms { namespace cppcms {
///
/// \brief This is a special object that may hold an std::string or
/// alternatively reference to external (unowned) chunk of text
///
/// It is designed to be used for efficiency and reduce amount of
/// memory allocations and copies.
///
/// It has interface that is roughly similar to the interface of std
::string,
/// but it does not provide a members that can mutate it or provide
a NUL terminated
/// string c_str().
///
class string_key { class string_key {
public: public:
///
/// Iterator type
///
typedef char const *const_iterator; typedef char const *const_iterator;
///
/// The last position of the character in the string
///
static const size_t npos = -1; static const size_t npos = -1;
///
/// Default constructor - empty key
///
string_key() : string_key() :
begin_(0), begin_(0),
end_(0) end_(0)
{ {
} }
///
/// Create a new string copying the \a key
///
string_key(char const *key) : string_key(char const *key) :
begin_(0), begin_(0),
end_(0), end_(0),
key_(key) key_(key)
{ {
} }
///
/// Create a new string copying the \a key
///
string_key(std::string const &key) : string_key(std::string const &key) :
begin_(0), begin_(0),
end_(0), end_(0),
key_(key) key_(key)
{ {
} }
///
/// String size in bytes
///
size_t size() const size_t size() const
{ {
return end() - begin(); return end() - begin();
} }
///
/// Same as size()
///
size_t length() const size_t length() const
{ {
return size(); return size();
} }
///
/// Clear the string
///
void clear() void clear()
{ {
begin_ = end_ = 0; begin_ = end_ = 0;
key_.clear(); key_.clear();
} }
///
/// Check if the string is empty
///
bool empty() const bool empty() const
{ {
return end() == begin(); return end() == begin();
} }
///
/// Find first occurrence of a character \c in the string st
arting from
/// position \a pos. Returns npos if not character found.
///
size_t find(char c,size_t pos = 0) const size_t find(char c,size_t pos = 0) const
{ {
size_t s = size(); size_t s = size();
if(pos >= s) if(pos >= s)
return npos; return npos;
char const *p=begin() + pos; char const *p=begin() + pos;
while(pos <= s && *p!=c) { while(pos <= s && *p!=c) {
pos++; pos++;
p++; p++;
} }
if(pos >= s) if(pos >= s)
return npos; return npos;
return pos; return pos;
} }
///
/// Create a substring from this string starting from charac
ter \a pos of size at most \a n
///
string_key substr(size_t pos = 0,size_t n=npos) const string_key substr(size_t pos = 0,size_t n=npos) const
{ {
string_key tmp = unowned_substr(pos,n); string_key tmp = unowned_substr(pos,n);
return string_key(std::string(tmp.begin(),tmp.end()) ); return string_key(std::string(tmp.begin(),tmp.end()) );
} }
///
/// Create a substring from this string starting from charac
ter \a pos of size at most \a n
/// such that the memory is not copied but only reference by
the created substring
///
string_key unowned_substr(size_t pos = 0,size_t n=npos) cons t string_key unowned_substr(size_t pos = 0,size_t n=npos) cons t
{ {
if(pos >= size()) { if(pos >= size()) {
return string_key(); return string_key();
} }
char const *p=begin() + pos; char const *p=begin() + pos;
char const *e=end(); char const *e=end();
if(n > size_t(e-p)) { if(n > size_t(e-p)) {
return string_key(p,e); return string_key(p,e);
} }
else { else {
return string_key(p,p+n); return string_key(p,p+n);
} }
} }
///
/// Get a character at position \a n
///
char const &operator[](size_t n) const char const &operator[](size_t n) const
{ {
return *(begin() + n); return *(begin() + n);
} }
///
/// Get a character at position \a n, if \a n is not valid p
osition, throws std::out_of_range exception
///
char const &at(size_t n) const char const &at(size_t n) const
{ {
if(n > size()) if(n > size())
throw std::out_of_range("cppcms::string_key: :at() range error"); throw std::out_of_range("cppcms::string_key: :at() range error");
return *(begin() + n); return *(begin() + n);
} }
///
/// Create a string from \a v without copying the memory. \a
v should remain valid
/// as long as this object is used
///
static string_key unowned(std::string const &v) static string_key unowned(std::string const &v)
{ {
return string_key(v.c_str(),v.c_str()+v.size()); return string_key(v.c_str(),v.c_str()+v.size());
} }
///
/// Create a string from \a str without copying the memory.
\a str should remain valid
/// as long as this object is used
///
static string_key unowned(char const *str) static string_key unowned(char const *str)
{ {
char const *end = str; char const *end = str;
while(*end) while(*end)
end++; end++;
return string_key(str,end); return string_key(str,end);
} }
///
/// Create a string from \a characters at rang [begin,end) w
ithout copying the memory.
/// The range should remain valid as long as this object is
used
///
static string_key unowned(char const *begin,char const *end) static string_key unowned(char const *begin,char const *end)
{ {
return string_key(begin,end); return string_key(begin,end);
} }
///
/// Get a pointer to the first character in the string
///
char const *begin() const char const *begin() const
{ {
if(begin_) if(begin_)
return begin_; return begin_;
return key_.c_str(); return key_.c_str();
} }
///
/// Get a pointer to the one past last character in the stri
ng
///
char const *end() const char const *end() const
{ {
if(begin_) if(begin_)
return end_; return end_;
return key_.c_str() + key_.size(); return key_.c_str() + key_.size();
} }
///
/// Compare two strings
///
bool operator<(string_key const &other) const bool operator<(string_key const &other) const
{ {
return std::lexicographical_compare( begin(),end( ), return std::lexicographical_compare( begin(),end( ),
other.begin( ),other.end(), other.begin( ),other.end(),
std::char_tr aits<char>::lt); std::char_tr aits<char>::lt);
} }
///
/// Compare two strings
///
bool operator>(string_key const &other) const bool operator>(string_key const &other) const
{ {
return other < *this; return other < *this;
} }
///
/// Compare two strings
///
bool operator>=(string_key const &other) const bool operator>=(string_key const &other) const
{ {
return !(*this < other); return !(*this < other);
} }
///
/// Compare two strings
///
bool operator<=(string_key const &other) const bool operator<=(string_key const &other) const
{ {
return !(*this > other); return !(*this > other);
} }
///
/// Compare two strings
///
bool operator==(string_key const &other) const bool operator==(string_key const &other) const
{ {
return (end() - begin() == other.end() - other.begin ()) return (end() - begin() == other.end() - other.begin ())
&& memcmp(begin(),other.begin(),end()-begin( )) == 0; && memcmp(begin(),other.begin(),end()-begin( )) == 0;
} }
///
/// Compare two strings
///
bool operator!=(string_key const &other) const bool operator!=(string_key const &other) const
{ {
return !(*this!=other); return !(*this!=other);
} }
///
/// Get the pointer to the first character in the string. No
te it should not be NUL terminated
///
char const *data() const char const *data() const
{ {
return begin(); return begin();
} }
///
/// Create std::string from the key
///
std::string str() const std::string str() const
{ {
if(begin_) if(begin_)
return std::string(begin_,end_-begin_); return std::string(begin_,end_-begin_);
else else
return key_; return key_;
} }
///
/// Convert the key to the std::string
///
operator std::string() const operator std::string() const
{ {
return str(); return str();
} }
private: private:
string_key(char const *b,char const *e) : string_key(char const *b,char const *e) :
begin_(b), begin_(b),
end_(e) end_(e)
{ {
} }
char const *begin_; char const *begin_;
char const *end_; char const *end_;
std::string key_; std::string key_;
}; };
///
/// Write the string to the stream
///
inline std::ostream &operator<<(std::ostream &out,string_key const & s) inline std::ostream &operator<<(std::ostream &out,string_key const & s)
{ {
out.write(s.data(),s.size()); out.write(s.data(),s.size());
return out; return out;
} }
///
/// Compare two strings
///
inline bool operator==(string_key const &l,char const *r) inline bool operator==(string_key const &l,char const *r)
{ {
return l==string_key::unowned(r); return l==string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator==(char const *l,string_key const &r) inline bool operator==(char const *l,string_key const &r)
{ {
return string_key::unowned(l) == r; return string_key::unowned(l) == r;
} }
///
/// Compare two strings
///
inline bool operator==(string_key const &l,std::string const &r) inline bool operator==(string_key const &l,std::string const &r)
{ {
return l==string_key::unowned(r); return l==string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator==(std::string const &l,string_key const &r) inline bool operator==(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) == r; return string_key::unowned(l) == r;
} }
///
/// Compare two strings
///
inline bool operator!=(string_key const &l,char const *r) inline bool operator!=(string_key const &l,char const *r)
{ {
return l!=string_key::unowned(r); return l!=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator!=(char const *l,string_key const &r) inline bool operator!=(char const *l,string_key const &r)
{ {
return string_key::unowned(l) != r; return string_key::unowned(l) != r;
} }
///
/// Compare two strings
///
inline bool operator!=(string_key const &l,std::string const &r) inline bool operator!=(string_key const &l,std::string const &r)
{ {
return l!=string_key::unowned(r); return l!=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator!=(std::string const &l,string_key const &r) inline bool operator!=(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) != r; return string_key::unowned(l) != r;
} }
///
/// Compare two strings
///
inline bool operator<=(string_key const &l,char const *r) inline bool operator<=(string_key const &l,char const *r)
{ {
return l<=string_key::unowned(r); return l<=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator<=(char const *l,string_key const &r) inline bool operator<=(char const *l,string_key const &r)
{ {
return string_key::unowned(l) <= r; return string_key::unowned(l) <= r;
} }
///
/// Compare two strings
///
inline bool operator<=(string_key const &l,std::string const &r) inline bool operator<=(string_key const &l,std::string const &r)
{ {
return l<=string_key::unowned(r); return l<=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator<=(std::string const &l,string_key const &r) inline bool operator<=(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) <= r; return string_key::unowned(l) <= r;
} }
///
/// Compare two strings
///
inline bool operator>=(string_key const &l,char const *r) inline bool operator>=(string_key const &l,char const *r)
{ {
return l>=string_key::unowned(r); return l>=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator>=(char const *l,string_key const &r) inline bool operator>=(char const *l,string_key const &r)
{ {
return string_key::unowned(l) >= r; return string_key::unowned(l) >= r;
} }
///
/// Compare two strings
///
inline bool operator>=(string_key const &l,std::string const &r) inline bool operator>=(string_key const &l,std::string const &r)
{ {
return l>=string_key::unowned(r); return l>=string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator>=(std::string const &l,string_key const &r) inline bool operator>=(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) >= r; return string_key::unowned(l) >= r;
} }
///
/// Compare two strings
///
inline bool operator<(string_key const &l,char const *r) inline bool operator<(string_key const &l,char const *r)
{ {
return l<string_key::unowned(r); return l<string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator<(char const *l,string_key const &r) inline bool operator<(char const *l,string_key const &r)
{ {
return string_key::unowned(l) < r; return string_key::unowned(l) < r;
} }
///
/// Compare two strings
///
inline bool operator<(string_key const &l,std::string const &r) inline bool operator<(string_key const &l,std::string const &r)
{ {
return l<string_key::unowned(r); return l<string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator<(std::string const &l,string_key const &r) inline bool operator<(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) < r; return string_key::unowned(l) < r;
} }
///
/// Compare two strings
///
inline bool operator>(string_key const &l,char const *r) inline bool operator>(string_key const &l,char const *r)
{ {
return l>string_key::unowned(r); return l>string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator>(char const *l,string_key const &r) inline bool operator>(char const *l,string_key const &r)
{ {
return string_key::unowned(l) > r; return string_key::unowned(l) > r;
} }
///
/// Compare two strings
///
inline bool operator>(string_key const &l,std::string const &r) inline bool operator>(string_key const &l,std::string const &r)
{ {
return l>string_key::unowned(r); return l>string_key::unowned(r);
} }
///
/// Compare two strings
///
inline bool operator>(std::string const &l,string_key const &r) inline bool operator>(std::string const &l,string_key const &r)
{ {
return string_key::unowned(l) > r; return string_key::unowned(l) > r;
} }
} }
#endif #endif
 End of changes. 54 change blocks. 
2 lines changed or deleted 189 lines changed or added


 system_error.h   system_error.h 
skipping to change at line 24 skipping to change at line 24
#include <booster/config.h> #include <booster/config.h>
namespace booster { namespace booster {
/// ///
/// \brief this namespace includes partial implementation of std::tr1's/boo st's system_error, error_code /// \brief this namespace includes partial implementation of std::tr1's/boo st's system_error, error_code
/// classes /// classes
/// ///
namespace system { namespace system {
///
/// \brief this class represents a category of errors.
///
/// Technically it allows to convert a numerical error representatio
n to
/// human readable error message.
///
/// This class is just an interface that should be implemented for e
ach
/// specific category
///
class error_category { class error_category {
public: public:
virtual ~error_category() virtual ~error_category()
{ {
} }
///
/// The name of the category
///
virtual char const *name() const = 0; virtual char const *name() const = 0;
///
/// Convert the error code representation to the human reada
ble text
///
virtual std::string message(int ev) const = 0; virtual std::string message(int ev) const = 0;
bool operator==(error_category const &other) const bool operator==(error_category const &other) const
{ {
return this==&other; return this==&other;
} }
bool operator!=(error_category const &other) const bool operator!=(error_category const &other) const
{ {
return this!=&other; return this!=&other;
} }
bool operator<(error_category const &other) const bool operator<(error_category const &other) const
{ {
skipping to change at line 59 skipping to change at line 76
#ifdef BOOSTER_WIN32 #ifdef BOOSTER_WIN32
BOOSTER_API error_category const &get_windows_category(); BOOSTER_API error_category const &get_windows_category();
static const error_category &windows_category = get_system_category( ); static const error_category &windows_category = get_system_category( );
#endif #endif
#ifdef BOOSTER_POSIX #ifdef BOOSTER_POSIX
BOOSTER_API error_category const &get_posix_category(); BOOSTER_API error_category const &get_posix_category();
static const error_category &posix_category = get_system_category(); static const error_category &posix_category = get_system_category();
#endif #endif
///
/// \brief The lightweight object that carries a error code informat
ion and its
/// category.
///
/// It is a pair: an integer code and a reference to the error_categ
ory object.
///
class error_code { class error_code {
public: public:
///
/// Create an empty error object - no error
///
error_code() : error_code() :
value_(0), value_(0),
category_(&system_category) category_(&system_category)
{ {
} }
///
/// Create a error object withing specific category \a cat w
ith code \a val
///
error_code(int val,error_category const &cat) : error_code(int val,error_category const &cat) :
value_(val), value_(val),
category_(&cat) category_(&cat)
{ {
} }
///
/// Get the numeric code of the error
///
int value() const int value() const
{ {
return value_; return value_;
} }
///
/// Get the reference to the specific category
///
const error_category &category() const const error_category &category() const
{ {
return *category_; return *category_;
} }
///
/// Convert the error code to the human readable string
///
std::string message() const std::string message() const
{ {
return std::string(category_->name()) + ": " + categ ory_->message(value_); return std::string(category_->name()) + ": " + categ ory_->message(value_);
} }
///
/// Convert to bool - returns true of it is a error and fals
e if it is not (value()==0)
///
operator bool () const operator bool () const
{ {
return value() != 0; return value() != 0;
} }
private: private:
int value_; int value_;
error_category const *category_; error_category const *category_;
}; };
///
/// Compare two error code for equality
///
inline bool operator==(error_code const &left,error_code const &righ t) inline bool operator==(error_code const &left,error_code const &righ t)
{ {
return left.value() == right.value() && left.category() == r ight.category(); return left.value() == right.value() && left.category() == r ight.category();
} }
///
/// Compare two error code for inequality
///
inline bool operator!=(error_code const &left,error_code const &righ t) inline bool operator!=(error_code const &left,error_code const &righ t)
{ {
return !(left==right); return !(left==right);
} }
///
/// \brief This is the object that should be thrown in case of the e
rror.
///
/// It consists
/// of two parts: the error_code object and the optional error messa
ge that would
/// be added to the error code itself.
///
class system_error : public booster::runtime_error { class system_error : public booster::runtime_error {
public: public:
///
/// Create a system error from error_code \a e
///
system_error(error_code const &e) : system_error(error_code const &e) :
booster::runtime_error(e.message()), booster::runtime_error(e.message()),
error_(e) error_(e)
{ {
} }
///
/// Create a system error from error_code \a e and additiona
l message
///
system_error(error_code const &e,std::string const &message) : system_error(error_code const &e,std::string const &message) :
booster::runtime_error(e.message()+": " + message), booster::runtime_error(e.message()+": " + message),
error_(e) error_(e)
{ {
} }
///
/// Create a system error from error_code \a e and an additi
onal message \a message
///
system_error(error_code const &e,char const *message) :
booster::runtime_error(e.message()+": " + message),
error_(e)
{
}
///
/// Create a system error from error_code defined by integer
code \a ev, a error category
/// \a category and an additional message \a message
///
system_error(int ev,error_category const &category,char cons
t *message) :
booster::runtime_error(
std::string(category.name())
+ ": " + category.message(ev)
+ ": " + message
),
error_(ev,category)
{
}
///
/// Create a system error from error_code defined by integer
code \a ev, a error category
/// \a category and an additional message \a message
///
system_error(int ev,error_category const &category,std::stri
ng const &message) :
booster::runtime_error(
std::string(category.name())
+ ": " + category.message(ev)
+ ": " + message
),
error_(ev,category)
{
}
///
/// Create a system error from error_code defined by integer
code \a ev, a error category
/// \a category
///
system_error(int ev,error_category const &category) :
booster::runtime_error(
std::string(category.name())
+ ": " + category.message(ev)
),
error_(ev,category)
{
}
///
/// Get the error code for the thrown error
///
error_code const &code() const error_code const &code() const
{ {
return error_; return error_;
} }
private: private:
error_cod