@@ -115,7 +115,7 @@ FULL_PATH_NAMES = YES | |||
# If left blank the directory from which doxygen is run is used as the | |||
# path to strip. | |||
STRIP_FROM_PATH = . | |||
STRIP_FROM_PATH = . booster noicu | |||
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of | |||
# the path mentioned in the documentation of a class, which tells | |||
@@ -418,7 +418,8 @@ WARNINGS = YES | |||
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will | |||
# automatically be disabled. | |||
WARN_IF_UNDOCUMENTED = YES | |||
#WARN_IF_UNDOCUMENTED = YES | |||
WARN_IF_UNDOCUMENTED = NO | |||
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for | |||
# potential errors in the documentation, such as not documenting some | |||
@@ -459,7 +460,7 @@ WARN_LOGFILE = | |||
# directories like "/usr/src/myproject". Separate the files or directories | |||
# with spaces. | |||
INPUT = cppcms | |||
INPUT = cppcms booster/booster booster/booster/aio booster/booster/locale booster/booster/nowide noicu/cppcms | |||
# If the value of the INPUT tag contains directories, you can use the | |||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp | |||
@@ -1012,7 +1013,7 @@ INCLUDE_FILE_PATTERNS = | |||
# undefined via #undef or recursively expanded use the := operator | |||
# instead of the = operator. | |||
PREDEFINED = CPPCMS_DOXYGEN_DOCS | |||
PREDEFINED = CPPCMS_DOXYGEN_DOCS CPPCMS_HAVE_ICU BOOSTER_DOXYGEN_DOCS | |||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then | |||
# this tag can be used to specify a list of macro names that should be expanded. | |||
@@ -14,6 +14,9 @@ | |||
namespace booster { | |||
namespace aio { | |||
/// | |||
/// \brief This namespace includes Booster.Aio specific error codes | |||
/// | |||
namespace aio_error { | |||
enum { | |||
ok, | |||
@@ -18,6 +18,11 @@ namespace booster { | |||
namespace system { | |||
class error_code; | |||
} | |||
/// | |||
/// \brief This namespace povides and API to asynchronous sockets API | |||
/// | |||
namespace aio { | |||
class endpoint; | |||
class socket; | |||
@@ -10,6 +10,11 @@ | |||
#include <booster/config.h> | |||
/// | |||
/// \brief Booster library namespace. The library that implements Boost Like API | |||
/// in ABI backward compatible way | |||
/// | |||
namespace booster { | |||
/// | |||
@@ -30,6 +30,9 @@ namespace booster | |||
# pragma option push -pc | |||
#endif | |||
/// | |||
/// An exeption that is throws in case of creating of shared_ptr from expired weak_ptr | |||
/// | |||
class bad_weak_ptr: public std::exception | |||
{ | |||
public: | |||
@@ -18,6 +18,8 @@ | |||
namespace booster | |||
{ | |||
/// \cond INTERNAL | |||
// verify that types are complete for increased safety | |||
template<class T> inline void checked_delete(T * x) | |||
@@ -57,7 +59,7 @@ template<class T> struct checked_array_deleter | |||
booster::checked_array_delete(x); | |||
} | |||
}; | |||
/// \endcond | |||
} // namespace boost | |||
#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED |
@@ -21,6 +21,12 @@ | |||
namespace booster | |||
{ | |||
/// | |||
/// \brief This class is borrowed from boost | |||
/// | |||
/// For details see: http://www.boost.org/doc/libs/release/libs/smart_ptr | |||
/// | |||
template<class T> class enable_shared_from_this | |||
{ | |||
protected: | |||
@@ -23,6 +23,82 @@ namespace booster { | |||
} | |||
}; | |||
#ifdef BOOSTER_DOXYGEN_DOCS | |||
/// | |||
/// \brief This is Booster's implementation of std::tr1::function/booster::function. | |||
/// | |||
/// This function is created from generic object that can be "called" i.e. | |||
/// a class with operator() or function pointer that has same signature as | |||
/// the function. | |||
/// | |||
/// See: http://www.boost.org/doc/html/function.html | |||
/// | |||
/// Notes: | |||
/// | |||
/// - this code is not taken from Boost and has slightly different interface. | |||
/// - as most of compilers do not support Variadic templates yet, this class | |||
/// is explicitly specialized for Params of size 0 to 8. So maximal amout | |||
/// of parameters that can be used is 8. | |||
/// | |||
/// | |||
template<typename Result,typename ...Params> | |||
class function<Result(Params...)> | |||
{ | |||
public: | |||
/// | |||
/// Type of result, for use with boost::bind | |||
/// | |||
typedef Result result_type; | |||
/// | |||
/// Default constructor, creates an empty functions | |||
/// | |||
function(); | |||
/// | |||
/// Creates a function from a functional \a func of type F. func | |||
/// should be copyable. It is copied and stored inside function object. | |||
/// | |||
template<typename F> | |||
function(F func); | |||
/// | |||
/// Copy function, Copies underlying functional object. | |||
/// | |||
function(function const &other); | |||
/// | |||
/// Assign a functional \a func of type F. func | |||
/// should be copyable. It is copied and stored inside function object. | |||
/// | |||
template<typename F> | |||
function const &operator=(F func); | |||
/// | |||
/// Assignment operator. Copies underlying functional object. | |||
/// | |||
function const &operator=(function const &other); | |||
/// | |||
/// Calls underling functional object. If the function is empty, throws bad_function_call. | |||
/// | |||
result_type operator()(Params... params) const; | |||
/// | |||
/// Return true if the function is empty | |||
/// | |||
bool empty() const; | |||
/// | |||
/// Returns true if the function is not empty | |||
/// | |||
operator bool() const; | |||
/// | |||
/// Swaps two functional object. Does not throw. | |||
/// | |||
void swap(function &other); | |||
}; | |||
#else | |||
#define BOOSTER_FUNCTION \ | |||
template<typename Result BOOSTER_TEMPLATE_PARAMS > \ | |||
class function<Result(BOOSTER_TYPE_PARAMS)> \ | |||
@@ -153,6 +229,8 @@ namespace booster { | |||
#undef BOOSTER_FUNCTION | |||
#endif // DOC | |||
} // booster | |||
@@ -21,20 +21,23 @@ | |||
namespace booster | |||
{ | |||
// | |||
// intrusive_ptr | |||
// | |||
// A smart pointer that uses intrusive reference counting. | |||
// | |||
// Relies on unqualified calls to | |||
// | |||
// void intrusive_ptr_add_ref(T * p); | |||
// void intrusive_ptr_release(T * p); | |||
// | |||
// (p != 0) | |||
// | |||
// The object is responsible for destroying itself. | |||
// | |||
/// | |||
/// \brief intrusive_ptr is the class taken as-is from boost. | |||
/// | |||
/// | |||
/// A smart pointer that uses intrusive reference counting. | |||
/// | |||
/// Relies on unqualified calls to | |||
/// | |||
/// void intrusive_ptr_add_ref(T * p); | |||
/// void intrusive_ptr_release(T * p); | |||
/// | |||
/// (p != 0) | |||
/// | |||
/// The object is responsible for destroying itself. | |||
/// | |||
/// See: http://www.boost.org/doc/libs/release/libs/smart_ptr | |||
/// | |||
template<class T> class intrusive_ptr | |||
{ | |||
@@ -24,6 +24,10 @@ class shared_ptr; | |||
template<typename T> | |||
class weak_ptr; | |||
/// | |||
/// \brief This namespace includes Booster.Log related classes | |||
/// | |||
namespace log { | |||
typedef enum { | |||
@@ -110,6 +114,11 @@ namespace log { | |||
~logger(); | |||
}; | |||
/// | |||
/// \brief This namespace includes various output devices (sinks) for logger. | |||
/// | |||
/// It includes several standard devices that can be used in most applications | |||
/// | |||
namespace sinks { | |||
BOOSTER_API std::string format_plain_text_message(message const &msg); | |||
@@ -9,6 +9,9 @@ | |||
#define BOOSTER_NONCOPYABLE_H | |||
namespace booster { | |||
/// | |||
/// \brief This class makes impossible to copy any class derived from this one. | |||
/// | |||
class noncopyable { | |||
private: | |||
noncopyable(noncopyable const &); | |||
@@ -4,7 +4,7 @@ | |||
#include <booster/config.h> | |||
#include <stdexcept> | |||
#ifdef BOOSTER_WIN_NATIVE | |||
#if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) | |||
namespace booster { | |||
namespace nowide { | |||
@@ -13,7 +13,10 @@ namespace booster { | |||
using std::freopen; | |||
using std::remove; | |||
using std::rename; | |||
#else | |||
#endif | |||
#if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) | |||
inline FILE *fopen(char const *file_name,char const *mode) | |||
{ | |||
try { | |||
@@ -12,6 +12,11 @@ | |||
#endif | |||
namespace booster { | |||
/// | |||
/// \brief This namespace includes implementation of basic STL's / STDLIb's functions | |||
/// such that they accept UTF-8 strings. on Windows. Otherwise it is just an alias | |||
/// of std namespace (i.e. not on Windows) | |||
/// | |||
namespace nowide { | |||
#ifndef BOOSTER_WIN_NATIVE | |||
@@ -24,7 +29,8 @@ namespace nowide { | |||
using std::ofstream; | |||
using std::fstream; | |||
#else // windows crap: | |||
#endif | |||
#if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) | |||
#if defined BOOSTER_MSVC | |||
@@ -1,39 +0,0 @@ | |||
#include <booster/nowide/fstream.h> | |||
#include <iostream> | |||
int main() | |||
{ | |||
{ | |||
booster::nowide::ofstream f("test.txt",std::ios_base::trunc | std::ios_base::out); | |||
f<< "Hello World" << std::endl;; | |||
f.close(); | |||
} | |||
{ | |||
booster::nowide::fstream f("test.txt"); | |||
std::string s; | |||
f >> s; | |||
std::cout << s << std::endl; | |||
f.seekp(0,std::ios_base::end); | |||
f<<s; | |||
f.close(); | |||
} | |||
{ | |||
booster::nowide::ifstream f("test.txt"); | |||
char buf[16]; | |||
while(!f.eof()) { | |||
f.read(buf,16); | |||
std::cout.write(buf,f.gcount()); | |||
} | |||
std::cout << std::flush; | |||
} | |||
{ | |||
booster::nowide::ifstream f; | |||
f.open("test.txt"); | |||
char buf[16]; | |||
while(!f.eof()) { | |||
f.read(buf,16); | |||
std::cout.write(buf,f.gcount()); | |||
} | |||
std::cout << std::flush; | |||
} | |||
} |
@@ -15,6 +15,9 @@ | |||
#include <stdexcept> | |||
namespace booster { | |||
/// | |||
/// \brief Exception that is thrown in case of creation of invalid regex | |||
/// | |||
class regex_error : public std::runtime_error { | |||
public: | |||
regex_error(std::string const &s) : std::runtime_error(s) | |||
@@ -22,32 +25,102 @@ namespace booster { | |||
} | |||
}; | |||
/// | |||
/// \brief This is a simple wrapper of PCRE library. | |||
/// | |||
/// It is designed to be used with sub_match, match_results, regex_match and regex_search template functions. | |||
/// | |||
/// It provides API similar to ones of Boost.Regex but it is also much simplified. | |||
/// | |||
class BOOSTER_API regex { | |||
public: | |||
typedef char value_type; | |||
explicit regex(); | |||
/// | |||
/// Copy regular expression. Note. This is much more efficient then creating a new expression | |||
/// with same patter. | |||
/// | |||
regex(regex const &); | |||
/// | |||
/// Copy regular expression. Note. This is much more efficient then creating a new expression | |||
/// with same patter. | |||
/// | |||
regex const &operator=(regex const &); | |||
~regex(); | |||
/// | |||
/// Create regular expression using a \a patter and special \a flags. Note, at this point flags | |||
/// should be normal or perl only (which are equivalent). May be extended in future. | |||
/// | |||
/// Throws regex_error in case of invalid expression. | |||
/// | |||
regex(std::string const &pattern,int flags = normal); | |||
/// | |||
/// Assigns regular expression using a \a patter and special \a flags. Note, at this point flags | |||
/// should be normal or perl only (which are equivalent). May be extended in future. | |||
/// | |||
/// Throws regex_error in case of invalid expression. | |||
/// | |||
void assign(std::string const &pattern,int flags = normal); | |||
/// | |||
/// Get expression flags. Now always 0. | |||
/// | |||
int flags() const; | |||
/// | |||
/// Get the string that the regular expression was created with. | |||
/// | |||
std::string str() const; | |||
/// | |||
/// Get number of captured subexpressions. | |||
/// | |||
unsigned mark_count() const; | |||
/// | |||
/// Match the expression in the text in range [begin,end) exactly. Parameter \a flags currently unused. | |||
/// | |||
/// Return true if matches | |||
/// | |||
bool match(char const *begin,char const *end,int flags = 0) const; | |||
/// | |||
/// Match the expression in the text in range [begin,end) exactly. Parameter \a flags currently unused. | |||
/// | |||
/// Return true if matches, and stores captured sub-patterns in \a marks. Each pair represents | |||
/// a text in rage [begin+first,begin+second). | |||
/// | |||
/// If no such patter was captured, returns (-1,-1) as pair. | |||
/// | |||
bool match(char const *begin,char const *end,std::vector<std::pair<int,int> > &marks,int flags = 0) const; | |||
/// | |||
/// Search the expression in the text in range [begin,end). Parameter \a flags currently unused. | |||
/// | |||
/// Return true if found. | |||
/// | |||
bool search(char const *begin,char const *end,int flags = 0) const; | |||
/// | |||
/// Search the expression in the text in range [begin,end). Parameter \a flags currently unused. | |||
/// | |||
/// Return true if found, and stores captured sub-patterns in \a marks. Each pair represents | |||
/// a text in rage [begin+first,begin+second). | |||
/// | |||
/// If no such patter was captured, returns (-1,-1) as pair. | |||
/// | |||
bool search(char const *begin,char const *end,std::vector<std::pair<int,int> > &marks,int flags = 0) const; | |||
/// | |||
/// Returns true if the expression wasn't assigned. | |||
/// | |||
bool empty() const; | |||
static const int perl = 0; | |||
static const int normal = 0; | |||
static const int perl = 0; ///< Constant for expression type - Perl Compatible Regex. | |||
static const int normal = 0; ///< Constant for expression type - synonym of perl, default. | |||
private: | |||
struct data; | |||
copy_ptr<data> d; | |||
@@ -14,8 +14,20 @@ | |||
#include <math.h> | |||
namespace booster { | |||
/// | |||
/// \brief This class represents POSIX time. | |||
/// | |||
/// The time from Jan 1, 1970 in seconds in UTC (without leap seconds) similar to time_t. | |||
/// | |||
/// ptime internally holds 64 bit integer for seconds part and int for nanoseconds | |||
/// part which gives fine-grained time representation. | |||
/// | |||
class BOOSTER_API ptime { | |||
public: | |||
/// | |||
/// Create the POSIX time from seconds and nanoseconds. | |||
/// | |||
explicit | |||
ptime(long long seconds=0,int nano=0) : | |||
sec(seconds), | |||
@@ -24,85 +36,148 @@ namespace booster { | |||
normalize(); | |||
} | |||
/// | |||
/// Get the seconds part of POSIX time | |||
/// | |||
long long get_seconds() const | |||
{ | |||
return sec; | |||
} | |||
/// | |||
/// Get the nanoseconds fraction part of POSIX time | |||
/// | |||
int get_nanoseconds() const | |||
{ | |||
return nsec; | |||
} | |||
/// | |||
/// Get the milliseconds fraction part of POSIX time (which is equal to get_nanoseconds() / 1,000,000) | |||
/// | |||
int get_milliseconds() const | |||
{ | |||
return nsec / one_e6; | |||
} | |||
/// | |||
/// Get the microseconds fraction part of POSIX time (which is equal to get_nanoseconds() / 1,000) | |||
/// | |||
int get_microseconds() const | |||
{ | |||
return nsec / one_e3; | |||
} | |||
/// | |||
/// Get amount of full seconds in \a p | |||
/// | |||
static long long seconds(ptime const &p) | |||
{ | |||
return p.sec; | |||
} | |||
/// | |||
/// Convert a seconds \a v to ptime. | |||
/// | |||
static ptime seconds(long long v) | |||
{ | |||
return ptime(v); | |||
} | |||
/// | |||
/// Get amount of full milliseconds in \a p. | |||
/// Not the same as p.get_milliseconds() as takes seconds as well | |||
/// | |||
static long long milliseconds(ptime const &p) | |||
{ | |||
return p.get_seconds() * one_e3 + p.get_milliseconds(); | |||
} | |||
/// | |||
/// Convert a milliseconds \a v to ptime. | |||
/// | |||
static ptime milliseconds(long long v) | |||
{ | |||
return ptime(v/one_e3,v%one_e3 * one_e6); | |||
} | |||
/// | |||
/// Get amount of full microseconds in \a p. | |||
/// Not the same as p.get_microseconds() as takes seconds as well | |||
/// | |||
static long long microseconds(ptime const &p) | |||
{ | |||
return p.get_seconds() * one_e6 + p.get_nanoseconds() / one_e3; | |||
} | |||
/// | |||
/// Convert a microseconds \a v to ptime. | |||
/// | |||
static ptime microseconds(long long v) | |||
{ | |||
return ptime(v/one_e6,v%one_e6 * one_e3); | |||
} | |||
/// | |||
/// Get amount of nanoseconds in \a p | |||
/// Not the same as p.get_nanoseconds() as takes seconds as well | |||
/// | |||
static long long nanoseconds(ptime const &p) | |||
{ | |||
return p.get_seconds() * one_e9 + p.get_nanoseconds(); | |||
} | |||
/// | |||
/// Convert a nanoseconds \a v to ptime. | |||
/// | |||
static ptime nanoseconds(long long v) | |||
{ | |||
return ptime(v/one_e9,v%one_e9); | |||
} | |||
/// | |||
/// Get amount of full minutes in \a p | |||
/// | |||
static ptime minutes(long long v) | |||
{ | |||
return ptime(v*60); | |||
} | |||
/// | |||
/// Convert minutes \a v to ptime. | |||
/// | |||
static long long minutes(ptime const &p) | |||
{ | |||
return p.get_seconds() / 60; | |||
} | |||
/// | |||
/// Get amount of full hours in \a p | |||
/// | |||
static long long hours(ptime const &p) | |||
{ | |||
return p.get_seconds() / 3600; | |||
} | |||
/// | |||
/// Convert hours \a v to ptime. | |||
/// | |||
static ptime hours(long long v) | |||
{ | |||
return ptime(v*3600); | |||
} | |||
/// | |||
/// Get amount of full days in \a p | |||
/// | |||
static long long days(ptime const &p) | |||
{ | |||
return p.get_seconds() / (3600*24); | |||
} | |||
/// | |||
/// Convert days \a v to ptime. | |||
/// | |||
static ptime days(long long v) | |||
{ | |||
return ptime(v*(3600*24)); | |||
} | |||
/// | |||
/// Convert \a t to floating point number that represents POSIX time in seconds | |||
/// | |||
static double to_number(ptime const &t) | |||
{ | |||
return double(t.sec) + double(t.nsec) * 1e-9; | |||
} | |||
/// | |||
/// Convert floating point number \a d that represents POSIX time in seconds to ptime | |||
/// | |||
static ptime from_number(double d) | |||
{ | |||
double sec = floor(d); | |||
@@ -114,10 +189,16 @@ namespace booster { | |||
return ptime(seconds,nano); | |||
} | |||
/// | |||
/// Add two POSIX time ranges (as numbers) | |||
/// | |||
ptime operator+(ptime const &other) const | |||
{ | |||
return ptime(sec+other.sec,nsec+other.nsec); | |||
} | |||
/// | |||
/// Subtract one time from other (as number) | |||
/// | |||
ptime operator-(ptime const &other) const | |||
{ | |||
return ptime(sec-other.sec,nsec-other.nsec); | |||
@@ -152,26 +233,43 @@ namespace booster { | |||
return !(*this < other); | |||
} | |||
// | |||
// static member functions | |||
// | |||
/// | |||
/// Convert POSIX time \a v to a local time similar to localtime_r | |||
/// | |||
static std::tm local_time(ptime const &v); | |||
/// | |||
/// Convert POSIX time \a v to a GMT time similar to gmtime_r | |||
/// | |||
static std::tm universal_time(ptime const &v); | |||
/// | |||
/// Get current time | |||
/// | |||
static ptime now(); | |||
/// | |||
/// Same as ptime() -- 0 in terms of POSIX time | |||
/// | |||
static ptime const zero; | |||
/// | |||
/// Sleep at least \a v milliseconds | |||
/// | |||
static void millisleep(long long v) | |||
{ | |||
sleep(milliseconds(v)); | |||
} | |||
/// | |||
/// Sleep at least \a v nanoseconds | |||
/// | |||
static void nanosleep(long long v) | |||
{ | |||
sleep(nanoseconds(v)); | |||
} | |||
static void sleep(ptime const &); | |||
/// | |||
/// Sleep at least \a v amount of time. | |||
/// | |||
static void sleep(ptime const &v ); | |||
private: | |||
void normalize() | |||
@@ -193,8 +291,16 @@ namespace booster { | |||
long long sec; | |||
int nsec; | |||
}; | |||
/// | |||
/// Write ptime to stream. It is written as double, so it would give expected result when | |||
/// working with booster::locale::as::date_time formatter | |||
/// | |||
BOOSTER_API std::ostream &operator<<(std::ostream &,ptime const &); | |||
/// | |||
/// Read ptime from stream. It is read as double, so it would give expected result when | |||
/// working with booster::locale::as::date_time formatter | |||
/// | |||
BOOSTER_API std::istream &operator>>(std::istream &,ptime &); | |||
} | |||
@@ -15,6 +15,12 @@ | |||
#include <string.h> | |||
namespace booster { | |||
/// | |||
/// \brief This class represents a single captures subexpression. | |||
/// | |||
/// The subexpressions captured text is found between [first,second). | |||
/// | |||
template<typename Iterator> | |||
class sub_match : public std::pair<Iterator,Iterator> { | |||
public: | |||
@@ -22,10 +28,21 @@ namespace booster { | |||
typedef typename std::iterator_traits<Iterator>::value_type value_type; | |||
typedef typename std::iterator_traits<Iterator>::difference_type difference_type; | |||
/// | |||
/// The string type that this expression can be converted into, generally std::string. | |||
/// | |||
typedef std::basic_string<value_type> string_type; | |||
typedef std::pair<Iterator,Iterator> pair_type; | |||
/// | |||
/// This flag is true if the expression was matched, false otherwise. | |||
/// if matched is false then there is no guarantees that first or second are valid iterators. | |||
/// | |||
bool matched; | |||
/// | |||
/// The length of captured subexpression, 0 if matched==false. | |||
/// | |||
difference_type length() const | |||
{ | |||
if(matched) | |||
@@ -33,11 +50,17 @@ namespace booster { | |||
return 0; | |||
} | |||
/// | |||
/// Explicit conversion operator to string | |||
/// | |||
operator string_type() const | |||
{ | |||
return str(); | |||
} | |||
/// | |||
/// Convert the subexpression to string. If matched is false, return empty string. | |||
/// | |||
string_type str() const | |||
{ | |||
if(matched) | |||
@@ -46,18 +69,30 @@ namespace booster { | |||
return string_type(); | |||
} | |||
/// | |||
/// Compare two subexpressions. Same as str().compare(other.str()) | |||
/// | |||
int compare(sub_match const &other) const | |||
{ | |||
return str().compare(other.str()); | |||
} | |||
/// | |||
/// Compare two subexpressions. Same as str().compare(other) | |||
/// | |||
int compare(string_type const &other) const | |||
{ | |||
return str().compare(other); | |||
} | |||
/// | |||
/// Compare two subexpressions. Same as str().compare(s) | |||
/// | |||
int compare(value_type const *s) const | |||
{ | |||
return str().compare(s); | |||
} | |||
/// | |||
/// Default not-matched subexpressions. | |||
/// | |||
sub_match() : matched(false) | |||
{ | |||
} | |||
@@ -67,15 +102,29 @@ namespace booster { | |||
typedef sub_match<std::string::const_iterator> ssub_match; | |||
/// | |||
/// The object that hold the result of matching a regular expression against the text | |||
/// using regex_match and regex_search functions | |||
/// | |||
template<typename Iterator> | |||
class match_results { | |||
public: | |||
/// | |||
/// Creates default empty matched result. | |||
/// | |||
match_results() | |||
{ | |||
begin_ = Iterator(); | |||
end_ = Iterator(); | |||
} | |||
/// | |||
/// The type of subexpression returned by operator[] | |||
/// | |||
typedef sub_match<Iterator> value_type; | |||
/// | |||
/// Get the sub_match for subexpression \a n. If n < 0 or n >= size() returns an empty sub_match | |||
/// | |||
value_type operator[](int n) const | |||
{ | |||
value_type r; | |||
@@ -90,11 +139,18 @@ namespace booster { | |||
std::advance(r.second,offsets_[n].second); | |||
return r; | |||
} | |||
/// | |||
/// Get the number of captured subexpressions in the regular expression. | |||
/// | |||
size_t size() const | |||
{ | |||
return offsets_.size(); | |||
} | |||
/// | |||
/// Get the text range before the matched expression. Always empty for match_results | |||
/// | |||
value_type suffix() | |||
{ | |||
value_type r; | |||
@@ -107,6 +163,9 @@ namespace booster { | |||
return r; | |||
} | |||
/// | |||
/// Get the text range after the matched expression. Always empty for match_results | |||
/// | |||
value_type prefix() | |||
{ | |||
value_type r; | |||
@@ -119,12 +178,17 @@ namespace booster { | |||
return r; | |||
} | |||
/// \cond INTERNAL | |||
void assign(Iterator begin,Iterator end,std::vector<std::pair<int,int> > &offsets) | |||
{ | |||
begin_ = begin; | |||
end_ = end; | |||
offsets_.swap(offsets); | |||
} | |||
/// \endcond | |||
private: | |||
Iterator begin_,end_; | |||
std::vector<std::pair<int,int> > offsets_; | |||
@@ -133,6 +197,10 @@ namespace booster { | |||
typedef match_results<char const *> cmatch; | |||
typedef match_results<std::string::const_iterator> smatch; | |||
/// | |||
/// Match an expression \a r against text in range [\a begin, \a end ), return true | |||
/// if found and store matched patters in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_match(char const *begin,char const *end,cmatch &m, Regex const &r,int flags = 0) | |||
{ | |||
@@ -142,6 +210,10 @@ namespace booster { | |||
m.assign(begin,end,map); | |||
return true; | |||
} | |||
/// | |||
/// Match an expression \a r against text \a s, return true | |||
/// if found and store matched patters in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_match(std::string const &s,smatch &m, Regex const &r,int flags = 0) | |||
@@ -152,6 +224,10 @@ namespace booster { | |||
m.assign(s.begin(),s.end(),map); | |||
return true; | |||
} | |||
/// | |||
/// Match an expression \a r against text \a s, return true | |||
/// if found and store matched patters in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_match(char const *s,cmatch &m, Regex const &r,int flags = 0) | |||
@@ -165,6 +241,10 @@ namespace booster { | |||
return true; | |||
} | |||
/// | |||
/// Search an expression \a r in text in rage [\a begin, \a end). Return true if found, | |||
/// and store matched subexpressions in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_search(char const *begin,char const *end,cmatch &m, Regex const &r,int flags = 0) | |||
{ | |||
@@ -175,6 +255,10 @@ namespace booster { | |||
return true; | |||
} | |||
/// | |||
/// Search an expression \a r in text \a s. Return true if found, | |||
/// and store matched subexpressions in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_search(std::string const &s,smatch &m, Regex const &r,int flags = 0) | |||
{ | |||
@@ -185,6 +269,11 @@ namespace booster { | |||
return true; | |||
} | |||
/// | |||
/// Search an expression \a r in text \a s. Return true if found, | |||
/// and store matched subexpressions in \a m | |||
/// | |||
template<typename Regex> | |||
bool regex_search(char const *s,cmatch &m, Regex const &r,int flags = 0) | |||
{ | |||
@@ -197,17 +286,26 @@ namespace booster { | |||
return true; | |||
} | |||
/// | |||
/// Match an expression \a r against text in range [\a begin, \a end ), return true if matched | |||
/// | |||
template<typename Regex> | |||
bool regex_match(char const *begin,char const *end, Regex const &r,int flags = 0) | |||
{ | |||
return r.match(begin,end,flags); | |||
} | |||
/// | |||
/// Match an expression \a r against text \a s, return true if matched | |||
/// | |||
template<typename Regex> | |||
bool regex_match(std::string const &s, Regex const &r,int flags = 0) | |||
{ | |||
return r.match(s.c_str(),s.c_str()+s.size(),flags); | |||
} | |||
/// | |||
/// Match an expression \a r against text \a s, return true if matched | |||
/// | |||
template<typename Regex> | |||
bool regex_match(char const *s, Regex const &r,int flags = 0) | |||
@@ -215,18 +313,27 @@ namespace booster { | |||
return r.match(s,s+strlen(s),flags); | |||
} | |||
/// | |||
/// Search an expression \a r against text in range [\a begin, \a end ), return true if found | |||
/// | |||
template<typename Regex> | |||
bool regex_search(char const *begin,char const *end, Regex const &r,int flags = 0) | |||
{ | |||
return r.search(begin,end,flags); | |||
} | |||
/// | |||
/// Search an expression \a r against text \a s, return true if found | |||
/// | |||
template<typename Regex> | |||
bool regex_search(std::string const &s, Regex const &r,int flags = 0) | |||
{ | |||
return r.search(s.c_str(),s.c_str()+s.size(),flags); | |||
} | |||
/// | |||
/// Search an expression \a r against text \a s, return true if found | |||
/// | |||
template<typename Regex> | |||
bool regex_search(char const *s, Regex const &r,int flags = 0) | |||
{ | |||
@@ -15,6 +15,11 @@ | |||
#include <booster/config.h> | |||
namespace booster { | |||
/// | |||
/// \brief this namespace includes partial implementation of std::tr1's/boost's system_error, error_code | |||
/// classes | |||
/// | |||
namespace system { | |||
class error_category { | |||
public: | |||
@@ -171,7 +171,7 @@ namespace cppcms { | |||
/// | |||
/// \param key -- the key that uniquely defines the frame. | |||
/// \param frame -- the actual value | |||
/// \parma triggers -- the set of triggers that the key should depend on (\a key is added automatically) | |||
/// \param triggers -- the set of triggers that the key should depend on (\a key is added automatically) | |||
/// \param timeout -- maximal object lifetime, -1 is infinity | |||
/// \param notriggers -- if \a notriggers is true no frame dependent triggers would be added to the current | |||
/// page trigger set. Otherwise (default) current page would depend on the \a key and \a triggers as its | |||
@@ -220,8 +220,8 @@ namespace cppcms { | |||
/// Store a serializeable object to the cache. | |||
/// | |||
/// \param key -- the key that uniquely defines the object. | |||
/// \param date -- the actual object | |||
/// \parma triggers -- the set of triggers that the key should depend on (\a key is added automatically) | |||
/// \param data -- the actual object | |||
/// \param triggers -- the set of triggers that the key should depend on (\a key is added automatically) | |||
/// \param timeout -- maximal object lifetime, -1 is infinity | |||
/// \param notriggers -- if \a notriggers is true no frame dependent triggers would be added to the current | |||
/// page trigger set. Otherwise (default) current page would depend on the \a key and \a triggers as its | |||
@@ -28,10 +28,7 @@ namespace cppcms { | |||
namespace json { class value; } | |||
namespace impl { class base_cache; } | |||
/// | |||
/// \cond INTERNAL | |||
/// | |||
class CPPCMS_API cache_pool { | |||
public: | |||
cache_pool(json::value const &settings); | |||
@@ -41,7 +38,6 @@ namespace cppcms { | |||
struct _data; | |||
booster::hold_ptr<_data> d; | |||
}; | |||
/// \endcond | |||
} | |||
@@ -346,34 +346,68 @@ namespace cppcms { | |||
/// | |||
iterator(form &); | |||
/// | |||
/// Destructor | |||
/// | |||
~iterator(); | |||
/// | |||
/// Copy the iterator, this is not cheap operation. | |||
/// | |||
iterator(iterator const &other); | |||
/// | |||
/// Assign the iterator, this is not cheap operation. | |||
/// | |||
iterator const &operator = (iterator const &other); | |||
/// | |||
/// Returns the underlying widget. Condition: *this!=iterator() | |||
/// | |||
widgets::base_widget *operator->() const | |||
{ | |||
return get(); | |||
} | |||
/// | |||
/// Returns the underlying widget. Condition: *this!=iterator() | |||
/// | |||
widgets::base_widget &operator*() const | |||
{ | |||
return *get(); | |||
} | |||
/// | |||
/// Check if two iterators pointing to same element | |||
/// | |||
bool operator==(iterator const &other) const | |||
{ | |||
return equal(other); | |||
} | |||
/// | |||
/// Check if two iterators pointing to different element | |||
/// | |||
bool operator!=(iterator const &other) const | |||
{ | |||
return !equal(other); | |||
} | |||
/// | |||
/// Post Increment operator, it forward the iterator no text widget. | |||
/// Note it does not point to higher level form container. | |||
/// | |||
/// Note: prefer using ++i then i++ as copying iterator is not cheap. | |||
/// | |||
iterator operator++(int unused) | |||
{ | |||
iterator tmp(*this); | |||
next(); | |||
return tmp; | |||
} | |||
/// | |||
/// Increment operator. It forward the iterator no text widget. | |||
/// Note it does not point to higher level form container | |||
/// | |||
iterator &operator++() | |||
{ | |||
next(); | |||
@@ -770,13 +804,36 @@ namespace cppcms { | |||
booster::hold_ptr<_data> d; | |||
}; | |||
/// | |||
/// This class represents a basic widget that generates html for common widgets | |||
/// that use <input \/> HTML tag. | |||
/// | |||
/// It allows you creating your own widgets easier as it does most of job required for | |||
/// generating the HTML and user is required only to generate actual value like | |||
/// value="10.34" as for numeric widget. | |||
/// | |||
class CPPCMS_API base_html_input : virtual public base_widget { | |||
public: | |||
/// | |||
/// Creates new instance, \a type is HTML type tag of the input element, for example "text" or | |||
/// "password". | |||
/// | |||
base_html_input(std::string const &type); | |||
/// | |||
/// Virtual destructor... | |||
/// | |||
virtual ~base_html_input(); | |||
/// | |||
/// This function is actual HTML generation function that calls render_value where needed. | |||
/// | |||
virtual void render_input(form_context &context); | |||
protected: | |||
/// | |||
/// This is what user actually expected to implement. Write actual value HTML tag. | |||
/// | |||
virtual void render_value(form_context &context) = 0; | |||
private: | |||
struct _data; | |||
@@ -825,11 +882,25 @@ namespace cppcms { | |||
booster::hold_ptr<_data> d; | |||
}; | |||
/// | |||
/// This widget represents hidden input form type. It is used to provide | |||
/// some invisible to user information. | |||
/// | |||
/// I has same properties that text widget has but it does not render any HTML | |||
/// related to message(), help() and other informational types. | |||
/// | |||
/// When your render the form in templates it is good idea to render it separately | |||
/// to make sure that no invalid HTML would be created. | |||
/// | |||
class CPPCMS_API hidden : public text | |||
{ | |||
public: | |||
hidden(); | |||
~hidden(); | |||
/// | |||
/// Actual rendering function that is redefined | |||
/// | |||
virtual void render(form_context &context); | |||
private: | |||
struct _data; | |||
@@ -837,6 +908,10 @@ namespace cppcms { | |||
}; | |||
/// | |||
/// This text widget behaves similarly to text widget but uses rather HTML | |||
/// textarea and not input HTML tags | |||
/// | |||
class CPPCMS_API textarea : public base_text | |||
{ | |||
public: | |||
@@ -402,6 +402,7 @@ namespace json { | |||
/// | |||
/// Note: only JSON object and JSON array are considered valid values | |||
/// | |||
/// \param in the std::istream used to read the data | |||
/// \param full require EOF once the object is read, otherwise consider it as syntax error | |||
/// \param line_number return a number of the line where syntax error occurred | |||
/// \result returns true if the value was read successfully, otherwise returns false to indicate a syntax error. | |||
@@ -166,7 +166,7 @@ namespace cppcms { | |||
/// opposite of \a sel, if sel is match_path_info then non_selected_part checked against SCRIPT_NAME | |||
/// otherwise it is checked against PATH_INFO | |||
/// \param selected_part is a regular expression for matching against PATH_INFO or SCRIPT_NAME according \a sel | |||
/// \param regular expression subgroup of \a selected_part for URL dispatching | |||
/// \param group regular expression subgroup of \a selected_part for URL dispatching | |||
/// | |||
mount_point( selection_type sel, | |||
std::string const &non_selected_part, | |||
@@ -39,7 +39,7 @@ class encryptor; | |||
class CPPCMS_API session_dual : public session_api { | |||
public: | |||
/// | |||
/// Create a new object using encryptor \a enc and session_storage \s storage. | |||
/// Create a new object using encryptor \a enc and session_storage \a storage. | |||
/// \a data_size_limit represents the maximal data size that can be stored on client side, if the data size is bigger then that | |||
/// the session data will be stored on server | |||
/// | |||
@@ -31,10 +31,11 @@ namespace cppcms { | |||
namespace util { | |||
/// | |||
/// Escape string for inclusion in HTML page, i.e. | |||
/// < --- < | |||
/// > --- > | |||
/// & --- & | |||
/// " --- " | |||
/// | |||
/// - < - \< | |||
/// - > - \> | |||
/// - \& - \& | |||
/// - " - \" | |||
/// | |||
/// Note, this function does not deal with encodings, so it's up to you to | |||
/// provide valid text encoding | |||
@@ -33,6 +33,9 @@ namespace cppcms { | |||
class CPPCMS_API views_pool : public booster::noncopyable { | |||
public: | |||
/// \cond INTERNAL | |||
typedef std::auto_ptr<base_view> (*view_factory_type)(std::ostream &,base_content *c); | |||
typedef std::map<std::string,view_factory_type> mapping_type; | |||
@@ -46,9 +49,24 @@ namespace cppcms { | |||
views_pool(); | |||
views_pool(json::value const &settings); | |||
~views_pool(); | |||
void add_view(std::string skin,mapping_type const &mapping); | |||
void remove_view(std::string skin); | |||
static views_pool &static_instance(); | |||
/// \endcond | |||
/// | |||
/// Thread safe member function | |||
/// This member function is used to render templates. Generally you should not use | |||
/// it directly, unless you have very good reasons. | |||
/// | |||
/// \param skin - the name of the skin that should be used | |||
/// \param template_name - the name of template (class) that should be rendered. | |||
/// \param out - the output stream into which the view should be rendered | |||
/// \param content - the content that should be rendered using this view. | |||
/// | |||
/// This function is thread safe | |||
/// | |||
void render(std::string skin,std::string template_name,std::ostream &out,base_content &content); | |||
@@ -57,10 +75,6 @@ namespace cppcms { | |||
/// | |||
std::string default_skin() const; | |||
void add_view(std::string skin,mapping_type const &mapping); | |||
void remove_view(std::string skin); | |||
static views_pool &static_instance(); | |||
private: | |||
struct _data; | |||
@@ -18,6 +18,9 @@ | |||
namespace cppcms { | |||
namespace locale { | |||
/// \cond INTERNAL | |||
namespace details { | |||
template<typename CharType> | |||
@@ -70,6 +70,9 @@ namespace cppcms { | |||
template<> | |||
CPPCMS_API std::string ext_pattern(std::ios_base &,flags::pattern_type pattern_id); | |||
/// | |||
/// \brief This namespace includes locale related iostream manipulators | |||
/// | |||
namespace as { | |||
#define CPPCMS_LOCALE_AS_MANIPULATOR(name,mask) \ | |||
@@ -90,6 +93,7 @@ namespace cppcms { | |||
CPPCMS_LOCALE_AS_MANIPULATOR(currency_iso,currency_flags_mask) | |||
CPPCMS_LOCALE_AS_MANIPULATOR(currency_national,currency_flags_mask) | |||
/// \cond INTERNAL | |||
namespace details { | |||
template<typename CharType> | |||
struct add_ftime { | |||
@@ -120,6 +124,8 @@ namespace cppcms { | |||
} | |||
/// \endcond | |||
template<typename CharType> | |||
details::add_ftime<CharType> ftime(std::basic_string<CharType> const &format) | |||
{ | |||
@@ -15,6 +15,15 @@ | |||
#include <cppcms/config.h> | |||
namespace cppcms { | |||
/// | |||
/// \brief this is implementation of simple localization that is not dependent on ICU library. | |||
/// | |||
/// It is very similar to booster::locale but much more limited and simple. It is designed | |||
/// to be used in embedded environent and use standard libraries features only. | |||
/// | |||
/// It is build only if CppCMS is built without ICU support and booster::locale is not build. | |||
/// | |||
/// | |||
namespace locale { | |||
class info_impl; | |||
@@ -24,13 +24,6 @@ | |||
namespace cppcms { | |||
namespace locale { | |||
/// | |||
/// \defgroup message Message Formatting (translation) | |||
/// | |||
///This module provides message translation functionality, i.e. allow your application to speak native language | |||
/// | |||
/// @{ | |||
/// | |||
class info; | |||
@@ -491,10 +484,6 @@ namespace cppcms { | |||
std::vector<std::string> const &paths); | |||
/// \endcond | |||
/// | |||
/// @} | |||
/// | |||
namespace as { | |||
/// \cond INTERNAL | |||
namespace details { | |||
@@ -511,11 +500,7 @@ namespace cppcms { | |||
} // details | |||
/// \endcond | |||
/// | |||
/// \addtogroup manipulators | |||
/// | |||
/// @{ | |||
/// | |||
/// Manipulator for switching message domain in ostream, | |||
/// | |||
@@ -525,7 +510,6 @@ namespace cppcms { | |||
tmp.domain_id = id; | |||
return tmp; | |||
} | |||
/// @} | |||
} // as | |||
} // locale | |||
} // boost | |||