8 #ifndef CPPCMS_FILTERS_H
9 #define CPPCMS_FILTERS_H
16 #include <cppcms/defs.h>
17 #include <booster/copy_ptr.h>
18 #include <cppcms/localization.h>
37 typedef void (*to_stream_type)(std::ostream &,
void const *ptr);
38 typedef std::string (*to_string_type)(std::ios &,
void const *ptr);
43 streamable(streamable
const &other);
44 streamable
const &operator=(streamable
const &other);
53 to_stream_type s1=&to_stream<S>;
54 to_string_type s2=&to_string<S>;
55 std::type_info
const *info=&
typeid(S);
66 if(
typeid(T) != type())
67 throw std::bad_cast();
68 T
const *
object=
reinterpret_cast<T
const *
>(ptr_);
75 streamable(
char const *ptr);
81 void operator()(std::ostream &output)
const;
86 std::string
get(std::ios &ios)
const;
88 void set(
void const *ptr,to_stream_type f1,to_string_type f2,std::type_info
const *type);
91 static void to_stream(std::ostream &out,
void const *ptr)
93 T
const *
object=
reinterpret_cast<T
const *
>(ptr);
99 static std::string to_string(std::ios &out,
void const *ptr)
101 T
const *
object=
reinterpret_cast<T
const *
>(ptr);
102 std::ostringstream oss;
108 std::type_info
const &type()
const;
112 to_stream_type to_stream_;
113 to_string_type to_string_;
114 std::type_info
const *type_;
123 CPPCMS_API streamable::streamable(std::string
const &str);
137 void operator()(std::ostream &out)
const;
164 void operator()(std::ostream &out)
const;
191 void operator()(std::ostream &out)
const;
218 void operator()(std::ostream &out)
const;
219 escape(streamable
const &obj);
246 void operator()(std::ostream &out)
const;
273 void operator()(std::ostream &out)
const;
299 raw const &operator=(
raw const &other);
300 void operator()(std::ostream &out)
const;
301 raw(streamable
const &obj);
312 inline std::ostream &
operator<<(std::ostream &out,
raw const &obj)
325 date const &operator=(
date const &other);
336 date(streamable
const &time,std::string
const &timezone);
337 void operator()(std::ostream &out)
const;
345 inline std::ostream &
operator<<(std::ostream &out,
date const &obj)
360 time const &operator=(
time const &other);
366 time(streamable
const &t);
371 time(streamable
const &
time,std::string
const &timezone);
372 void operator()(std::ostream &out)
const;
380 inline std::ostream &
operator<<(std::ostream &out,
time const &obj)
405 datetime(streamable
const &
time,std::string
const &timezone);
406 void operator()(std::ostream &out)
const;
436 strftime(streamable
const &t,std::string
const &fmt);
443 strftime(streamable
const &
time,std::string
const &timezone,std::string
const &fmt);
445 void operator()(std::ostream &out)
const;
streamable(S const &ptr)
Definition: filters.h:50
Output filter urlencode.
Definition: filters.h:240
std::ios_base & date(std::ios_base &ios)
Definition: formatting.h:319
std::basic_string< CharType > to_lower(std::basic_string< CharType > const &str, std::locale const &loc=std::locale())
Definition: conversion.h:248
Output filter raw.
Definition: filters.h:294
std::basic_string< CharType > to_title(std::basic_string< CharType > const &str, std::locale const &loc=std::locale())
Definition: conversion.h:286
Output filter to_lower.
Definition: filters.h:158
std::basic_ostream< CharType > & operator<<(std::basic_ostream< CharType > &out, date_time const &t)
Definition: date_time.h:874
std::ios_base & datetime(std::ios_base &ios)
Definition: formatting.h:337
std::basic_string< CharType > to_upper(std::basic_string< CharType > const &str, std::locale const &loc=std::locale())
Definition: conversion.h:209
Output filter base64_urlencode.
Definition: filters.h:267
basic_message< CharType > translate(CharType const *msg)
Translate a message, msg is not copied.
Definition: message.h:530
Formats date to the stream, date is represented as number - POSIX time, a plain number.
Definition: filters.h:321
Format date and time to ouput stream.
Definition: filters.h:390
Output filter to_title.
Definition: filters.h:185
Custom time formating filter.
Definition: filters.h:424
std::ios_base & strftime(std::ios_base &ios)
Definition: formatting.h:347
Output filter escape.
Definition: filters.h:212
A special proxy object for writing any object to a std::ostream.
Definition: filters.h:34
Output filter to_upper.
Definition: filters.h:131
Format local time to ouput stream.
Definition: filters.h:356
std::ios_base & time(std::ios_base &ios)
Definition: formatting.h:328