backtrace.h   backtrace.h 
skipping to change at line 14 skipping to change at line 14
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_BACKTRACE_H #ifndef BOOSTER_BACKTRACE_H
#define BOOSTER_BACKTRACE_H #define BOOSTER_BACKTRACE_H
#include <booster/config.h> #include <booster/config.h>
#include <stdexcept> #include <stdexcept>
#include <typeinfo> #include <typeinfo>
#include <string>
#include <vector> #include <vector>
#include <iosfwd> #include <iosfwd>
namespace booster { namespace booster {
namespace stack_trace { namespace stack_trace {
BOOSTER_API int trace(void **addresses,int size); BOOSTER_API int trace(void **addresses,int size);
BOOSTER_API void write_symbols(void *const *addresses,int size,std: :ostream &); BOOSTER_API void write_symbols(void *const *addresses,int size,std: :ostream &);
BOOSTER_API std::string get_symbol(void *address); BOOSTER_API std::string get_symbol(void *address);
BOOSTER_API std::string get_symbols(void * const *address,int size) ; BOOSTER_API std::string get_symbols(void * const *address,int size) ;
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 basic_io_device.h   basic_io_device.h 
skipping to change at line 13 skipping to change at line 13
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_AIO_BASIC_IO_DEVICE_H #ifndef BOOSTER_AIO_BASIC_IO_DEVICE_H
#define BOOSTER_AIO_BASIC_IO_DEVICE_H #define BOOSTER_AIO_BASIC_IO_DEVICE_H
#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/noncopyable.h> #include <booster/noncopyable.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class io_service; class io_service;
class endpoint; class endpoint;
class BOOSTER_API basic_io_device : public noncopyable { class BOOSTER_API basic_io_device : public noncopyable {
public: public:
basic_io_device(); basic_io_device();
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 boundary.h   boundary.h 
// //
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_LOCALE_BOUNDARY_H_INCLUDED #ifndef BOOSTER_LOCALE_BOUNDARY_H_INCLUDED
#define BOOSTER_LOCALE_BOUNDARY_H_INCLUDED #define BOOSTER_LOCALE_BOUNDARY_H_INCLUDED
#include <booster/config.h> #include <booster/locale/boundary/types.h>
#include <booster/cstdint.h> #include <booster/locale/boundary/facets.h>
#ifdef BOOSTER_MSVC #include <booster/locale/boundary/segment.h>
# pragma warning(push) #include <booster/locale/boundary/boundary_point.h>
# pragma warning(disable : 4275 4251 4231 4660) #include <booster/locale/boundary/index.h>
#endif
#include <string>
#include <locale>
#include <vector>
#include <iterator>
#include <algorithm>
#include <typeinfo>
#include <iterator>
#include <booster/backtrace.h>
namespace booster {
namespace locale {
///
/// \brief This namespae contains all operations required for bound
ary analysis of text
///
namespace boundary {
///
/// \defgroup boundary Boundary Analysis
///
/// This module contains all operations required for boundary a
nalysis of text: character, word, like and sentence boundaries
///
/// @{
///
///
/// The enum that describes possible break types
///
typedef enum {
character, ///< Find character boundaries
word, ///< Find word boundaries
sentence, ///< Find sentence boundaries
line ///< Find a positions suitable for line breaks
} boundary_type;
///
/// Flags used with word boundary analysis -- the type of the w
ord found
///
typedef enum {
word_none = 0x0000F, ///< Not a word
word_number = 0x000F0, ///< Word that appear to be a
number
word_letter = 0x00F00, ///< Word that contains lette
rs, excluding kana and ideographic characters
word_kana = 0x0F000, ///< Word that contains kana
characters
word_ideo = 0xF0000, ///< Word that contains ideog
raphic characters
word_any = 0xFFFF0, ///< Any word including numbe
rs, 0 is special flag, equivalent to 15
word_letters = 0xFFF00, ///< Any word, excluding numb
ers but including letters, kana and ideograms.
word_kana_ideo = 0xFF000, ///< Word that includes kana
or ideographic characters
word_mask = 0xFFFFF ///< Maximal used mask
} word_type;
///
/// Flags that describe a type of line break
///
typedef enum {
line_soft = 0x0F, ///< Soft line break: optional b
ut not required
line_hard = 0xF0, ///< Hard line break: like break
is required (as per CR/LF)
line_any = 0xFF, ///< Soft or Hard line break
line_mask = 0xFF
} line_break_type;
///
/// Flags that describe a type of sentence break
///
typedef enum {
sentence_term = 0x0F, ///< The sentence was terminate
d with a sentence terminator
/// like ".", "!" possible fol
lowed by hard separator like CR, LF, PS
sentence_sep = 0xF0, ///< The sentence does not cont
ain terminator like ".", "!" but ended with hard separator
/// like CR, LF, PS or end of
input.
sentence_any = 0xFF, ///< Either first or second sen
tence break type;.
sentence_mask = 0xFF
} sentence_break_type;
///
/// Flags that describe a type of character break. At this poin
t break iterator does not distinguish different
/// kinds of characters so it is used for consistency.
///
typedef enum {
character_any = 0xF, ///< Not in use, just for consi
stency
character_mask = 0xF,
} character_break_type;
///
/// This function returns the mask that covers all variants for
specific boundary type
///
inline unsigned boundary_mask(boundary_type t)
{
switch(t) {
case character: return character_mask;
case word: return word_mask;
case sentence: return sentence_mask;
case line: return line_mask;
default: return 0;
}
}
///
/// This structure is used for representing boundary point
/// that follows the offset.
///
struct break_info {
///
/// Create empty break point at beginning
///
break_info() :
offset(0),
mark(0)
{
}
///
/// Create empty break point at offset v.
/// it is useful for order comparison with other points.
///
break_info(unsigned v) :
offset(v),
mark(0)
{
}
///
/// Offset from the begging of the text where a break occur
s.
///
uint32_t offset;
///
/// The identification of this break point according to
/// various break types
///
uint32_t mark;
///
/// Compare two break points' offset. Allows to search with
/// standard algorithms over the index.
///
bool operator<(break_info const &other) const
{
return offset < other.offset;
}
};
///
/// This type holds the alalisys of the text - all its break po
ints
/// with marks
///
typedef std::vector<break_info> index_type;
template<typename CharType>
class boundary_indexing;
///
/// The facet that allows us to create an index for boundary an
alisys
/// of the text.
///
template<>
class BOOSTER_API boundary_indexing<char> : public std::locale:
:facet {
public:
///
/// Default constructor typical for facets
///
boundary_indexing(size_t refs=0) : std::locale::facet(refs)
{
}
///
/// Create index for boundary type \a t for text in range [
begin,end)
///
virtual index_type map(boundary_type t,char const *begin,ch
ar const *end) const = 0;
/// Identification of this facet
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
};
///
/// The facet that allows us to create an index for boundary an
alisys
/// of the text.
///
template<>
class BOOSTER_API boundary_indexing<wchar_t> : public std::loca
le::facet {
public:
///
/// Default constructor typical for facets
///
boundary_indexing(size_t refs=0) : std::locale::facet(refs)
{
}
///
/// Create index for boundary type \a t for text in range [
begin,end)
///
virtual index_type map(boundary_type t,wchar_t const *begin
,wchar_t const *end) const = 0;
/// Identification of this facet
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
};
#ifdef BOOSTER_HAS_CHAR16_T
template<>
class BOOSTER_API boundary_indexing<char16_t> : public std::loc
ale::facet {
public:
boundary_indexing(size_t refs=0) : std::locale::facet(refs)
{
}
virtual index_type map(boundary_type t,char16_t const *begi
n,char16_t const *end) const = 0;
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
};
#endif
#ifdef BOOSTER_HAS_CHAR32_T
template<>
class BOOSTER_API boundary_indexing<char32_t> : public std::loc
ale::facet {
public:
boundary_indexing(size_t refs=0) : std::locale::facet(refs)
{
}
virtual index_type map(boundary_type t,char32_t const *begi
n,char32_t const *end) const = 0;
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
};
#endif
/// \cond INTERNAL
namespace details {
template<typename IteratorType,typename CategoryType = type
name std::iterator_traits<IteratorType>::iterator_category>
struct mapping_traits {
typedef typename std::iterator_traits<IteratorType>::va
lue_type char_type;
static index_type map(boundary_type t,IteratorType b,It
eratorType e,std::locale const &l)
{
std::basic_string<char_type> str(b,e);
return std::use_facet<boundary_indexing<char_type>
>(l).map(t,str.c_str(),str.c_str()+str.size());
}
};
template<typename IteratorType>
struct mapping_traits<IteratorType,std::random_access_itera
tor_tag> {
typedef typename std::iterator_traits<IteratorType>::va
lue_type char_type;
static index_type map(boundary_type t,IteratorType b,It
eratorType e,std::locale const &l)
{
index_type result;
//
// Optimize for most common cases
//
// C++0x requires that string is continious in memo
ry and all string implementations
// do this because of c_str() support.
//
if(
(
typeid(IteratorType) == typeid(typename std
::basic_string<char_type>::iterator)
|| typeid(IteratorType) == typeid(typename
std::basic_string<char_type>::const_iterator)
|| typeid(IteratorType) == typeid(typename
std::vector<char_type>::iterator)
|| typeid(IteratorType) == typeid(typename
std::vector<char_type>::const_iterator)
|| typeid(IteratorType) == typeid(char_type
*)
|| typeid(IteratorType) == typeid(char_type
const *)
)
&&
b!=e
)
{
char_type const *begin = &*b;
char_type const *end = begin + (e-b);
index_type tmp=std::use_facet<boundary_indexing
<char_type> >(l).map(t,begin,end);
result.swap(tmp);
}
else{
std::basic_string<char_type> str(b,e);
index_type tmp = std::use_facet<boundary_indexi
ng<char_type> >(l).map(t,str.c_str(),str.c_str()+str.size());
result.swap(tmp);
}
return result;
}
};
} // details
/// \endcond
//
// Forward declarations to prevent collsion with boost::token_i
terator
//
template<typename I>
class break_iterator;
template<typename I,typename V>
class token_iterator;
///
/// \brief Class the holds boundary mapping of the text that ca
n be used with iterators
///
/// When the object is created in creates index and provides ac
cess to it with iterators.
/// it is used mostly together with break_iterator and token_it
erator. For each boundary point it
/// provides the description mark of it that allows distinguish
between different types of boundaries.
/// For example it marks if sentence terminates because a mark
like "?" or "." was found or because
/// new line symbol is present in the text.
///
/// These marks can be read out with token_iterator::mark() and
break_iterator::mark() member functions.
///
/// This class stores iterators to the original text, so you sh
ould be careful with iterators
/// invalidation. If the iterators on original text are invalid
you can't use this mapping any more.
///
template<class RangeIterator>
class mapping {
public:
///
/// Iterator type that is used to iterate over boundaries
///
typedef RangeIterator iterator;
///
/// Underlying iterator that is used to iterate original te
xt.
///
typedef typename RangeIterator::base_iterator base_iterator
;
///
/// The character type of the text
///
typedef typename std::iterator_traits<base_iterator>::value
_type char_type;
///
/// Create a mapping of type \a type of the text in range [
\a begin, \a end) using locale \a loc
///
mapping(boundary_type type,base_iterator begin,base_iterato
r end,std::locale const &loc = std::locale())
{
create_mapping(type,begin,end,loc,0xFFFFFFFFu);
}
///
/// Create a mapping of type \a type of the text in range [
\a begin, \a end) using locale \a loc and set the boundaries
/// mask to \a mask
///
mapping(boundary_type type,base_iterator begin,base_iterato
r end,unsigned mask,std::locale const &loc = std::locale())
{
create_mapping(type,begin,end,loc,mask);
}
///
/// Create a mapping of type \a type of the text in range [
\a begin, \a end) using locale \a loc
///
void map(boundary_type type,base_iterator begin,base_iterat
or end,std::locale const &loc = std::locale())
{
create_mapping(type,begin,end,loc,0xFFFFFFFFu);
}
///
/// Create a mapping of type \a type of the text in range [
\a begin, \a end) using locale \a loc, and set a mask to \a mask
///
void map(boundary_type type,base_iterator begin,base_iterat
or end,unsigned mask,std::locale const &loc = std::locale())
{
create_mapping(type,begin,end,loc,mask);
}
///
/// Default constructor of empty mapping
///
mapping()
{
mask_=0xFFFFFFFF;
}
///
/// Copy the mapping, note, you can copy the mapping that i
s used for token_iterator to break_iterator and vise versa.
///
template<typename ORangeIterator>
mapping(mapping<ORangeIterator> const &other) :
index_(other.index_),
begin_(other.begin_),
end_(other.end_),
mask_(other.mask_)
{
}
///
/// Swap the mappings, note, you swap the mappings between
those that are used for token_iterator to break_iterator and vise versa.
/// This operation invalidates all iterators.
///
template<typename ORangeIterator>
void swap(mapping<ORangeIterator> &other)
{
index_.swap(other.index_),
std::swap(begin_,other.begin_);
std::swap(end_,other.end_);
std::swap(mask_,other.mask_);
}
///
/// Copy the mapping, note, you can copy the mapping that i
s used for token_iterator to break_iterator and vise versa.
///
template<typename ORangeIterator>
mapping const &operator=(mapping<ORangeIterator> const &oth
er)
{
index_=other.index_;
begin_=other.begin_;
end_=other.end_;
mask_=other.mask_;
}
///
/// Get current boundary mask
///
unsigned mask() const
{
return mask_;
}
///
/// Set current boundary mask.
///
/// This mask provides fine grained control on the type of
boundaries and tokens you need to relate to. For example, if
/// you want to find sentence breaks that are caused only b
y terminator like "." or "?" and ignore new lines, you can set the mask
/// value sentence_term and break iterator would iterate on
ly over boundaries that much this mask.
///
/// Note: the beginning of the text and the end of the text
are always considered legal boundaries regardless if they have
/// a mark that fits the mask.
///
/// For token iterator it means which kind of tokens should
be selected. Please note that token iterator generally selects the
/// biggest amount of text that has specific mark. This is
especially relevant for word boundary analysis.
///
/// For example: if you set mask to word_any (selects numbe
rs, letters) then when you iterate Over "To be, or not to be?" You would
/// get "To", "be", "or", "not", "to", "be". You can reques
t from token iterator to use wider type of selection by
/// calling token_iterator::full_select(true) so it would s
elect only "To", " be", ", or", " not", " to", " be" tokens. All depends
/// on your actual needs. For word selection you would prob
ably want the first (default) and for sentence selection the second.
///
/// Changing a mask does not invalidate current iterators b
ut all new created iterators would not be compatible with old ones
/// So you can't compare them, be careful with it.
///
void mask(unsigned u)
{
mask_ = u;
}
///
/// Get \a begin iterator used when object was created
///
RangeIterator begin() const
{
return RangeIterator(*this,true,mask_);
}
///
/// Get \a end iterator used when object was created
///
RangeIterator end() const
{
return RangeIterator(*this,false,mask_);
}
private:
void create_mapping(boundary_type type,base_iterator begin,
base_iterator end,std::locale const &loc,unsigned mask)
{
index_type idx=details::mapping_traits<base_iterator>::
map(type,begin,end,loc);
index_.swap(idx);
begin_ = begin;
end_ = end;
mask_=mask;
}
template<typename I>
friend class break_iterator;
template<typename I,typename V>
friend class token_iterator;
template<typename I>
friend class mapping;
base_iterator begin_,end_;
index_type index_;
unsigned mask_;
};
///
/// \brief token_iterator is an iterator that returns text chun
ks between boundary positions
///
/// Token iterator may behave in two different ways: select spe
cific tokens in only tide way and
/// select them widely. For tide selection (default) it would n
ot return text chunks that
/// do not fit the selection mask. For example, for word iterat
ion with mask "word_letters"
/// for text "I met him at 7" it would return "I", "met", "him"
, "at" ignoring white spaces
/// punctuation and numbers, But sometimes, you need to perform
full selection of almost entry text
/// for example for sentence boundaries and sentence_term mask
you may want to specify full_select(true),
/// So "Hello! How<LF>are you?" would return you biggest possib
le chunks "Hello!", " How<LF>are you?".
///
template<
typename IteratorType,
typename ValueType = std::basic_string<typename std::iterat
or_traits<IteratorType>::value_type>
>
class token_iterator : public std::iterator<std::bidirectional_
iterator_tag,ValueType>
{
public:
///
/// The character type of the text
///
typedef typename std::iterator_traits<IteratorType>::value_
type char_type;
///
/// Underlying iterator that is used to iterate original te
xt.
///
typedef IteratorType base_iterator;
///
/// The type of mapping that iterator can iterate over it
///
typedef mapping<token_iterator<IteratorType,ValueType> > ma
pping_type;
///
/// Default constructor
///
token_iterator() :
map_(0),
offset_(0),
mask_(0xFFFFFFFF),
full_select_(false)
{
}
///
/// set position of the token iterator to the location of u
nderlying iterator.
///
/// This operator sets the token iterator to first token fo
llowing that position. For example:
///
/// For word boundary with "word_any" mask:
///
/// - "to| be or ", would point to "be",
/// - "t|o be or ", would point to "to",
/// - "to be or| ", would point to end.
///
/// \a p - should be in range of the original mapping.
///
token_iterator const &operator=(IteratorType p)
{
unsigned dist=std::distance(map_->begin_,p);
index_type::const_iterator b=map_->index_.begin(),e=map
_->index_.end();
index_type::const_iterator
bound=std::upper_bound(b,e,break_info(dist));
while(bound != e && (bound->mark & mask_)==0)
bound++;
offset_ = bound - b;
return *this;
}
///
/// Create token iterator for mapping \a map with location
at begin or end according to value of flag \a begin,
/// and a mask \a mask
///
/// It is strongly recommended to use map.begin(), map.end(
) instead.
///
token_iterator(mapping_type const &map,bool begin,unsigned
mask) :
map_(&map),
mask_(mask),
full_select_(false)
{
if(begin) {
offset_ = 0;
next();
}
else
offset_=map_->index_.size();
}
///
/// Copy constructor
///
token_iterator(token_iterator const &other) :
map_(other.map_),
offset_(other.offset_),
mask_(other.mask_),
full_select_(other.full_select_)
{
}
///
/// Assignment operator
///
token_iterator const &operator=(token_iterator const &other
)
{
if(this!=&other) {
map_ = other.map_;
offset_ = other.offset_;
mask_=other.mask_;
full_select_ = other.full_select_;
}
return *this;
}
///
/// Return the token the iterator points it. Iterator must
not point to the
/// end of the range. Throws booster::out_of_range exceptio
n
///
/// Note, returned value is not lvalue, you can't use this
iterator to assign new values to text.
///
ValueType operator*() const
{
if(offset_ < 1 || offset_ >= map_->index_.size())
throw booster::out_of_range("Invalid token iterator
location");
unsigned pos=offset_-1;
if(full_select_)
while(!valid_offset(pos))
pos--;
base_iterator b=map_->begin_;
unsigned b_off = map_->index_[pos].offset;
std::advance(b,b_off);
base_iterator e=b;
unsigned e_off = map_->index_[offset_].offset;
std::advance(e,e_off-b_off);
return ValueType(b,e);
}
///
/// Increment operator
///
token_iterator &operator++()
{
next();
return *this;
}
///
/// Decrement operator
///
token_iterator &operator--()
{
prev();
return *this;
}
///
/// Increment operator
///
token_iterator operator++(int unused)
{
token_iterator tmp(*this);
next();
return tmp;
}
///
/// Decrement operator
///
token_iterator operator--(int unused)
{
token_iterator tmp(*this);
prev();
return tmp;
}
///
/// Get full selection flag, see description of token_itera
tor
///
bool full_select() const
{
return full_select_;
}
///
/// Set full selection flag, see description of token_itera
tor
///
void full_select(bool fs)
{
full_select_ = fs;
}
///
/// Compare two iterators. They equal if they point to same
map, have same position and same mask
///
bool operator==(token_iterator const &other) const
{
return map_ == other.map_
&& offset_==other.offset_
&& mask_ == other.mask_;
}
///
/// Opposite of ===
///
bool operator!=(token_iterator const &other) const
{
return !(*this==other);
}
///
/// Return the mark that token iterator points at. See desc
ription of mapping class and various boundary flags
///
unsigned mark() const
{
return map_->index_.at(offset_).mark;
}
private:
bool valid_offset(unsigned offset) const
{
return offset == 0
|| offset == map_->index_.size()
|| (map_->index_[offset].mark & mask_)!=0;
}
bool at_end() const
{
return !map_ || offset_>=map_->index_.size();
}
void next()
{
while(offset_ < map_->index_.size()) {
offset_++;
if(valid_offset(offset_))
break;
}
}
void prev()
{
while(offset_ > 0) {
offset_ --;
if(valid_offset(offset_))
break;
}
}
mapping_type const * map_;
size_t offset_;
unsigned mask_;
uint32_t full_select_ : 1;
uint32_t reserved_ : 31;
};
///
/// \brief break_iterator is bidirectional iterator that return
s text boundary positions
///
/// It returns rather iterators to break position then text chu
nks themselves. It stops only
/// on boundaries that their marks fit the required mask. Also
beginning of text and end of
/// text are valid boundaries regardless their marks.
///
/// Please note for text in range [text_begin,text_end) and bre
ak_iterator it over it
/// in range [begin,end): if *it==text_end then it!=end. And if
it==end then *it is invalid.
/// Thus for example for work iterator over text "hello", break
iterator returns at beginning
/// text_begin ("|hello"), then text_end ("hello|") and then it
points to end.
///
template<typename IteratorType>
class break_iterator : public std::iterator<std::bidirectional_
iterator_tag,IteratorType>
{
public:
///
/// The character type of the text
///
typedef typename std::iterator_traits<IteratorType>::value_
type char_type;
///
/// Underlying iterator that is used to iterate original te
xt.
///
typedef IteratorType base_iterator;
///
/// The type of mapping that iterator can iterate over it
///
typedef mapping<break_iterator<IteratorType> > mapping_type
;
///
/// Default constructor
///
break_iterator() :
map_(0),
offset_(0),
mask_(0xFFFFFFFF)
{
}
///
/// Copy constructor
///
break_iterator(break_iterator const &other):
map_(other.map_),
offset_(other.offset_),
mask_(other.mask_)
{
}
///
/// Assignment operator
///
break_iterator const &operator=(break_iterator const &other
)
{
if(this!=&other) {
map_ = other.map_;
offset_ = other.offset_;
mask_=other.mask_;
}
return *this;
}
///
/// Create break iterator for mapping \a map with location
at begin or end according to value of flag \a begin,
/// and a mask \a mask
///
/// It is strongly recommended to use map.begin(), map.end(
) instead.
///
break_iterator(mapping_type const &map,bool begin,unsigned
mask) :
map_(&map),
mask_(mask)
{
if(begin)
offset_ = 0;
else
offset_=map_->index_.size();
}
///
/// Compare two iterators. They equal if they point to same
map, have same position and same mask
///
bool operator==(break_iterator const &other) const
{
return map_ == other.map_
&& offset_==other.offset_
&& mask_==other.mask_;
}
///
/// Opposite of ===
///
bool operator!=(break_iterator const &other) const
{
return !(*this==other);
}
///
/// Return the mark that token iterator points at. See desc
ription of mapping class and various boundary flags
///
unsigned mark() const
{
return map_->index_.at(offset_).mark;
}
///
/// set position of the break_iterator to the location of u
nderlying iterator.
///
/// This operator sets the break_iterator to position of th
e iterator p or to the first valid following position
/// For example:
///
/// For word boundary:
///
/// - "|to be or ", would point to "|to be or "
/// - "t|o be or ", would point to "to| be or "
///
/// \a p - should be in range of the original mapping.
///
break_iterator const &operator=(base_iterator p)
{
at_least(p);
return *this;
}
///
/// Return the underlying iterator that break_iterator poin
ts it. Iterator must not point to the
/// end of the range, otherwise throws booster::out_of_rang
e exception
///
/// Note, returned value is not lvalue, you can't use this
iterator to change underlying iterators.
///
base_iterator operator*() const
{
if(offset_ >=map_->index_.size())
throw booster::out_of_range("Invalid position of br
eak iterator");
base_iterator p = map_->begin_;
std::advance(p, map_->index_[offset_].offset);
return p;
}
///
/// Increment operator
///
break_iterator &operator++()
{
next();
return *this;
}
///
/// Decrement operator
///
break_iterator &operator--()
{
prev();
return *this;
}
///
/// Increment operator
///
break_iterator operator++(int unused)
{
break_iterator tmp(*this);
next();
return tmp;
}
///
/// Decrement operator
///
break_iterator operator--(int unused)
{
break_iterator tmp(*this);
prev();
return tmp;
}
private:
bool valid_offset(unsigned offset) const
{
return offset == 0
|| offset + 1 >= map_->index_.size() // last an
d first are always valid regardless of mark
|| (map_->index_[offset].mark & mask_)!=0;
}
bool at_end() const
{
return !map_ || offset_>=map_->index_.size();
}
void next()
{
while(offset_ < map_->index_.size()) {
offset_++;
if(valid_offset(offset_))
break;
}
}
void prev()
{
while(offset_ > 0) {
offset_ --;
if(valid_offset(offset_))
break;
}
}
void at_least(IteratorType p)
{
unsigned diff = std::distance(map_->begin_,p);
index_type::const_iterator b=map_->index_.begin();
index_type::const_iterator e=map_->index_.end();
index_type::const_iterator ptr = std::lower_bound(b,e,b
reak_info(diff));
if(ptr==map_->index_.end())
offset_=map_->index_.size()-1;
else
offset_=ptr - map_->index_.begin();
while(!valid_offset(offset_))
offset_ ++;
}
mapping_type const * map_;
size_t offset_;
unsigned mask_;
uint32_t reserved_;
};
///
/// @}
///
} // boundary
} // locale
} // boost
///
/// \example boundary.cpp
/// Example of using boundary iterator
/// \example wboundary.cpp
/// Example of using boundary iterator over wide strings
///
#ifdef BOOSTER_MSVC
#pragma warning(pop)
#endif
#endif #endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 End of changes. 1 change blocks. 
1119 lines changed or deleted 5 lines changed or added


 build_config.h   build_config.h 
skipping to change at line 64 skipping to change at line 64
// //
#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
#endif #endif
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 callback.h   callback.h 
skipping to change at line 112 skipping to change at line 112
/// ///
/// Swaps two callbackal object. Does not throw. /// Swaps two callbackal object. Does not throw.
/// ///
void swap(callback &other); void swap(callback &other);
}; };
#else #else
#define BOOSTER_CALLBACK \ #define BOOSTER_CALLBACK \
template<typename Result BOOSTER_TEMPLATE_PARAMS > \ template<typename Result BOOSTER_TEMPLATE_PARAMS > \
struct callable<Result(BOOSTER_TYPE_PARAMS)> : public refcounted { struct callable<Result(BOOSTER_TEMPLATE_TYPE_PARAMS)> :public refcou
\ nted\
{
\
virtual Result operator()(BOOSTER_TYPE_PARAMS) = 0; \ virtual Result operator()(BOOSTER_TYPE_PARAMS) = 0; \
virtual ~callable(){} \ virtual ~callable(){} \
}; \ }; \
\ \
template<typename Result BOOSTER_TEMPLATE_PARAMS > \ template<typename Result BOOSTER_TEMPLATE_PARAMS > \
class callback<Result(BOOSTER_TYPE_PARAMS)> \ class callback<Result(BOOSTER_TEMPLATE_TYPE_PARAMS)> \
{ \ { \
public: \ public: \
typedef Result result_type; \ typedef Result result_type; \
\ \
typedef callable<Result(BOOSTER_TYPE_PARAMS)> callable_type; typedef callable<Result(BOOSTER_TEMPLATE_TYPE_PARAMS)>
\ \
callable_type;
\
\ \
template<typename R,typename F> \ template<typename R,typename F> \
struct callable_impl : public callable_type { \ struct callable_impl : public callable_type { \
F func; \ F func; \
callable_impl(F f) : func(f){} \ callable_impl(F f) : func(f){} \
virtual R operator()(BOOSTER_TYPE_PARAMS) \ virtual R operator()(BOOSTER_TYPE_PARAMS) \
{ return func(BOOSTER_CALL_PARAMS); } \ { return func(BOOSTER_CALL_PARAMS); } \
}; \ }; \
\ \
template<typename F> \ template<typename F> \
skipping to change at line 195 skipping to change at line 197
\ \
operator bool() const { return !empty(); } \ operator bool() const { return !empty(); } \
\ \
void swap(callback &other) { call_ptr.swap(other.call_ptr); } \ void swap(callback &other) { call_ptr.swap(other.call_ptr); } \
\ \
private: \ private: \
intrusive_ptr<callable_type> call_ptr; \ intrusive_ptr<callable_type> call_ptr; \
}; \ }; \
#define BOOSTER_TEMPLATE_PARAMS #define BOOSTER_TEMPLATE_PARAMS
#define BOOSTER_TEMPLATE_TYPE_PARAMS
#define BOOSTER_TYPE_PARAMS #define BOOSTER_TYPE_PARAMS
#define BOOSTER_CALL_PARAMS #define BOOSTER_CALL_PARAMS
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1 #define BOOSTER_TEMPLATE_PARAMS ,typename P1
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1
#define BOOSTER_TYPE_PARAMS P1 a1 #define BOOSTER_TYPE_PARAMS P1 a1
#define BOOSTER_CALL_PARAMS a1 #define BOOSTER_CALL_PARAMS a1
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2
#define BOOSTER_CALL_PARAMS a1,a2 #define BOOSTER_CALL_PARAMS a1,a2
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3
#define BOOSTER_CALL_PARAMS a1,a2,a3 #define BOOSTER_CALL_PARAMS a1,a2,a3
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6, P7
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7,typename P8 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7,typename P8
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6, P7, P8
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7,P8 a8 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7,P8 a8
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7,a8 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7,a8
BOOSTER_CALLBACK BOOSTER_CALLBACK
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#undef BOOSTER_CALLBACK #undef BOOSTER_CALLBACK
#endif // DOC #endif // DOC
} // booster } // booster
#endif #endif
 End of changes. 23 change blocks. 
5 lines changed or deleted 29 lines changed or added


 clone_ptr.h   clone_ptr.h 
skipping to change at line 22 skipping to change at line 22
/// ///
/// \brief a smart pointer similar to std::auto_ptr but it clones (b y calling T::clone()) /// \brief a smart pointer similar to std::auto_ptr but it clones (b y calling T::clone())
/// underlying object on copy instead of moving its ownership. /// underlying object on copy instead of moving its ownership.
/// ///
template<typename T> template<typename T>
class clone_ptr { class clone_ptr {
T *ptr_; T *ptr_;
public: public:
clone_ptr() : ptr_(0) {} clone_ptr() : ptr_(0) {}
clone_ptr(T *v) : ptr_(v) {} explicit clone_ptr(T *v) : ptr_(v) {}
clone_ptr(clone_ptr const &other) : ptr_(0) clone_ptr(clone_ptr const &other) : ptr_(0)
{ {
if(other.ptr_) if(other.ptr_)
ptr_=other.ptr_->clone(); ptr_=other.ptr_->clone();
} }
clone_ptr const &operator=(clone_ptr const &other) clone_ptr const &operator=(clone_ptr const &other)
{ {
if(this != &other) { if(this != &other) {
if(ptr_) { clone_ptr tmp(other);
delete ptr_; swap(tmp);
ptr_=0;
}
if(other.ptr_) {
ptr_=other.ptr_->clone();
}
} }
return *this; return *this;
} }
~clone_ptr() { ~clone_ptr() {
if(ptr_) delete ptr_; if(ptr_) delete ptr_;
} }
T *get() const { return ptr_; } T *get() const { return ptr_; }
T &operator *() const { return *ptr_; } T &operator *() const { return *ptr_; }
T *operator->() const { return ptr_; } T *operator->() const { return ptr_; }
 End of changes. 2 change blocks. 
8 lines changed or deleted 3 lines changed or added


 config.h   config.h 
skipping to change at line 12 skipping to change at line 12
// Copyright (c) 2010 Artyom Beilis (Tonkikh) // Copyright (c) 2010 Artyom Beilis (Tonkikh)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_CONFIG_H #ifndef BOOSTER_CONFIG_H
#define BOOSTER_CONFIG_H #define BOOSTER_CONFIG_H
#if defined(__WIN32) || defined(_WIN32) || defined(WIN32) || defined(__CYGW IN__) #if defined(__WIN32) || defined(_WIN32) || defined(WIN32) || defined(__CYGW IN__)
# define BOOSTER_SYMBOL_VISIBLE
# if defined(DLL_EXPORT) # if defined(DLL_EXPORT)
# if defined(BOOSTER_SOURCE) # if defined(BOOSTER_SOURCE)
# define BOOSTER_API __declspec(dllexport) # define BOOSTER_API __declspec(dllexport)
# else # else
# define BOOSTER_API __declspec(dllimport) # define BOOSTER_API __declspec(dllimport)
# endif # endif
# else # else
# define BOOSTER_API # define BOOSTER_API
# endif # endif
#else // ELF BINARIES #else // ELF BINARIES
# if defined(BOOSTER_SOURCE) && defined(BOOSTER_VISIBILITY_SUPPORT) # if defined(BOOSTER_SOURCE) && defined(BOOSTER_VISIBILITY_SUPPORT)
# define BOOSTER_API __attribute__ ((visibility("default"))) # define BOOSTER_API __attribute__ ((visibility("default")))
# define BOOSTER_SYMBOL_VISIBLE __attribute__ ((visibility("de fault")))
# else # else
# define BOOSTER_API # define BOOSTER_API
# define BOOSTER_SYMBOL_VISIBLE
# endif # endif
#endif #endif
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__C YGWIN__) #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__C YGWIN__)
#define BOOSTER_WIN_NATIVE #define BOOSTER_WIN_NATIVE
#endif #endif
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
#define BOOSTER_CYGWIN #define BOOSTER_CYGWIN
#endif #endif
skipping to change at line 54 skipping to change at line 57
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define BOOSTER_MSVC #define BOOSTER_MSVC
// This warning is really not revevant // This warning is really not revevant
#pragma warning (disable: 4275 4251) #pragma warning (disable: 4275 4251)
#endif #endif
#undef BOOSTER_HAS_CHAR16_T #undef BOOSTER_HAS_CHAR16_T
#undef BOOSTER_HAS_CHAR32_T #undef BOOSTER_HAS_CHAR32_T
#undef BOOSTER_NO_STD_WSTRING #undef BOOSTER_NO_STD_WSTRING
#undef BOOST_NO_SWPRINTF #undef BOOSTER_NO_SWPRINTF
#ifdef __GNUC__ #ifdef __GNUC__
# define BOOSTER_GCC # define BOOSTER_GCC
#endif #endif
#if defined(__GNUC__) && __GNUC__ < 4 #if defined(__GNUC__) && __GNUC__ < 4
# define BOOSTER_GCC3 # define BOOSTER_GCC3
#endif #endif
#if defined(__CYGWIN__) || (defined(BOOSTER_WIN32) && defined(BOOSTER_GCC3) ) #if defined(__CYGWIN__) || (defined(BOOSTER_WIN32) && defined(BOOSTER_GCC3) )
 End of changes. 4 change blocks. 
1 lines changed or deleted 4 lines changed or added


 conversion.h   conversion.h 
skipping to change at line 29 skipping to change at line 29
namespace locale { namespace locale {
/// ///
/// \defgroup convert Text Conversions /// \defgroup convert Text Conversions
/// ///
/// This module provides various function for string manipulation like Unicode normalization, case conversion etc. /// This module provides various function for string manipulation like Unicode normalization, case conversion etc.
/// @{ /// @{
/// ///
/// ///
/// This class provides base flags for text manipulation, it is use d as base for converter facet. /// \brief This class provides base flags for text manipulation. It is used as base for converter facet.
/// ///
class converter_base { class converter_base {
public: public:
/// ///
/// The flag used for facet - the type of operation to perform /// The flag used for facet - the type of operation to perform
/// ///
typedef enum { typedef enum {
normalization, ///< Apply Unicode normalization on the tex t normalization, ///< Apply Unicode normalization on the tex t
upper_case, ///< Convert text to upper case upper_case, ///< Convert text to upper case
lower_case, ///< Convert text to lower case lower_case, ///< Convert text to lower case
case_folding, ///< Fold case in the text case_folding, ///< Fold case in the text
title_case ///< Convert text to title case title_case ///< Convert text to title case
} conversion_type; } conversion_type;
}; };
template<typename CharType> template<typename CharType>
class converter; class converter;
#ifdef BOOSTER_LOCALE_DOXYGEN
/// ///
/// The facet that implements text manipulation /// \brief The facet that implements text manipulation
/// ///
template<> /// It is used to performs text conversion operations defined by \r
class BOOSTER_API converter<char> : public converter_base, public s ef conversion_type. It is specialized
td::locale::facet { /// for four types of characters \c char, \c wchar_t, \c char16_t,
\c char32_t
///
template<typename Char>
class BOOSTER_API converter: public converter_base, public std::loc
ale::facet {
public: public:
/// Locale identification /// Locale identification
static std::locale::id id; static std::locale::id id;
/// Standard constructor /// Standard constructor
converter(size_t refs = 0) : std::locale::facet(refs) converter(size_t refs = 0) : std::locale::facet(refs)
{ {
} }
/// ///
/// Convert text in range [\a begin, \a end) according to conve rsion method \a how. Parameter /// Convert text in range [\a begin, \a end) according to conve rsion method \a how. Parameter
/// \a flags is used for specification of normalization method like nfd, nfc etc. /// \a flags is used for specification of normalization method like nfd, nfc etc.
/// ///
virtual std::basic_string<Char> convert(conversion_type how,Cha
r const *begin,Char const *end,int flags = 0) const = 0;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
};
#else
template<>
class BOOSTER_API converter<char> : public converter_base, public s
td::locale::facet {
public:
static std::locale::id id;
converter(size_t refs = 0) : std::locale::facet(refs)
{
}
virtual std::string convert(conversion_type how,char const *beg in,char const *end,int flags = 0) const = 0; virtual std::string convert(conversion_type how,char const *beg in,char const *end,int flags = 0) const = 0;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER) #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; } std::locale::id& __get_id (void) const { return id; }
#endif #endif
}; };
///
/// The facet that implements text manipulation
///
template<> template<>
class BOOSTER_API converter<wchar_t> : public converter_base, publi c std::locale::facet { class BOOSTER_API converter<wchar_t> : public converter_base, publi c std::locale::facet {
public: public:
/// Locale identification
static std::locale::id id; static std::locale::id id;
/// Standard constructor
converter(size_t refs = 0) : std::locale::facet(refs) converter(size_t refs = 0) : std::locale::facet(refs)
{ {
} }
///
/// Convert text in range [\a begin, \a end) according to conve
rsion method \a how. Parameter
/// \a flags is used for specification of normalization method
like nfd, nfc etc.
///
virtual std::wstring convert(conversion_type how,wchar_t const *begin,wchar_t const *end,int flags = 0) const = 0; virtual std::wstring convert(conversion_type how,wchar_t const *begin,wchar_t const *end,int flags = 0) const = 0;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER) #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; } std::locale::id& __get_id (void) const { return id; }
#endif #endif
}; };
#ifdef BOOSTER_HAS_CHAR16_T #ifdef BOOSTER_HAS_CHAR16_T
template<> template<>
class BOOSTER_API converter<char16_t> : public converter_base, publ ic std::locale::facet { class BOOSTER_API converter<char16_t> : public converter_base, publ ic std::locale::facet {
public: public:
skipping to change at line 123 skipping to change at line 133
converter(size_t refs = 0) : std::locale::facet(refs) converter(size_t refs = 0) : std::locale::facet(refs)
{ {
} }
virtual std::u32string convert(conversion_type how,char32_t con st *begin,char32_t const *end,int flags = 0) const = 0; virtual std::u32string convert(conversion_type how,char32_t con st *begin,char32_t const *end,int flags = 0) const = 0;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER) #if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; } std::locale::id& __get_id (void) const { return id; }
#endif #endif
}; };
#endif #endif
#endif
/// ///
/// Type of normalization /// The type that defined <a href="http://unicode.org/reports/tr15/ #Norm_Forms">normalization form</a>
/// ///
typedef enum { typedef enum {
norm_nfd, ///< Canonical decomposition norm_nfd, ///< Canonical decomposition
norm_nfc, ///< Canonical decomposition followed by canonical composition norm_nfc, ///< Canonical decomposition followed by canonical composition
norm_nfkd, ///< Compatibility decomposition norm_nfkd, ///< Compatibility decomposition
norm_nfkc, ///< Compatibility decomposition followed by canoni cal composition. norm_nfkc, ///< Compatibility decomposition followed by canoni cal composition.
norm_default = norm_nfc, ///< Default normalization - canonical decomposition followed by canonical composition norm_default = norm_nfc, ///< Default normalization - canonical decomposition followed by canonical composition
} norm_type; } norm_type;
/// ///
/// Normalize Unicode string \a str according to normalization mode \a n /// Normalize Unicode string \a str according to \ref norm_type "no rmalization form" \a n
/// ///
/// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not takes /// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not take
/// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside /// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside
/// of Unicode character set. /// of a Unicode character set.
///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
/// ///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> normalize(std::basic_string<CharType> c onst &str,norm_type n=norm_default,std::locale const &loc=std::locale()) std::basic_string<CharType> normalize(std::basic_string<CharType> c onst &str,norm_type n=norm_default,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,str.data(),str.data() + str.size(),n); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,str.data(),str.data() + str.size(),n);
} }
/// ///
/// Normalize NUL terminated Unicode string \a str according to nor malization mode \a n /// Normalize NUL terminated Unicode string \a str according to \re f norm_type "normalization form" \a n
/// ///
/// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not takes /// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not take
/// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside /// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside
/// of Unicode character set. /// of a Unicode character set.
///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
/// ///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> normalize(CharType const *str,norm_type n=norm_default,std::locale const &loc=std::locale()) std::basic_string<CharType> normalize(CharType const *str,norm_type n=norm_default,std::locale const &loc=std::locale())
{ {
CharType const *end=str; CharType const *end=str;
while(*end) while(*end)
end++; end++;
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,str,end,n); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,str,end,n);
} }
/// ///
/// Normalize Unicode string in range [begin,end) according to norm alization mode \a n /// Normalize Unicode string in range [begin,end) according to \ref norm_type "normalization form" \a n
/// ///
/// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not takes /// Note: This function receives only Unicode strings, i.e.: UTF-8, UTF-16 or UTF-32. It does not take
/// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside /// in account the locale encoding, because Unicode decomposition a nd composition are meaningless outside
/// of Unicode character set. /// of a Unicode character set.
///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
/// ///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> normalize(CharType const *begin,CharTyp std::basic_string<CharType> normalize( CharType const *begin,
e const *end,norm_type n=norm_default,std::locale const &loc=std::locale()) CharType const *end,
norm_type n=norm_default,
std::locale const &loc=std:
:locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,begin,end,n); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::normalization,begin,end,n);
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
/// ///
/// Convert a string \a str to upper case according to locale \a lo c /// Convert a string \a str to upper case according to locale \a lo c
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_upper(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale()) std::basic_string<CharType> to_upper(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,str.data(),str.data()+str.size()); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,str.data(),str.data()+str.size());
} }
/// ///
/// Convert a NUL terminated string \a str to upper case according to locale \a loc /// Convert a NUL terminated string \a str to upper case according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_upper(CharType const *str,std::local e const &loc=std::locale()) std::basic_string<CharType> to_upper(CharType const *str,std::local e const &loc=std::locale())
{ {
CharType const *end=str; CharType const *end=str;
while(*end) while(*end)
end++; end++;
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,str,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,str,end);
} }
/// ///
/// Convert a string in range [begin,end) to upper case according t o locale \a loc /// Convert a string in range [begin,end) to upper case according t o locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_upper(CharType const *begin,CharType const *end,std::locale const &loc=std::locale()) std::basic_string<CharType> to_upper(CharType const *begin,CharType const *end,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,begin,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::upper_case,begin,end);
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
/// ///
/// Convert a string \a str to lower case according to locale \a lo c /// Convert a string \a str to lower case according to locale \a lo c
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_lower(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale()) std::basic_string<CharType> to_lower(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,str.data(),str.data()+str.size()); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,str.data(),str.data()+str.size());
} }
/// ///
/// Convert a NUL terminated string \a str to lower case according to locale \a loc /// Convert a NUL terminated string \a str to lower case according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_lower(CharType const *str,std::local e const &loc=std::locale()) std::basic_string<CharType> to_lower(CharType const *str,std::local e const &loc=std::locale())
{ {
CharType const *end=str; CharType const *end=str;
while(*end) while(*end)
end++; end++;
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,str,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,str,end);
} }
/// ///
/// Convert a string in range [begin,end) to lower case according t o locale \a loc /// Convert a string in range [begin,end) to lower case according t o locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_lower(CharType const *begin,CharType const *end,std::locale const &loc=std::locale()) std::basic_string<CharType> to_lower(CharType const *begin,CharType const *end,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,begin,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::lower_case,begin,end);
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
/// ///
/// Convert a string \a str to title case according to locale \a lo c /// Convert a string \a str to title case according to locale \a lo c
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_title(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale()) std::basic_string<CharType> to_title(std::basic_string<CharType> co nst &str,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,str.data(),str.data()+str.size()); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,str.data(),str.data()+str.size());
} }
/// ///
/// Convert a NUL terminated string \a str to title case according to locale \a loc /// Convert a NUL terminated string \a str to title case according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_title(CharType const *str,std::local e const &loc=std::locale()) std::basic_string<CharType> to_title(CharType const *str,std::local e const &loc=std::locale())
{ {
CharType const *end=str; CharType const *end=str;
while(*end) while(*end)
end++; end++;
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,str,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,str,end);
} }
/// ///
/// Convert a string in range [begin,end) to title case according t o locale \a loc /// Convert a string in range [begin,end) to title case according t o locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_title(CharType const *begin,CharType const *end,std::locale const &loc=std::locale()) std::basic_string<CharType> to_title(CharType const *begin,CharType const *end,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,begin,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::title_case,begin,end);
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
/// ///
/// Fold case of a string \a str according to locale \a loc /// Fold case of a string \a str according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> fold_case(std::basic_string<CharType> c onst &str,std::locale const &loc=std::locale()) std::basic_string<CharType> fold_case(std::basic_string<CharType> c onst &str,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,str.data(),str.data()+str.size()); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,str.data(),str.data()+str.size());
} }
/// ///
/// Fold case of a NUL terminated string \a str according to locale \a loc /// Fold case of a NUL terminated string \a str according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> fold_case(CharType const *str,std::loca le const &loc=std::locale()) std::basic_string<CharType> fold_case(CharType const *str,std::loca le const &loc=std::locale())
{ {
CharType const *end=str; CharType const *end=str;
while(*end) while(*end)
end++; end++;
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,str,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,str,end);
} }
/// ///
/// Fold case of a string in range [begin,end) according to locale \a loc /// Fold case of a string in range [begin,end) according to locale \a loc
/// ///
/// \note throws std::bad_cast if loc does not have \ref converter
facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> fold_case(CharType const *begin,CharTyp e const *end,std::locale const &loc=std::locale()) std::basic_string<CharType> fold_case(CharType const *begin,CharTyp e const *end,std::locale const &loc=std::locale())
{ {
return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,begin,end); return std::use_facet<converter<CharType> >(loc).convert(conver ter_base::case_folding,begin,end);
} }
/// ///
///@} ///@}
/// ///
} // locale } // locale
 End of changes. 33 change blocks. 
28 lines changed or deleted 90 lines changed or added


 copy_ptr.h   copy_ptr.h 
skipping to change at line 26 skipping to change at line 26
/// ///
/// Note: Underlying object has same constness as the pointer itself (not like in ordinary pointer). /// Note: Underlying object has same constness as the pointer itself (not like in ordinary pointer).
/// ///
/// Don't use it with polymorphic classes. Prefer clone_ptr instead. /// Don't use it with polymorphic classes. Prefer clone_ptr instead.
/// ///
template<typename T> template<typename T>
class copy_ptr { class copy_ptr {
T *ptr_; T *ptr_;
public: public:
copy_ptr() : ptr_(0) {} copy_ptr() : ptr_(0) {}
copy_ptr(T *v) : ptr_(v) {} explicit copy_ptr(T *v) : ptr_(v) {}
copy_ptr(copy_ptr const &other) : copy_ptr(copy_ptr const &other) :
ptr_(other.ptr_ ? new T(*other.ptr_) : 0) ptr_(other.ptr_ ? new T(*other.ptr_) : 0)
{ {
} }
copy_ptr const &operator=(copy_ptr const &other) copy_ptr const &operator=(copy_ptr const &other)
{ {
if(this != &other) { if(this != &other) {
if(ptr_) { copy_ptr tmp(other);
delete ptr_; swap(tmp);
ptr_=0;
}
if(other.ptr_) {
ptr_=new T(*other.ptr_);
}
} }
return *this; return *this;
} }
~copy_ptr() { ~copy_ptr() {
if(ptr_) delete ptr_; if(ptr_) delete ptr_;
} }
T const *get() const { return ptr_; } T const *get() const { return ptr_; }
T *get() { return ptr_; } T *get() { return ptr_; }
 End of changes. 2 change blocks. 
8 lines changed or deleted 3 lines changed or added


 ctime.h   ctime.h 
skipping to change at line 13 skipping to change at line 13
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_CTIME_H #ifndef BOOSTER_CTIME_H
#define BOOSTER_CTIME_H #define BOOSTER_CTIME_H
#include <booster/config.h> #include <booster/config.h>
#include <ctime> #include <ctime>
#include <time.h>
namespace booster { namespace booster {
/// ///
/// Convert POSIX time to local time. Effectivly works as C localtim e /// Convert POSIX time to local time. Effectivly works as C localtim e
/// ///
BOOSTER_API std::tm local_time(time_t pt); BOOSTER_API std::tm local_time(time_t pt);
/// ///
/// Convert POSIX time to GMT time. Effectivly works as C gmtime /// Convert POSIX time to GMT time. Effectivly works as C gmtime
/// ///
BOOSTER_API std::tm universal_time(time_t pt); BOOSTER_API std::tm universal_time(time_t pt);
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 date_time.h   date_time.h 
skipping to change at line 19 skipping to change at line 19
#define BOOSTER_LOCALE_DATE_TIME_H_INCLUDED #define BOOSTER_LOCALE_DATE_TIME_H_INCLUDED
#include <booster/config.h> #include <booster/config.h>
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
# pragma warning(push) # pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660) # pragma warning(disable : 4275 4251 4231 4660)
#endif #endif
#include <booster/locale/hold_ptr.h> #include <booster/locale/hold_ptr.h>
#include <booster/locale/date_time_facet.h> #include <booster/locale/date_time_facet.h>
#include <booster/locale/formatting.h>
#include <booster/locale/time_zone.h>
#include <locale> #include <locale>
#include <vector> #include <vector>
#include <booster/backtrace.h> #include <booster/backtrace.h>
namespace booster { namespace booster {
namespace locale { namespace locale {
/// ///
/// \defgroup date_time Date, Time, Timezone and Calendar manipulat ions /// \defgroup date_time Date, Time, Timezone and Calendar manipulat ions
/// ///
/// This module provides various calendar, timezone and date time s ervices /// This module provides various calendar, timezone and date time s ervices
/// ///
/// @{ /// @{
/// ///
/// \brief This error is thrown in case of invalid state that occur red /// \brief This error is thrown in case of invalid state that occur red
/// ///
class date_time_error : public booster::runtime_error { class BOOSTER_SYMBOL_VISIBLE date_time_error : public booster::runt ime_error {
public: public:
/// ///
/// Constructor of date_time_error class /// Constructor of date_time_error class
/// ///
date_time_error(std::string const &e) : booster::runtime_error( e) {} date_time_error(std::string const &e) : booster::runtime_error( e) {}
}; };
/// ///
/// \brief This structure provides a pair period_type and amount. /// \brief This class represents a pair of period_type and the inte
ger
/// values that describes its amount. For example 3 days or 4 years
.
/// ///
/// Usually obtained as product of period_type and integer. /// Usually obtained as product of period_type and integer or
/// For example day*3 == date_time_period(day,3) /// my calling a representative functions
/// For example day()*3 == date_time_period(day(),3) == day(3)
/// ///
struct date_time_period struct date_time_period
{ {
period::period_type type; ///< The type of period, i.e. era, year, day etc. period::period_type type; ///< The type of period, i.e. era, year, day etc.
int value; ///< The value the actual number of \a periods int value; ///< The value the actual number of \a periods
/// ///
/// Operator + returns copy of itself /// Operator + returns copy of itself
/// ///
date_time_period operator+() const { return *this; } date_time_period operator+() const { return *this; }
/// ///
/// Operator -, switches the sign of period /// Operator -, switches the sign of period
/// ///
date_time_period operator-() const { return date_time_period(ty pe,-value); } date_time_period operator-() const { return date_time_period(ty pe,-value); }
/// ///
/// Constructor that creates date_time_period from period_type \a f and a value \a v -- default 1. /// Constructor that creates date_time_period from period_type \a f and a value \a v -- default 1.
/// ///
date_time_period(period::period_type f=period::invalid,int v=1) : type(f), value(v) {} date_time_period(period::period_type f=period::period_type(),in t v=1) : type(f), value(v) {}
}; };
namespace period { namespace period {
/// ///
/// Predefined constant for January /// Get period_type for: special invalid value, should not be used directly
/// ///
static const date_time_period january(month,0); inline period_type invalid(){ return period_type(marks::invalid ); }
/// ///
/// Predefined constant for February /// Get period_type for: Era i.e. AC, BC in Gregorian and Juli an calendar, range [0,1]
/// ///
static const date_time_period february(month,1); inline period_type era(){ return period_type(marks::era); }
/// ///
/// Predefined constant for March /// Get period_type for: Year, it is calendar specific, for ex ample 2011 in Gregorian calendar.
/// ///
static const date_time_period march(month,2); inline period_type year(){ return period_type(marks::year); }
/// ///
/// Predefined constant for April /// Get period_type for: Extended year for Gregorian/Julian ca lendars, where 1 BC == 0, 2 BC == -1.
/// ///
static const date_time_period april(month,3); inline period_type extended_year(){ return period_type(marks::e xtended_year); }
/// ///
/// Predefined constant for May /// Get period_type for: The month of year, calendar specific, in Gregorian [0..11]
/// ///
static const date_time_period may(month,4); inline period_type month(){ return period_type(marks::month); }
/// ///
/// Predefined constant for June /// Get period_type for: The day of month, calendar specific, in Gregorian [1..31]
/// ///
static const date_time_period june(month,5); inline period_type day(){ return period_type(marks::day); }
/// ///
/// Predefined constant for July /// Get period_type for: The number of day in year, starting f rom 1, in Gregorian [1..366]
/// ///
static const date_time_period july(month,6); inline period_type day_of_year(){ return period_type(marks::day _of_year); }
/// ///
/// Predefined constant for August /// Get period_type for: Day of week, Sunday=1, Monday=2,..., Saturday=7.
/// ///
static const date_time_period august(month,7); /// Note that that updating this value respects local day of we
ek, so for example,
/// If first day of week is Monday and the current day is Tuesd
ay then setting
/// the value to Sunday (1) would forward the date by 5 days fo
rward and not backward
/// by two days as it could be expected if the numbers were tak
en as is.
/// ///
/// Predefined constant for September inline period_type day_of_week(){ return period_type(marks::day _of_week); }
/// ///
static const date_time_period september(month,8); /// Get period_type for: Original number of the day of the wee
k in month. For example 1st Sunday,
/// 2nd Sunday, etc. in Gregorian [1..5]
/// ///
/// Predefined constant for October inline period_type day_of_week_in_month(){ return period_type(m arks::day_of_week_in_month); }
/// ///
static const date_time_period october(month,9); /// Get period_type for: Local day of week, for example in Fra nce Monday is 1, in US Sunday is 1, [1..7]
/// ///
/// Predefined constant for November inline period_type day_of_week_local(){ return period_type(mark s::day_of_week_local); }
/// ///
static const date_time_period november(month,10); /// Get period_type for: 24 clock hour [0..23]
/// ///
/// Predefined constant for December inline period_type hour(){ return period_type(marks::hour); }
/// ///
static const date_time_period december(month,11); /// Get period_type for: 12 clock hour [0..11]
///
inline period_type hour_12(){ return period_type(marks::hour_12
); }
///
/// Get period_type for: am or pm marker [0..1]
///
inline period_type am_pm(){ return period_type(marks::am_pm); }
///
/// Get period_type for: minute [0..59]
///
inline period_type minute(){ return period_type(marks::minute);
}
///
/// Get period_type for: second [0..59]
///
inline period_type second(){ return period_type(marks::second);
}
///
/// Get period_type for: The week number in the year
///
inline period_type week_of_year(){ return period_type(marks::we
ek_of_year); }
///
/// Get period_type for: The week number within current month
///
inline period_type week_of_month(){ return period_type(marks::w
eek_of_month); }
///
/// Get period_type for: First day of week, constant, for exam
ple Sunday in US = 1, Monday in France = 2
///
inline period_type first_day_of_week(){ return period_type(mark
s::first_day_of_week); }
/// ///
/// Predefined constant for Sunday /// Get date_time_period for: Era i.e. AC, BC in Gregorian and Julian calendar, range [0,1]
/// ///
static const date_time_period sunday(day_of_week,1); inline date_time_period era(int v) { return date_time_period(er a(),v); }
/// ///
/// Predefined constant for Monday /// Get date_time_period for: Year, it is calendar specific, f or example 2011 in Gregorian calendar.
/// ///
static const date_time_period monday(day_of_week,2); inline date_time_period year(int v) { return date_time_period(y ear(),v); }
/// ///
/// Predefined constant for Tuesday /// Get date_time_period for: Extended year for Gregorian/Juli an calendars, where 1 BC == 0, 2 BC == -1.
/// ///
static const date_time_period tuesday(day_of_week,3); inline date_time_period extended_year(int v) { return date_time _period(extended_year(),v); }
/// ///
/// Predefined constant for Wednesday /// Get date_time_period for: The month of year, calendar spec ific, in Gregorian [0..11]
/// ///
static const date_time_period wednesday(day_of_week,4); inline date_time_period month(int v) { return date_time_period( month(),v); }
/// ///
/// Predefined constant for Thursday /// Get date_time_period for: The day of month, calendar speci fic, in Gregorian [1..31]
/// ///
static const date_time_period thursday(day_of_week,5); inline date_time_period day(int v) { return date_time_period(da y(),v); }
/// ///
/// Predefined constant for Friday /// Get date_time_period for: The number of day in year, start ing from 1, in Gregorian [1..366]
/// ///
static const date_time_period friday(day_of_week,6); inline date_time_period day_of_year(int v) { return date_time_p eriod(day_of_year(),v); }
/// ///
/// Predefined constant for Saturday /// Get date_time_period for: Day of week, Sunday=1, Monday=2, ..., Saturday=7.
/// ///
static const date_time_period saturday(day_of_week,7); /// Note that that updating this value respects local day of we
ek, so for example,
/// If first day of week is Monday and the current day is Tuesd
ay then setting
/// the value to Sunday (1) would forward the date by 5 days fo
rward and not backward
/// by two days as it could be expected if the numbers were tak
en as is.
/// ///
/// Predefined constant for AM (Ante Meridiem) inline date_time_period day_of_week(int v) { return date_time_p eriod(day_of_week(),v); }
/// ///
static const date_time_period am(am_pm,0); /// Get date_time_period for: Original number of the day of th
e week in month. For example 1st Sunday,
/// 2nd Sunday, etc. in Gregorian [1..5]
/// ///
/// Predefined constant for PM (Post Meridiem) inline date_time_period day_of_week_in_month(int v) { return da te_time_period(day_of_week_in_month(),v); }
/// ///
static const date_time_period pm(am_pm,1); /// Get date_time_period for: Local day of week, for example i
n France Monday is 1, in US Sunday is 1, [1..7]
/// ///
/// convers period_type to date_time_period(f,1) inline date_time_period day_of_week_local(int v) { return date_ time_period(day_of_week_local(),v); }
/// ///
inline date_time_period operator+(period::period_type f) /// Get date_time_period for: 24 clock hour [0..23]
{
return date_time_period(f);
}
/// ///
/// convers period_type to date_time_period(f,-1) inline date_time_period hour(int v) { return date_time_period(h our(),v); }
/// ///
inline date_time_period operator-(period::period_type f) /// Get date_time_period for: 12 clock hour [0..11]
{
return date_time_period(f,-1);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period hour_12(int v) { return date_time_perio d(hour_12(),v); }
/// ///
inline date_time_period operator*(period::period_type f,char v) /// Get date_time_period for: am or pm marker [0..1]
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period am_pm(int v) { return date_time_period( am_pm(),v); }
/// ///
inline date_time_period operator*(char v,period::period_type f) /// Get date_time_period for: minute [0..59]
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period minute(int v) { return date_time_period (minute(),v); }
/// ///
inline date_time_period operator*(char v,date_time_period f) /// Get date_time_period for: second [0..59]
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period second(int v) { return date_time_period (second(),v); }
/// ///
inline date_time_period operator*(date_time_period f,char v) /// Get date_time_period for: The week number in the year
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period week_of_year(int v) { return date_time_ period(week_of_year(),v); }
/// ///
inline date_time_period operator*(period::period_type f,short i /// Get date_time_period for: The week number within current m
nt v) onth
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. inline date_time_period week_of_month(int v) { return date_time _period(week_of_month(),v); }
/// ///
inline date_time_period operator*(short int v,period::period_ty /// Get date_time_period for: First day of week, constant, for
pe f) example Sunday in US = 1, Monday in France = 2
{ ///
return date_time_period(f,v); inline date_time_period first_day_of_week(int v) { return date_
} time_period(first_day_of_week(),v); }
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for January
/// ///
inline date_time_period operator*(short int v,date_time_period inline date_time_period january() { return date_time_period(mon
f) th(),0); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for February
/// ///
inline date_time_period operator*(date_time_period f,short int inline date_time_period february() { return date_time_period(mo
v) nth(),1); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for March
/// ///
inline date_time_period operator*(period::period_type f,int v) inline date_time_period march() { return date_time_period(month
{ (),2); }
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for April
/// ///
inline date_time_period operator*(int v,period::period_type f) inline date_time_period april() { return date_time_period(month
{ (),3); }
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for May
/// ///
inline date_time_period operator*(int v,date_time_period f) inline date_time_period may() { return date_time_period(month()
{ ,4); }
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for June
/// ///
inline date_time_period operator*(date_time_period f,int v) inline date_time_period june() { return date_time_period(month(
{ ),5); }
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for July
/// ///
inline date_time_period operator*(period::period_type f,long in inline date_time_period july() { return date_time_period(month(
t v) ),6); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for August
/// ///
inline date_time_period operator*(long int v,period::period_typ inline date_time_period august() { return date_time_period(mont
e f) h(),7); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for September
/// ///
inline date_time_period operator*(long int v,date_time_period f inline date_time_period september() { return date_time_period(m
) onth(),8); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for October
/// ///
inline date_time_period operator*(date_time_period f,long int v inline date_time_period october() { return date_time_period(mon
) th(),9); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for November
/// ///
inline date_time_period operator*(period::period_type f,unsigne inline date_time_period november() { return date_time_period(mo
d char v) nth(),10); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for December
/// ///
inline date_time_period operator*(unsigned char v,period::perio inline date_time_period december() { return date_time_period(mo
d_type f) nth(),11); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Sunday
/// ///
inline date_time_period operator*(unsigned char v,date_time_per inline date_time_period sunday() { return date_time_period(day_
iod f) of_week(),1); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Monday
/// ///
inline date_time_period operator*(date_time_period f,unsigned c inline date_time_period monday() { return date_time_period(day_
har v) of_week(),2); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Tuesday
/// ///
inline date_time_period operator*(period::period_type f,unsigne inline date_time_period tuesday() { return date_time_period(day
d short int v) _of_week(),3); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Wednesday
/// ///
inline date_time_period operator*(unsigned short int v,period:: inline date_time_period wednesday() { return date_time_period(d
period_type f) ay_of_week(),4); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Thursday
/// ///
inline date_time_period operator*(unsigned short int v,date_tim inline date_time_period thursday() { return date_time_period(da
e_period f) y_of_week(),5); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Friday
/// ///
inline date_time_period operator*(date_time_period f,unsigned s inline date_time_period friday() { return date_time_period(day_
hort int v) of_week(),6); }
{
return date_time_period(f.type,f.value*v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for Saturday
/// ///
inline date_time_period operator*(period::period_type f,unsigne inline date_time_period saturday() { return date_time_period(da
d int v) y_of_week(),7); }
{
return date_time_period(f,v);
}
/// ///
/// Create date_time_period of type \a f with value \a v. /// Get predefined constant for AM (Ante Meridiem)
/// ///
inline date_time_period operator*(unsigned int v,period::period inline date_time_period am() { return date_time_period(am_pm(),
_type f) 0); }
{ ///
return date_time_period(f,v); /// Get predefined constant for PM (Post Meridiem)
} ///
inline date_time_period pm() { return date_time_period(am_pm(),
1); }
/// ///
/// Create date_time_period of type \a f with value \a v. /// convert period_type to date_time_period(f,1)
/// ///
inline date_time_period operator*(unsigned int v,date_time_peri od f) inline date_time_period operator+(period::period_type f)
{ {
return date_time_period(f.type,f.value*v); return date_time_period(f);
} }
/// ///
/// Create date_time_period of type \a f with value \a v. /// convert period_type to date_time_period(f,-1)
/// ///
inline date_time_period operator*(date_time_period f,unsigned i nt v) inline date_time_period operator-(period::period_type f)
{ {
return date_time_period(f.type,f.value*v); return date_time_period(f,-1);
} }
/// ///
/// Create date_time_period of type \a f with value \a v. /// Create date_time_period of type \a f with value \a v.
/// ///
inline date_time_period operator*(period::period_type f,unsigne template<typename T>
d long int v) date_time_period operator*(period::period_type f,T v)
{ {
return date_time_period(f,v); return date_time_period(f,v);
} }
/// ///
/// Create date_time_period of type \a f with value \a v. /// Create date_time_period of type \a f with value \a v.
/// ///
inline date_time_period operator*(unsigned long int v,period::p template<typename T>
eriod_type f) date_time_period operator*(T v,period::period_type f)
{ {
return date_time_period(f,v); return date_time_period(f,v);
} }
/// ///
/// Create date_time_period of type \a f with value \a v. /// Create date_time_period of type \a f with value \a v.
/// ///
inline date_time_period operator*(unsigned long int v,date_time template<typename T>
_period f) date_time_period operator*(T v,date_time_period f)
{ {
return date_time_period(f.type,f.value*v); return date_time_period(f.type,f.value*v);
} }
/// ///
/// Create date_time_period of type \a f with value \a v. /// Create date_time_period of type \a f with value \a v.
/// ///
inline date_time_period operator*(date_time_period f,unsigned l template<typename T>
ong int v) date_time_period operator*(date_time_period f,T v)
{ {
return date_time_period(f.type,f.value*v); return date_time_period(f.type,f.value*v);
} }
} // period } // period
/// ///
/// \brief this class that represents a set of periods, /// \brief this class that represents a set of periods,
/// ///
/// It is generally created by operations on periods: /// It is generally created by operations on periods:
skipping to change at line 472 skipping to change at line 410
if(n < 4) if(n < 4)
basic_[n]=f; basic_[n]=f;
else else
periods_.push_back(f); periods_.push_back(f);
} }
/// ///
/// Get number if items in list /// Get number if items in list
/// ///
size_t size() const size_t size() const
{ {
if(basic_[0].type == period::invalid) if(basic_[0].type == period::period_type())
return 0; return 0;
if(basic_[1].type == period::invalid) if(basic_[1].type == period::period_type())
return 1; return 1;
if(basic_[2].type == period::invalid) if(basic_[2].type == period::period_type())
return 2; return 2;
if(basic_[3].type == period::invalid) if(basic_[3].type == period::period_type())
return 3; return 3;
return 4+periods_.size(); return 4+periods_.size();
} }
/// ///
/// Get item at position \a n the set, n should be in range [0, size) /// Get item at position \a n the set, n should be in range [0, size)
/// ///
date_time_period const &operator[](unsigned n) const date_time_period const &operator[](size_t n) const
{ {
if(n >= size()) if(n >= size())
throw booster::out_of_range("Invalid index to date_time _period"); throw booster::out_of_range("Invalid index to date_time _period");
if(n < 4) if(n < 4)
return basic_[n]; return basic_[n];
else else
return periods_[n-4]; return periods_[n-4];
} }
private: private:
date_time_period basic_[4]; date_time_period basic_[4];
skipping to change at line 534 skipping to change at line 472
/// This information is not connected to specific date but generic to locale, and timezone. /// This information is not connected to specific date but generic to locale, and timezone.
/// It is used in obtaining general information about calendar and is essential for creation of /// It is used in obtaining general information about calendar and is essential for creation of
/// date_time objects. /// date_time objects.
/// ///
class BOOSTER_API calendar { class BOOSTER_API calendar {
public: public:
/// ///
/// Create calendar taking locale and timezone information from ios_base instance. /// Create calendar taking locale and timezone information from ios_base instance.
/// ///
/// \note throws std::bad_cast if ios does not have a locale wi
th installed \ref calendar_facet
/// facet installed
///
calendar(std::ios_base &ios); calendar(std::ios_base &ios);
/// ///
/// Create calendar with locale \a l and time_zone \a zone /// Create calendar with locale \a l and time_zone \a zone
/// ///
/// \note throws std::bad_cast if loc does not have \ref calend
ar_facet facet installed
///
calendar(std::locale const &l,std::string const &zone); calendar(std::locale const &l,std::string const &zone);
/// ///
/// Create calendar with locale \a l and default timezone /// Create calendar with locale \a l and default timezone
/// ///
/// \note throws std::bad_cast if loc does not have \ref calend
ar_facet facet installed
///
calendar(std::locale const &l); calendar(std::locale const &l);
/// ///
/// Create calendar with default locale and timezone \a zone /// Create calendar with default locale and timezone \a zone
/// ///
/// \note throws std::bad_cast if global locale does not have \
ref calendar_facet facet installed
///
calendar(std::string const &zone); calendar(std::string const &zone);
/// ///
/// Create calendar with default locale and timezone /// Create calendar with default locale and timezone
/// ///
/// \note throws std::bad_cast if global locale does not have \
ref calendar_facet facet installed
///
calendar(); calendar();
~calendar(); ~calendar();
/// ///
/// copy calendar /// copy calendar
/// ///
calendar(calendar const &other); calendar(calendar const &other);
/// ///
/// assign calendar /// assign calendar
/// ///
calendar const &operator=(calendar const &other); calendar const &operator=(calendar const &other);
/// ///
/// Get minimum value for period f, For example for period::day it is 1. /// Get minimum value for period f, For example for period::day it is 1.
/// ///
int minimum(period::period_type f) const; int minimum(period::period_type f) const;
/// ///
/// Get grates possible minimum value for period f, For example for period::day it is 1, but may be different for other calendars. /// Get greatest possible minimum value for period f, For examp le for period::day it is 1, but may be different for other calendars.
/// ///
int greatest_minimum(period::period_type f) const; int greatest_minimum(period::period_type f) const;
/// ///
/// Get maximum value for period f, For example for Gregorian c alendar's maximum period::day it is 31. /// Get maximum value for period f, For example for Gregorian c alendar's maximum period::day it is 31.
/// ///
int maximum(period::period_type f) const; int maximum(period::period_type f) const;
/// ///
/// Get least maximum value for period f, For example for Grego rian calendar's maximum period::day it is 28. /// Get least maximum value for period f, For example for Grego rian calendar's maximum period::day it is 28.
/// ///
int least_maximum(period::period_type f) const; int least_maximum(period::period_type f) const;
skipping to change at line 640 skipping to change at line 589
/// some_time = year * 1995 that sets the year to 1995. /// some_time = year * 1995 that sets the year to 1995.
/// ///
/// ///
class BOOSTER_API date_time { class BOOSTER_API date_time {
public: public:
/// ///
/// Dafault constructor, uses default calendar initialized date _time object to current time. /// Dafault constructor, uses default calendar initialized date _time object to current time.
/// ///
/// \note throws std::bad_cast if the global locale does not ha
ve \ref calendar_facet facet installed
///
date_time(); date_time();
/// ///
/// copy date_time /// copy date_time
/// ///
date_time(date_time const &other); date_time(date_time const &other);
/// ///
/// copy date_time and change some fields according to the \a s et /// copy date_time and change some fields according to the \a s et
/// ///
date_time(date_time const &other,date_time_period_set const &se t); date_time(date_time const &other,date_time_period_set const &se t);
/// ///
/// assign the date_time /// assign the date_time
/// ///
date_time const &operator=(date_time const &other); date_time const &operator=(date_time const &other);
~date_time(); ~date_time();
/// ///
/// Create a date_time opject using POSIX time \a time and defa /// Create a date_time object using POSIX time \a time and defa
ult calendar ult calendar
///
/// \note throws std::bad_cast if the global locale does not ha
ve \ref calendar_facet facet installed
/// ///
date_time(double time); date_time(double time);
/// ///
/// Create a date_time opject using POSIX time \a time and cale ndar \a cal /// Create a date_time object using POSIX time \a time and cale ndar \a cal
/// ///
date_time(double time,calendar const &cal); date_time(double time,calendar const &cal);
/// ///
/// Create a date_time opject using calendar \a cal and initial izes it to current time. /// Create a date_time object using calendar \a cal and initial izes it to current time.
/// ///
date_time(calendar const &cal); date_time(calendar const &cal);
/// ///
/// Create a date_time opject using default calendar and define /// Create a date_time object using default calendar and define
values given in \a set values given in \a set
///
/// \note throws std::bad_cast if the global locale does not ha
ve \ref calendar_facet facet installed
/// ///
date_time(date_time_period_set const &set); date_time(date_time_period_set const &set);
/// ///
/// Create a date_time opject using calendar \a cal and define values given in \a set /// Create a date_time object using calendar \a cal and define values given in \a set
/// ///
date_time(date_time_period_set const &set,calendar const &cal); date_time(date_time_period_set const &set,calendar const &cal);
/// ///
/// assign values to valrious periods in set \a f /// assign values to various periods in set \a f
/// ///
date_time const &operator=(date_time_period_set const &f); date_time const &operator=(date_time_period_set const &f);
/// ///
/// set specific period \a f value to \a v /// set specific period \a f value to \a v
/// ///
void set(period::period_type f,int v); void set(period::period_type f,int v);
/// ///
/// get specific period \a f value /// get specific period \a f value
/// ///
skipping to change at line 766 skipping to change at line 721
date_time const &operator>>=(period::period_type f) date_time const &operator>>=(period::period_type f)
{ {
return *this>>=date_time_period(f); return *this>>=date_time_period(f);
} }
/// ///
/// add date_time_period to the current date_time /// add date_time_period to the current date_time
/// ///
date_time operator+(date_time_period const &v) const; date_time operator+(date_time_period const &v) const;
/// ///
/// substract date_time_period from the current date_time /// subtract date_time_period from the current date_time
/// ///
date_time operator-(date_time_period const &v) const; date_time operator-(date_time_period const &v) const;
/// ///
/// add date_time_period to the current date_time /// add date_time_period to the current date_time
/// ///
date_time const &operator+=(date_time_period const &v); date_time const &operator+=(date_time_period const &v);
/// ///
/// substract date_time_period from the current date_time /// subtract date_time_period from the current date_time
/// ///
date_time const &operator-=(date_time_period const &v); date_time const &operator-=(date_time_period const &v);
/// ///
/// roll current date_time forward by date_time_period v /// roll current date_time forward by date_time_period v
/// ///
date_time operator<<(date_time_period const &v) const; date_time operator<<(date_time_period const &v) const;
/// ///
/// roll current date_time backward by date_time_period v /// roll current date_time backward by date_time_period v
/// ///
skipping to change at line 800 skipping to change at line 755
/// ///
/// roll current date_time backward by date_time_period v /// roll current date_time backward by date_time_period v
/// ///
date_time const &operator>>=(date_time_period const &v); date_time const &operator>>=(date_time_period const &v);
/// ///
/// add date_time_period_set v to the current date_time /// add date_time_period_set v to the current date_time
/// ///
date_time operator+(date_time_period_set const &v) const; date_time operator+(date_time_period_set const &v) const;
/// ///
/// substract date_time_period_set v from the current date_time /// subtract date_time_period_set v from the current date_time
/// ///
date_time operator-(date_time_period_set const &v) const; date_time operator-(date_time_period_set const &v) const;
/// ///
/// add date_time_period_set v to the current date_time /// add date_time_period_set v to the current date_time
/// ///
date_time const &operator+=(date_time_period_set const &v); date_time const &operator+=(date_time_period_set const &v);
/// ///
/// substract date_time_period_set v from the current date_time /// subtract date_time_period_set v from the current date_time
/// ///
date_time const &operator-=(date_time_period_set const &v); date_time const &operator-=(date_time_period_set const &v);
/// ///
/// roll current date_time forward by date_time_period_set v /// roll current date_time forward by date_time_period_set v
/// ///
date_time operator<<(date_time_period_set const &v) const; date_time operator<<(date_time_period_set const &v) const;
/// ///
/// roll current date_time backward by date_time_period_set v /// roll current date_time backward by date_time_period_set v
/// ///
skipping to change at line 839 skipping to change at line 794
/// ///
/// Get POSIX time /// Get POSIX time
/// ///
/// The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds. /// The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds.
/// ///
double time() const; double time() const;
/// ///
/// set POSIX time /// set POSIX time
/// ///
/// The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds. /// The POSIX time is number of seconds since January 1st, 1970 00:00 UTC, ignoring leap seconds.
/// This time can be fetched from Operating system clock using C function time, gettimeofdat and others. /// This time can be fetched from Operating system clock using C function time, gettimeofday and others.
/// ///
void time(double v); void time(double v);
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator==(date_time const &other) const; bool operator==(date_time const &other) const;
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator!=(date_time const &other) const; bool operator!=(date_time const &other) const;
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator<(date_time const &other) const; bool operator<(date_time const &other) const;
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator>(date_time const &other) const; bool operator>(date_time const &other) const;
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator<=(date_time const &other) const; bool operator<=(date_time const &other) const;
/// ///
/// compare date_time in the timeline (ingnores difference in c alendar, timezone etc) /// compare date_time in the timeline (ignores difference in ca lendar, timezone etc)
/// ///
bool operator>=(date_time const &other) const; bool operator>=(date_time const &other) const;
/// ///
/// swaps two dates - efficient, does not throw /// swaps two dates - efficient, does not throw
/// ///
void swap(date_time &other); void swap(date_time &other);
/// ///
/// calculate the distance from this date_time to \a other in t erms of perios \a f /// calculate the distance from this date_time to \a other in t erms of perios \a f
/// ///
int difference(date_time const &other,period::period_type f) co nst; int difference(date_time const &other,period::period_type f) co nst;
/// ///
/// Get minimal possible value for current time point for a per iod \a f. /// Get minimal possible value for *this time point for a perio d \a f.
/// ///
int minimum(period::period_type f) const; int minimum(period::period_type f) const;
/// ///
/// Get minimal possible value for current time point for a per iod \a f. For example /// Get minimal possible value for *this time point for a perio d \a f. For example
/// in February maximum(day) may be 28 or 29, in January maximu m(day)==31 /// in February maximum(day) may be 28 or 29, in January maximu m(day)==31
/// ///
int maximum(period::period_type f) const; int maximum(period::period_type f) const;
/// ///
/// Check if the current time is in daylight saving time /// Check if *this time point is in daylight saving time
/// ///
bool is_in_daylight_saving_time() const; bool is_in_daylight_saving_time() const;
private: private:
hold_ptr<abstract_calendar> impl_; hold_ptr<abstract_calendar> impl_;
}; };
/// ///
/// Writes date_time \a t to output stream \a out. /// Writes date_time \a t to output stream \a out.
/// ///
/// This function uses locale, calendar and time zone of the target stream \a in. /// This function uses locale, calendar and time zone of the target stream \a in.
/// ///
/// For example: /// For example:
/// \code /// \code
/// date_time now(time(0),hebrew_calendar) /// date_time now(time(0),hebrew_calendar)
/// cout << "Year:" t / perood::year <<" Full Date:"<< as::date_ti me << t; /// cout << "Year: " << period::year(now) <<" Full Date:"<< now;
/// \endcode /// \endcode
/// ///
/// The output may be Year:5770 Full Date:Jan 1, 2010 /// The output may be Year:5770 Full Date:Jan 1, 2010
/// ///
template<typename CharType> template<typename CharType>
std::basic_ostream<CharType> &operator<<(std::basic_ostream<CharTyp e> &out,date_time const &t) std::basic_ostream<CharType> &operator<<(std::basic_ostream<CharTyp e> &out,date_time const &t)
{ {
out << t.time(); double time_point = t.time();
uint64_t display_flags = ios_info::get(out).display_flags();
if (
display_flags == flags::date
|| display_flags == flags::time
|| display_flags == flags::datetime
|| display_flags == flags::strftime
)
{
out << time_point;
}
else {
ios_info::get(out).display_flags(flags::datetime);
out << time_point;
ios_info::get(out).display_flags(display_flags);
}
return out; return out;
} }
/// ///
/// Reads date_time \a t from output stream \a in /// Reads date_time \a t from output stream \a in
/// ///
/// This function uses locale, calendar and time zone of the source stream \a in. /// This function uses locale, calendar and time zone of the source stream \a in.
/// ///
template<typename CharType> template<typename CharType>
std::basic_istream<CharType> &operator>>(std::basic_istream<CharTyp e> &in,date_time &t) std::basic_istream<CharType> &operator>>(std::basic_istream<CharTyp e> &in,date_time &t)
{ {
double v; double v;
in >> v; uint64_t display_flags = ios_info::get(in).display_flags();
t.time(v); if (
display_flags == flags::date
|| display_flags == flags::time
|| display_flags == flags::datetime
|| display_flags == flags::strftime
)
{
in >> v;
}
else {
ios_info::get(in).display_flags(flags::datetime);
in >> v;
ios_info::get(in).display_flags(display_flags);
}
if(!in.fail())
t.time(v);
return in; return in;
} }
/// ///
/// \brief This class represents a period: a pair of two date_time objects. /// \brief This class represents a period: a pair of two date_time objects.
/// ///
/// It is generally used as syntactic sugar to calculate difference between two dates. /// It is generally used as syntactic sugar to calculate difference between two dates.
/// ///
/// Note: it stores references to the original objects, so it is no t recommended to be used /// Note: it stores references to the original objects, so it is no t recommended to be used
/// outside of the equation you calculate the difference in. /// outside of the equation you calculate the difference in.
skipping to change at line 955 skipping to change at line 940
/// ///
date_time_duration(date_time const &first,date_time const &seco nd) : date_time_duration(date_time const &first,date_time const &seco nd) :
s_(first), s_(first),
e_(second) e_(second)
{ {
} }
/// ///
/// find a difference in terms of period_type \a f /// find a difference in terms of period_type \a f
/// ///
int get(period::period_type f) const
{
return start().difference(end(),f);
}
///
/// Syntactic sugar for get(f)
///
int operator / (period::period_type f) const int operator / (period::period_type f) const
{ {
return start().difference(end(),f); return start().difference(end(),f);
} }
/// ///
/// Get starting point /// Get starting point
/// ///
date_time const &start() const { return s_; } date_time const &start() const { return s_; }
/// ///
skipping to change at line 982 skipping to change at line 975
/// ///
/// Calculates the difference between two dates, the left operand i s a later point on time line. /// Calculates the difference between two dates, the left operand i s a later point on time line.
/// Returns date_time_duration object. /// Returns date_time_duration object.
/// ///
inline date_time_duration operator-(date_time const &later,date_tim e const &earlier) inline date_time_duration operator-(date_time const &later,date_tim e const &earlier)
{ {
return date_time_duration(earlier,later); return date_time_duration(earlier,later);
} }
/// namespace period {
/// \brief namespace that holds function for operating global time
zone identifier
///
namespace time_zone {
/// ///
/// Get global time zone identifier. If empty, system time zone is used /// Extract from date_time numerical value of Era i.e. AC, BC in Gregorian and Julian calendar, range [0,1]
/// ///
BOOSTER_API std::string global(); inline int era(date_time const &dt) { return dt.get(era()); }
/// ///
/// Set global time zone identifier returing pervious one. If e mpty, system time zone is used /// Extract from date_time numerical value of Year, it is cale ndar specific, for example 2011 in Gregorian calendar.
/// ///
BOOSTER_API std::string global(std::string const &new_tz); inline int year(date_time const &dt) { return dt.get(year()); }
///
/// Extract from date_time numerical value of Extended year fo
r Gregorian/Julian calendars, where 1 BC == 0, 2 BC == -1.
///
inline int extended_year(date_time const &dt) { return dt.get(e
xtended_year()); }
///
/// Extract from date_time numerical value of The month of yea
r, calendar specific, in Gregorian [0..11]
///
inline int month(date_time const &dt) { return dt.get(month());
}
///
/// Extract from date_time numerical value of The day of month
, calendar specific, in Gregorian [1..31]
///
inline int day(date_time const &dt) { return dt.get(day()); }
///
/// Extract from date_time numerical value of The number of da
y in year, starting from 1, in Gregorian [1..366]
///
inline int day_of_year(date_time const &dt) { return dt.get(day
_of_year()); }
///
/// Extract from date_time numerical value of Day of week, Sun
day=1, Monday=2,..., Saturday=7.
///
/// Note that that updating this value respects local day of we
ek, so for example,
/// If first day of week is Monday and the current day is Tuesd
ay then setting
/// the value to Sunday (1) would forward the date by 5 days fo
rward and not backward
/// by two days as it could be expected if the numbers were tak
en as is.
///
inline int day_of_week(date_time const &dt) { return dt.get(day
_of_week()); }
///
/// Extract from date_time numerical value of Original number
of the day of the week in month. For example 1st Sunday,
/// 2nd Sunday, etc. in Gregorian [1..5]
///
inline int day_of_week_in_month(date_time const &dt) { return d
t.get(day_of_week_in_month()); }
///
/// Extract from date_time numerical value of Local day of wee
k, for example in France Monday is 1, in US Sunday is 1, [1..7]
///
inline int day_of_week_local(date_time const &dt) { return dt.g
et(day_of_week_local()); }
///
/// Extract from date_time numerical value of 24 clock hour [0
..23]
///
inline int hour(date_time const &dt) { return dt.get(hour()); }
///
/// Extract from date_time numerical value of 12 clock hour [0
..11]
///
inline int hour_12(date_time const &dt) { return dt.get(hour_12
()); }
///
/// Extract from date_time numerical value of am or pm marker
[0..1]
///
inline int am_pm(date_time const &dt) { return dt.get(am_pm());
}
///
/// Extract from date_time numerical value of minute [0..59]
///
inline int minute(date_time const &dt) { return dt.get(minute()
); }
///
/// Extract from date_time numerical value of second [0..59]
///
inline int second(date_time const &dt) { return dt.get(second()
); }
///
/// Extract from date_time numerical value of The week number
in the year
///
inline int week_of_year(date_time const &dt) { return dt.get(we
ek_of_year()); }
///
/// Extract from date_time numerical value of The week number
within current month
///
inline int week_of_month(date_time const &dt) { return dt.get(w
eek_of_month()); }
///
/// Extract from date_time numerical value of First day of wee
k, constant, for example Sunday in US = 1, Monday in France = 2
///
inline int first_day_of_week(date_time const &dt) { return dt.g
et(first_day_of_week()); }
///
/// Extract from date_time_duration numerical value of duratio
n in Era i.e. AC, BC in Gregorian and Julian calendar, range [0,1]
///
inline int era(date_time_duration const &dt) { return dt.get(er
a()); }
///
/// Extract from date_time_duration numerical value of duratio
n in years
///
inline int year(date_time_duration const &dt) { return dt.get(y
ear()); }
///
/// Extract from date_time_duration numerical value of duratio
n in extended years (for Gregorian/Julian calendars, where 1 BC == 0, 2 BC
== -1).
///
inline int extended_year(date_time_duration const &dt) { return
dt.get(extended_year()); }
///
/// Extract from date_time_duration numerical value of duratio
n in months
///
inline int month(date_time_duration const &dt) { return dt.get(
month()); }
///
/// Extract from date_time_duration numerical value of duratio
n in days of month
///
inline int day(date_time_duration const &dt) { return dt.get(da
y()); }
///
/// Extract from date_time_duration numerical value of duratio
n in days of year
///
inline int day_of_year(date_time_duration const &dt) { return d
t.get(day_of_year()); }
///
/// Extract from date_time_duration numerical value of duratio
n in days of week
///
inline int day_of_week(date_time_duration const &dt) { return d
t.get(day_of_week()); }
///
/// Extract from date_time_duration numerical value of duratio
n in original number of the day of the week in month
///
inline int day_of_week_in_month(date_time_duration const &dt) {
return dt.get(day_of_week_in_month()); }
///
/// Extract from date_time_duration numerical value of duratio
n in local day of week
///
inline int day_of_week_local(date_time_duration const &dt) { re
turn dt.get(day_of_week_local()); }
///
/// Extract from date_time_duration numerical value of duratio
n in hours
///
inline int hour(date_time_duration const &dt) { return dt.get(h
our()); }
///
/// Extract from date_time_duration numerical value of duratio
n in 12 clock hours
///
inline int hour_12(date_time_duration const &dt) { return dt.ge
t(hour_12()); }
///
/// Extract from date_time_duration numerical value of duratio
n in am or pm markers
///
inline int am_pm(date_time_duration const &dt) { return dt.get(
am_pm()); }
///
/// Extract from date_time_duration numerical value of duratio
n in minutes
///
inline int minute(date_time_duration const &dt) { return dt.get
(minute()); }
///
/// Extract from date_time_duration numerical value of duratio
n in seconds
///
inline int second(date_time_duration const &dt) { return dt.get
(second()); }
///
/// Extract from date_time_duration numerical value of duratio
n in the week number in the year
///
inline int week_of_year(date_time_duration const &dt) { return
dt.get(week_of_year()); }
///
/// Extract from date_time_duration numerical value of duratio
n in The week number within current month
///
inline int week_of_month(date_time_duration const &dt) { return
dt.get(week_of_month()); }
///
/// Extract from date_time_duration numerical value of duratio
n in the first day of week
///
inline int first_day_of_week(date_time_duration const &dt) { re
turn dt.get(first_day_of_week()); }
} }
/// @} /// @}
} // locale } // locale
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
 End of changes. 156 change blocks. 
286 lines changed or deleted 506 lines changed or added


 date_time_facet.h   date_time_facet.h 
skipping to change at line 23 skipping to change at line 23
# pragma warning(push) # pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660) # pragma warning(disable : 4275 4251 4231 4660)
#endif #endif
#include <booster/cstdint.h> #include <booster/cstdint.h>
#include <locale> #include <locale>
namespace booster { namespace booster {
namespace locale { namespace locale {
/// ///
/// \brief Namespace that contains a enum that defines various peri ods like years, days /// \brief Namespace that contains various types for manipulation w ith dates
/// ///
namespace period { namespace period {
/// ///
/// \brief This namespace holds a enum of various period types like era, year, month, etc..
/// ///
/// This enum provides the list of various time periods that ca namespace marks {
n be used for manipulation over date and time /// \brief the type that defines a flag that holds a period
/// Operators like +, - * defined for these period allowing to identifier
perform easy calculations over them enum period_mark {
invalid, ///< Special invalid value,
should not be used directly
era, ///< Era i.e. AC, BC in Gre
gorian and Julian calendar, range [0,1]
year, ///< Year, it is calendar s
pecific, for example 2011 in Gregorian calendar.
extended_year, ///< Extended year for Greg
orian/Julian calendars, where 1 BC == 0, 2 BC == -1.
month, ///< The month of year, cal
endar specific, in Gregorian [0..11]
day, ///< The day of month, cale
ndar specific, in Gregorian [1..31]
day_of_year, ///< The number of day in y
ear, starting from 1, in Gregorian [1..366]
day_of_week, ///< Day of week, Sunday=1,
Monday=2,..., Saturday=7.
///< Note that that updatin
g this value respects local day of week, so for example,
///< If first day of week i
s Monday and the current day is Tuesday then setting
///< the value to Sunday (1
) would forward the date by 5 days forward and not backward
///< by two days as it coul
d be expected if the numbers were taken as is.
day_of_week_in_month, ///< Original number of the
day of the week in month. For example 1st Sunday,
///< 2nd Sunday, etc. in Gr
egorian [1..5]
day_of_week_local, ///< Local day of week, for
example in France Monday is 1, in US Sunday is 1, [1..7]
hour, ///< 24 clock hour [0..23]
hour_12, ///< 12 clock hour [0..11]
am_pm, ///< am or pm marker [0..1]
minute, ///< minute [0..59]
second, ///< second [0..59]
week_of_year, ///< The week number in the
year
week_of_month, ///< The week number within
current month
first_day_of_week, ///< First day of week, con
stant, for example Sunday in US = 1, Monday in France = 2
};
} // marks
/// ///
typedef enum { /// \brief This class holds a type that represents certain peri
invalid, ///< Special invalid value, sho od of time like
uld not be used directly /// year, hour, second and so on.
era, ///< Era i.e. AC, BC in Gregori ///
an and Julian calendar, range [0,1] /// It can be created from either marks::period_mark type or by
year, ///< Year, it is calendar speci using shortcuts in period
fic, for example 2011 in Gregorian calendar. /// namespace - calling functions like period::year(), period::
extended_year, ///< Extended year for Gregoria hour() and so on.
n/Julian calendars, where 1 BC == 0, 2 BC == -1. ///
month, ///< The month of year, calenda /// Basically it represents the same object as enum marks::peri
r specific, in Gregorian [0..11] od_mark but allows to
day, ///< The day of month, calendar /// provide save operator overloading that would not collide wi
specific, in Gregorian [1..31] th casing of enum to
day_of_year, ///< The number of day in year, /// numeric values.
starting from 1, in Gregorian [1..366] ///
day_of_week, ///< Day of week, Sunday=1, Mon class period_type {
day=2,..., Saturday=7. public:
///< Note that that updating th ///
is value respects local day of week, so for example, /// Create a period of specific type, default is invalid.
///< If first day of week is Mo ///
nday and the current day is Tuesday then setting period_type(marks::period_mark m = marks::invalid) : mark_(
///< the value to Sunday (1) wo m)
uld forward the date by 5 days forward and not backward {
///< by two days as it could be }
expected if the numbers were taken as is.
day_of_week_in_month, ///< Original number of the day ///
of the week in month. For example 1st Sunday, /// Get the value of marks::period_mark it was created with
///< 2nd Sunday, etc. in Gregor .
ian [1..5] ///
day_of_week_local, ///< Local day of week, for exa marks::period_mark mark() const
mple in France Monday is 1, in US Sunday is 1, [1..7] {
hour, ///< 24 clock hour [0..23] return mark_;
hour_12, ///< 12 clock hour [0..11] }
am_pm, ///< am or pm marker [0..1]
minute, ///< minute [0..59] ///
second, ///< second [0..59] /// Check if two periods are the same
week_of_year, ///< The week number in the yea ///
r bool operator==(period_type const &other) const
week_of_month, ///< The week number withing cu {
rrent month return mark()==other.mark();
first_day_of_week, ///< First day if week, constan }
t, for example Sunday in US = 1, Monday in France = 2 ///
} period_type; /// Check if two periods are different
///
bool operator!=(period_type const &other) const
{
return mark()!=other.mark();
}
private:
marks::period_mark mark_;
};
} // namespace period } // namespace period
/// ///
/// Structure that define POSIX time, seconds and milliseconds /// Structure that define POSIX time, seconds and milliseconds
/// since Jan 1, 1970, 00:00 not including leap seconds. /// since Jan 1, 1970, 00:00 not including leap seconds.
/// ///
struct posix_time { struct posix_time {
int64_t seconds; ///< Seconds since epoch int64_t seconds; ///< Seconds since epoch
uint32_t nanoseconds; ///< Nanoseconds resolution uint32_t nanoseconds; ///< Nanoseconds resolution
skipping to change at line 115 skipping to change at line 163
} calendar_option_type; } calendar_option_type;
/// ///
/// Make a polymorphic copy of the calendar /// Make a polymorphic copy of the calendar
/// ///
virtual abstract_calendar *clone() const = 0; virtual abstract_calendar *clone() const = 0;
/// ///
/// Set specific \a value for period \a p, note not all values are settable. /// Set specific \a value for period \a p, note not all values are settable.
/// ///
virtual void set_value(period::period_type p,int value) = 0; /// After call of set_value you may want to call normalize() fu
nction to make sure
/// vall periods are updated, if you set sereral fields that ar
e part of single
/// date/time representation you should call set_value several
times and then
/// call normalize().
///
/// If normalize() is not called after set_value, the behavior
is undefined
///
virtual void set_value(period::marks::period_mark p,int value)
= 0;
///
/// Recalculate all periods after setting them, should be calle
d after use of set_value() function.
///
virtual void normalize() = 0;
/// ///
/// Get specific value for period \a p according to a value_typ e \a v /// Get specific value for period \a p according to a value_typ e \a v
/// ///
virtual int get_value(period::period_type p,value_type v) const = 0; virtual int get_value(period::marks::period_mark p,value_type v ) const = 0;
/// ///
/// Set current time point /// Set current time point
/// ///
virtual void set_time(posix_time const &p) = 0; virtual void set_time(posix_time const &p) = 0;
/// ///
/// Get current time point /// Get current time point
/// ///
virtual posix_time get_time() const = 0; virtual posix_time get_time() const = 0;
skipping to change at line 144 skipping to change at line 204
virtual void set_option(calendar_option_type opt,int v) = 0; virtual void set_option(calendar_option_type opt,int v) = 0;
/// ///
/// Get option for calendar, currently only check if it is Greg orian calendar /// Get option for calendar, currently only check if it is Greg orian calendar
/// ///
virtual int get_option(calendar_option_type opt) const = 0; virtual int get_option(calendar_option_type opt) const = 0;
/// ///
/// Adjust period's \a p value by \a difference items using a u pdate_type \a u. /// Adjust period's \a p value by \a difference items using a u pdate_type \a u.
/// Note: not all values are adjustable /// Note: not all values are adjustable
/// ///
virtual void adjust_value(period::period_type p,update_type u,i nt difference) = 0; virtual void adjust_value(period::marks::period_mark p,update_t ype u,int difference) = 0;
/// ///
/// Calculate the difference between this calendar and \a othe r in \a p units /// Calculate the difference between this calendar and \a othe r in \a p units
/// ///
virtual int difference(abstract_calendar const *other,period::p eriod_type p) const = 0; virtual int difference(abstract_calendar const *other,period::m arks::period_mark p) const = 0;
/// ///
/// Set time zone, empty - use system /// Set time zone, empty - use system
/// ///
virtual void set_timezone(std::string const &tz) = 0; virtual void set_timezone(std::string const &tz) = 0;
/// ///
/// Get current time zone, empty - system one /// Get current time zone, empty - system one
/// ///
virtual std::string get_timezone() const = 0; virtual std::string get_timezone() const = 0;
skipping to change at line 188 skipping to change at line 248
/// ///
calendar_facet(size_t refs = 0) : std::locale::facet(refs) calendar_facet(size_t refs = 0) : std::locale::facet(refs)
{ {
} }
/// ///
/// Create a new calendar that points to current point of time. /// Create a new calendar that points to current point of time.
/// ///
virtual abstract_calendar *create_calendar() const = 0; virtual abstract_calendar *create_calendar() const = 0;
/// ///
/// Locale id (for work with std::locale /// Locale id (needed to work with std::locale)
/// ///
static std::locale::id id; static std::locale::id id;
}; };
} // locale } // locale
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
 End of changes. 9 change blocks. 
53 lines changed or deleted 125 lines changed or added


 deadline_timer.h   deadline_timer.h 
skipping to change at line 14 skipping to change at line 14
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_AIO_DEADLINE_TIMER_H #ifndef BOOSTER_AIO_DEADLINE_TIMER_H
#define BOOSTER_AIO_DEADLINE_TIMER_H #define BOOSTER_AIO_DEADLINE_TIMER_H
#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/aio/types.h> #include <booster/aio/types.h>
#include <booster/noncopyable.h> #include <booster/noncopyable.h>
namespace booster { namespace booster {
namespace aio { namespace aio {
class BOOSTER_API deadline_timer : public noncopyable { class BOOSTER_API deadline_timer : public noncopyable {
public: public:
deadline_timer(); deadline_timer();
deadline_timer(io_service &srv); deadline_timer(io_service &srv);
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 encoding.h   encoding.h 
skipping to change at line 35 skipping to change at line 35
/// ///
namespace conv { namespace conv {
/// ///
/// \defgroup codepage Character conversion functions /// \defgroup codepage Character conversion functions
/// ///
/// @{ /// @{
/// ///
/// \brief The excepton that is thrown in case of conversion er ror /// \brief The excepton that is thrown in case of conversion er ror
/// ///
class conversion_error : public booster::runtime_error { class BOOSTER_SYMBOL_VISIBLE conversion_error : public booster: :runtime_error {
public: public:
conversion_error() : booster::runtime_error("Conversion fai led") {} conversion_error() : booster::runtime_error("Conversion fai led") {}
}; };
/// ///
/// \brief This exception is thrown in case of use of unsupport ed /// \brief This exception is thrown in case of use of unsupport ed
/// or invalid character set /// or invalid character set
/// ///
class invalid_charset_error : public booster::runtime_error { class BOOSTER_SYMBOL_VISIBLE invalid_charset_error : public boo ster::runtime_error {
public: public:
/// Create an error for charset \a charset /// Create an error for charset \a charset
invalid_charset_error(std::string charset) : invalid_charset_error(std::string charset) :
booster::runtime_error("Invalid or unsupported charset: " + charset) booster::runtime_error("Invalid or unsupported charset: " + charset)
{ {
} }
}; };
/// ///
skipping to change at line 78 skipping to change at line 78
/// ///
/// convert UTF text in range [begin,end) to a text encoded wit h \a charset according to policy \a how /// convert UTF text in range [begin,end) to a text encoded wit h \a charset according to policy \a how
/// ///
template<typename CharType> template<typename CharType>
std::string from_utf(CharType const *begin,CharType const *end, std::string const &charset,method_type how=default_method); std::string from_utf(CharType const *begin,CharType const *end, std::string const &charset,method_type how=default_method);
/// ///
/// convert string to UTF string from text in range [begin,end) encoded according to locale \a loc according to policy \a how /// convert string to UTF string from text in range [begin,end) encoded according to locale \a loc according to policy \a how
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_utf(char const *begin,char const *end,std::locale const &loc,method_type how=default_method) std::basic_string<CharType> to_utf(char const *begin,char const *end,std::locale const &loc,method_type how=default_method)
{ {
return to_utf<CharType>(begin,end,std::use_facet<info>(loc) .encoding(),how); return to_utf<CharType>(begin,end,std::use_facet<info>(loc) .encoding(),how);
} }
/// ///
/// convert UTF text in range [begin,end) to a text encoded acc ording to locale \a loc according to policy \a how /// convert UTF text in range [begin,end) to a text encoded acc ording to locale \a loc according to policy \a how
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::string from_utf(CharType const *begin,CharType const *end, std::locale const &loc,method_type how=default_method) std::string from_utf(CharType const *begin,CharType const *end, std::locale const &loc,method_type how=default_method)
{ {
return from_utf(begin,end,std::use_facet<info>(loc).encodin g(),how); return from_utf(begin,end,std::use_facet<info>(loc).encodin g(),how);
} }
/// ///
/// convert a string \a text encoded with \a charset to UTF str ing /// convert a string \a text encoded with \a charset to UTF str ing
/// ///
skipping to change at line 139 skipping to change at line 143
{ {
CharType const *text_end = text; CharType const *text_end = text;
while(*text_end) while(*text_end)
text_end++; text_end++;
return from_utf(text,text_end,charset,how); return from_utf(text,text_end,charset,how);
} }
/// ///
/// Convert a \a text in locale encoding given by \a loc to UTF /// Convert a \a text in locale encoding given by \a loc to UTF
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_utf(std::string const &text,std: :locale const &loc,method_type how=default_method) std::basic_string<CharType> to_utf(std::string const &text,std: :locale const &loc,method_type how=default_method)
{ {
return to_utf<CharType>(text.c_str(),text.c_str()+text.size (),loc,how); return to_utf<CharType>(text.c_str(),text.c_str()+text.size (),loc,how);
} }
/// ///
/// Convert a \a text in UTF to locale encoding given by \a loc /// Convert a \a text in UTF to locale encoding given by \a loc
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::string from_utf(std::basic_string<CharType> const &text,st d::locale const &loc,method_type how=default_method) std::string from_utf(std::basic_string<CharType> const &text,st d::locale const &loc,method_type how=default_method)
{ {
return from_utf(text.c_str(),text.c_str()+text.size(),loc,h ow); return from_utf(text.c_str(),text.c_str()+text.size(),loc,h ow);
} }
/// ///
/// Convert a \a text in locale encoding given by \a loc to UTF /// Convert a \a text in locale encoding given by \a loc to UTF
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::basic_string<CharType> to_utf(char const *text,std::locale const &loc,method_type how=default_method) std::basic_string<CharType> to_utf(char const *text,std::locale const &loc,method_type how=default_method)
{ {
char const *text_end = text; char const *text_end = text;
while(*text_end) while(*text_end)
text_end++; text_end++;
return to_utf<CharType>(text,text_end,loc,how); return to_utf<CharType>(text,text_end,loc,how);
} }
/// ///
/// Convert a \a text in UTF to locale encoding given by \a loc /// Convert a \a text in UTF to locale encoding given by \a loc
/// ///
/// \note throws std::bad_cast if the loc does not have \ref in
fo facet installed
///
template<typename CharType> template<typename CharType>
std::string from_utf(CharType const *text,std::locale const &lo c,method_type how=default_method) std::string from_utf(CharType const *text,std::locale const &lo c,method_type how=default_method)
{ {
CharType const *text_end = text; CharType const *text_end = text;
while(*text_end) while(*text_end)
text_end++; text_end++;
return from_utf(text,text_end,loc,how); return from_utf(text,text_end,loc,how);
} }
/// ///
skipping to change at line 202 skipping to change at line 214
inline inline
std::string between(char const *text, std::string between(char const *text,
std::string const &to_encoding, std::string const &to_encoding,
std::string const &from_encoding, std::string const &from_encoding,
method_type how=default_method) method_type how=default_method)
{ {
char const *end=text; char const *end=text;
while(*end) while(*end)
end++; end++;
return between(text,end,to_encoding,from_encoding,how); return booster::locale::conv::between(text,end,to_encoding, from_encoding,how);
} }
/// ///
/// Convert a \a text to \a to_encoding from \a from_encoding /// Convert a \a text to \a to_encoding from \a from_encoding
/// ///
inline inline
std::string between(std::string const &text, std::string between(std::string const &text,
std::string const &to_encoding, std::string const &to_encoding,
std::string const &from_encoding, std::string const &from_encoding,
method_type how=default_method) method_type how=default_method)
{ {
return between(text.c_str(),text.c_str()+text.size(),to_enc oding,from_encoding,how); return booster::locale::conv::between(text.c_str(),text.c_s tr()+text.size(),to_encoding,from_encoding,how);
} }
/// @}
/// \cond INTERNAL /// \cond INTERNAL
template<> template<>
BOOSTER_API std::basic_string<char> to_utf(char const *begin,ch ar const *end,std::string const &charset,method_type how); BOOSTER_API std::basic_string<char> to_utf(char const *begin,ch ar const *end,std::string const &charset,method_type how);
template<> template<>
BOOSTER_API std::string from_utf(char const *begin,char const * end,std::string const &charset,method_type how); BOOSTER_API std::string from_utf(char const *begin,char const * end,std::string const &charset,method_type how);
template<> template<>
BOOSTER_API std::basic_string<wchar_t> to_utf(char const *begin ,char const *end,std::string const &charset,method_type how); BOOSTER_API std::basic_string<wchar_t> to_utf(char const *begin ,char const *end,std::string const &charset,method_type how);
skipping to change at line 249 skipping to change at line 259
#endif #endif
#ifdef BOOSTER_HAS_CHAR32_T #ifdef BOOSTER_HAS_CHAR32_T
template<> template<>
BOOSTER_API std::basic_string<char32_t> to_utf(char const *begi n,char const *end,std::string const &charset,method_type how); BOOSTER_API std::basic_string<char32_t> to_utf(char const *begi n,char const *end,std::string const &charset,method_type how);
template<> template<>
BOOSTER_API std::string from_utf(char32_t const *begin,char32_t const *end,std::string const &charset,method_type how); BOOSTER_API std::string from_utf(char32_t const *begin,char32_t const *end,std::string const &charset,method_type how);
#endif #endif
namespace details {
template<typename CharOut,typename CharIn>
struct utf_to_utf_traits {
static std::basic_string<CharOut>
convert(CharIn const *begin,CharIn const *end,method_ty
pe how)
{
// Make more efficient in fututre - UTF-16/UTF-32 s
hould be quite
// simple and fast
return to_utf<CharOut>(from_utf(begin,end,"UTF-8",h
ow),"UTF-8",how);
}
};
template<typename CharOut>
struct utf_to_utf_traits<CharOut,char> {
static std::basic_string<CharOut>
convert(char const *begin,char const *end,method_type h
ow)
{
return to_utf<CharOut>(begin,end,"UTF-8",how);
}
};
template<typename CharIn>
struct utf_to_utf_traits<char,CharIn> {
static std::string
convert(CharIn const *begin,CharIn const *end,method_ty
pe how)
{
return from_utf(begin,end,"UTF-8",how);
}
};
template<>
struct utf_to_utf_traits<char,char> { // just test valid
static std::string
convert(char const *begin,char const *end,method_type h
ow)
{
return from_utf(begin,end,"UTF-8",how);
}
};
}
/// \endcond /// \endcond
///
/// Convert a Unicode text in range [begin,end) to other Unicod
e encoding
///
template<typename CharOut,typename CharIn>
std::basic_string<CharOut>
utf_to_utf(CharIn const *begin,CharIn const *end,method_type ho
w = default_method)
{
return details::utf_to_utf_traits<CharOut,CharIn>::convert(
begin,end,how);
}
///
/// Convert a Unicode NUL terminated string \a str other Unicod
e encoding
///
template<typename CharOut,typename CharIn>
std::basic_string<CharOut>
utf_to_utf(CharIn const *str,method_type how = default_method)
{
CharIn const *end = str;
while(*end)
end++;
return utf_to_utf<CharOut,CharIn>(str,end,how);
}
///
/// Convert a Unicode string \a str other Unicode encoding
///
template<typename CharOut,typename CharIn>
std::basic_string<CharOut>
utf_to_utf(std::basic_string<CharIn> const &str,method_type how
= default_method)
{
return utf_to_utf<CharOut,CharIn>(str.c_str(),str.c_str()+s
tr.size(),how);
}
/// @}
} // conv } // conv
} // locale } // locale
} // boost } // boost
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
#pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
 End of changes. 13 change blocks. 
6 lines changed or deleted 108 lines changed or added


 format.h   format.h 
skipping to change at line 27 skipping to change at line 27
#include <booster/locale/formatting.h> #include <booster/locale/formatting.h>
#include <sstream> #include <sstream>
namespace booster { namespace booster {
namespace locale { namespace locale {
/// ///
/// \defgroup format Format /// \defgroup format Format
/// ///
/// This module provides printf like functionality integrated to io streams and suitable for localization /// This module provides printf like functionality integrated into iostreams and suitable for localization
/// ///
/// @{ /// @{
/// ///
/// \cond INTERNAL /// \cond INTERNAL
namespace details { namespace details {
template<typename CharType> template<typename CharType>
struct formattible { struct formattible {
typedef std::basic_ostream<CharType> stream_type; typedef std::basic_ostream<CharType> stream_type;
skipping to change at line 64 skipping to change at line 64
if(this != &other) { if(this != &other) {
pointer_=other.pointer_; pointer_=other.pointer_;
writer_=other.writer_; writer_=other.writer_;
} }
return *this; return *this;
} }
template<typename Type> template<typename Type>
formattible(Type const &value) formattible(Type const &value)
{ {
pointer_ = reinterpret_cast<void const *>(&value); pointer_ = static_cast<void const *>(&value);
writer_ = &write<Type>; writer_ = &write<Type>;
} }
template<typename Type> template<typename Type>
formattible const &operator=(Type const &other) formattible const &operator=(Type const &other)
{ {
*this = formattible(other); *this = formattible(other);
return *this; return *this;
} }
skipping to change at line 91 skipping to change at line 91
private: private:
static void void_write(stream_type &output,void const * /*p tr*/) static void void_write(stream_type &output,void const * /*p tr*/)
{ {
CharType empty_string[1]={0}; CharType empty_string[1]={0};
output<<empty_string; output<<empty_string;
} }
template<typename Type> template<typename Type>
static void write(stream_type &output,void const *ptr) static void write(stream_type &output,void const *ptr)
{ {
output << *reinterpret_cast<Type const *>(ptr); output << *static_cast<Type const *>(ptr);
} }
void const *pointer_; void const *pointer_;
writer_type writer_; writer_type writer_;
}; // formattible }; // formattible
class BOOSTER_API format_parser { class BOOSTER_API format_parser {
public: public:
format_parser(std::ios_base &ios,void *,void (*imbuer)(void *,std::locale const &)); format_parser(std::ios_base &ios,void *,void (*imbuer)(void *,std::locale const &));
~format_parser(); ~format_parser();
unsigned get_posision(); unsigned get_position();
void set_one_flag(std::string const &key,std::string const &value); void set_one_flag(std::string const &key,std::string const &value);
template<typename CharType> template<typename CharType>
void set_flag_with_str(std::string const &key,std::basic_st ring<CharType> const &value) void set_flag_with_str(std::string const &key,std::basic_st ring<CharType> const &value)
{ {
if(key=="ftime" || key=="strftime") { if(key=="ftime" || key=="strftime") {
as::strftime(ios_); as::strftime(ios_);
ios_info::get(ios_).date_time_pattern(value); ios_info::get(ios_).date_time_pattern(value);
} }
skipping to change at line 133 skipping to change at line 133
std::auto_ptr<data> d; std::auto_ptr<data> d;
}; };
} }
/// \endcond /// \endcond
/// ///
/// \brief a printf like class that allows type-safe and locale awa re message formatting /// \brief a printf like class that allows type-safe and locale awa re message formatting
/// ///
/// This class creates formatted message similarly to printf or boo st::format and receives /// This class creates a formatted message similar to printf or boo st::format and receives
/// formatted entries via operator %. /// formatted entries via operator %.
/// ///
/// For example /// For example
/// \code /// \code
/// cout << format("Hello {1}, you are {2} years old") % name % ag e << endl; /// cout << format("Hello {1}, you are {2} years old") % name % ag e << endl;
/// \endcode /// \endcode
/// ///
/// Formatting is enclosed between curl brackets \c { \c } and def ined by comma separated list of flags in format key[=value] /// Formatting is enclosed between curly brackets \c { \c } and def ined by a comma separated list of flags in the format key[=value]
/// value may also be text included between single quotes \c ' that is used for special purposes where inclusion of non-ASCII /// value may also be text included between single quotes \c ' that is used for special purposes where inclusion of non-ASCII
/// text is allowed /// text is allowed
/// ///
/// Including of literal \c { and \c } is possible by specifying do
uble brackets \c {{ and \c }} accordingly.
///
///
/// For example: /// For example:
/// ///
/// \code /// \code
/// cout << format("The hight of water at {1,time} is {2,num=fixe d,precision=3}") % time % height; /// cout << format("The height of water at {1,time} is {2,num=fix ed,precision=3}") % time % height;
/// \endcode /// \endcode
/// ///
/// The special key -- number without value defines a position of i nput parameter. /// The special key -- a number without a value defines the positio n of an input parameter.
/// List of keys: /// List of keys:
/// - \c [0-9]+ -- digits, the index of formatted parameter -- ma ndatory key. /// - \c [0-9]+ -- digits, the index of a formatted parameter -- mandatory key.
/// - \c num or \c number -- format a number. Optional values are : /// - \c num or \c number -- format a number. Optional values are :
/// - \c hex -- display hexadecimal number /// - \c hex -- display hexadecimal number
/// - \c oct -- display in octal format /// - \c oct -- display in octal format
/// - \c sci or `scientific` -- display in scientific format /// - \c sci or \c scientific -- display in scientific format
/// - \c fix or `fixed` -- display in fixed format /// - \c fix or \c fixed -- display in fixed format
/// . /// .
/// For example \c number=sci /// For example \c number=sci
/// - \c cur or \c currency -- format currency. Optional values ar e: /// - \c cur or \c currency -- format currency. Optional values ar e:
/// ///
/// - \c iso -- display using ISO currency symbol. /// - \c iso -- display using ISO currency symbol.
/// - \c nat or \c national -- display using national currency symbol. /// - \c nat or \c national -- display using national currency symbol.
/// . /// .
/// - \c per or \c percent -- format percent value. /// - \c per or \c percent -- format percent value.
/// - \c date, \c time , \c datetime or \c dt -- format date, time or date and time. Optional values are: /// - \c date, \c time , \c datetime or \c dt -- format date, time or date and time. Optional values are:
/// - \c s or \c short -- display in short format /// - \c s or \c short -- display in short format
skipping to change at line 182 skipping to change at line 185
/// . /// .
/// - \c ftime with string (quoted) parameter -- display as with \ c strftime see, \c as::ftime manipulator /// - \c ftime with string (quoted) parameter -- display as with \ c strftime see, \c as::ftime manipulator
/// - \c spell or \c spellout -- spell the number. /// - \c spell or \c spellout -- spell the number.
/// - \c ord or \c ordinal -- format ordinal number (1st, 2nd... e tc) /// - \c ord or \c ordinal -- format ordinal number (1st, 2nd... e tc)
/// - \c left or \c < -- align to left. /// - \c left or \c < -- align to left.
/// - \c right or \c > -- align to right. /// - \c right or \c > -- align to right.
/// - \c width or \c w -- set field width (requires parameter). /// - \c width or \c w -- set field width (requires parameter).
/// - \c precision or \c p -- set precision (requires parameter). /// - \c precision or \c p -- set precision (requires parameter).
/// - \c locale -- with parameter -- switch locale for current ope ration. This command generates locale /// - \c locale -- with parameter -- switch locale for current ope ration. This command generates locale
/// with formatting facets giving more fine grained control of formatting. For example: /// with formatting facets giving more fine grained control of formatting. For example:
/// \code
/// cout << format("Today {1,date} ({1,date,locale=he_IL.UTF-8@c
alendar=hebrew,date} Hebrew Date)") % date;
/// \endcode
/// - \c timezone or \c tz -- the name of the timezone to display
the time in. For example:\n
/// \code
/// cout << format("Time is: Local {1,time}, ({1,time,tz=EET} Ea
stern European Time)") % date;
/// \endcode
/// - \c local - display the time in local time
/// - \c gmt - display the time in UTC time scale
/// \code
/// cout << format("Local time is: {1,time,local}, universal tim
e is {1,time,gmt}") % time;
/// \endcode
/// ///
/// ///
/// Invalid formatting strings are slightly ignored. This would pre
vent from translator
/// to crash the program in unexpected location.
/// ///
template<typename CharType> template<typename CharType>
class basic_format { class basic_format {
public: public:
typedef CharType char_type; ///< Underlying character type typedef CharType char_type; ///< Underlying character type
typedef basic_message<char_type> message_type; ///< The transla tion message type
/// \cond INTERNAL /// \cond INTERNAL
typedef details::formattible<CharType> formattible_type; typedef details::formattible<CharType> formattible_type;
/// \endcond /// \endcond
typedef std::basic_string<CharType> string_type; ///< string ty pe for this type of character typedef std::basic_string<CharType> string_type; ///< string ty pe for this type of character
typedef std::basic_ostream<CharType> stream_type; ///< output s tream type for this type of character typedef std::basic_ostream<CharType> stream_type; ///< output s tream type for this type of character
/// ///
/// Create a format class for \a format_string /// Create a format class for \a format_string
/// ///
basic_format(string_type format_string) : basic_format(string_type format_string) :
format_(format_string), format_(format_string),
translate_(false), translate_(false),
parameters_count_(0) parameters_count_(0)
{ {
} }
/// ///
/// Create a format class using message \a trans. The message i f translated first according /// Create a format class using message \a trans. The message i f translated first according
/// to the rules of target locale and then interpreted as forma t string /// to the rules of target locale and then interpreted as forma t string
/// ///
basic_format(message const &trans) : basic_format(message_type const &trans) :
message_(trans), message_(trans),
translate_(true), translate_(true),
parameters_count_(0) parameters_count_(0)
{ {
} }
/// ///
/// Add new parameter to format list /// Add new parameter to format list. The object should be a ty
pe
/// with defined expression out << object where \c out is \c st
d::basic_ostream.
/// ///
template<typename Formattible> template<typename Formattible>
basic_format &operator % (Formattible const &object) basic_format &operator % (Formattible const &object)
{ {
add(formattible_type(object)); add(formattible_type(object));
return *this; return *this;
} }
/// ///
/// Format a string using a locale \a loc /// Format a string using a locale \a loc
skipping to change at line 244 skipping to change at line 263
return buffer.str(); return buffer.str();
} }
/// ///
/// write a formatted string to output stream \a out using out' s locale /// write a formatted string to output stream \a out using out' s locale
/// ///
void write(stream_type &out) const void write(stream_type &out) const
{ {
string_type format; string_type format;
if(translate_) if(translate_)
format = message_.str<CharType>(out.getloc(),ios_info:: get(out).domain_id()); format = message_.str(out.getloc(),ios_info::get(out).d omain_id());
else else
format = format_; format = format_;
format_output(out,format); format_output(out,format);
} }
private: private:
class format_guard {
public:
format_guard(details::format_parser &fmt) :
fmt_(&fmt),
restored_(false)
{
}
void restore()
{
if(restored_)
return;
fmt_->restore();
restored_ = true;
}
~format_guard()
{
try {
restore();
}
catch(...) {
}
}
private:
details::format_parser *fmt_;
bool restored_;
};
void format_output(stream_type &out,string_type const &sformat) const void format_output(stream_type &out,string_type const &sformat) const
{ {
char_type obrk='{'; char_type obrk='{';
char_type cbrk='}'; char_type cbrk='}';
char_type eq='='; char_type eq='=';
char_type comma=','; char_type comma=',';
char_type quote='\''; char_type quote='\'';
size_t pos = 0; size_t pos = 0;
size_t size=sformat.size(); size_t size=sformat.size();
skipping to change at line 285 skipping to change at line 331
continue; continue;
} }
if(pos+1 < size && format[pos+1]==obrk) { if(pos+1 < size && format[pos+1]==obrk) {
out << obrk; out << obrk;
pos+=2; pos+=2;
continue; continue;
} }
pos++; pos++;
details::format_parser fmt(out,reinterpret_cast<void *> details::format_parser fmt(out,static_cast<void *>(&out
(&out),&basic_format::imbue_locale); ),&basic_format::imbue_locale);
format_guard guard(fmt);
while(pos < size) { while(pos < size) {
std::string key; std::string key;
std::string svalue; std::string svalue;
string_type value; string_type value;
bool use_svalue = true; bool use_svalue = true;
for(;format[pos];pos++) { for(;format[pos];pos++) {
char_type c=format[pos]; char_type c=format[pos];
if(c==comma || c==eq || c==cbrk) if(c==comma || c==eq || c==cbrk)
break; break;
skipping to change at line 338 skipping to change at line 386
} }
} }
} }
if(use_svalue) { if(use_svalue) {
fmt.set_one_flag(key,svalue); fmt.set_one_flag(key,svalue);
} }
else else
fmt.set_flag_with_str(key,value); fmt.set_flag_with_str(key,value);
if(format[pos]==',') { if(format[pos]==comma) {
pos++; pos++;
continue; continue;
} }
else if(format[pos]=='}') { else if(format[pos]==cbrk) {
unsigned position = fmt.get_posision(); unsigned position = fmt.get_position();
out << get(position); out << get(position);
fmt.restore(); guard.restore();
pos++; pos++;
break; break;
} }
else { else {
fmt.restore(); guard.restore();
break; break;
} }
} }
} }
} }
// //
// Non-copyable // Non-copyable
// //
basic_format(basic_format const &other); basic_format(basic_format const &other);
skipping to change at line 389 skipping to change at line 437
return parameters_[id]; return parameters_[id];
} }
static void imbue_locale(void *ptr,std::locale const &l) static void imbue_locale(void *ptr,std::locale const &l)
{ {
reinterpret_cast<stream_type *>(ptr)->imbue(l); reinterpret_cast<stream_type *>(ptr)->imbue(l);
} }
static unsigned const base_params_ = 8; static unsigned const base_params_ = 8;
message message_; message_type message_;
string_type format_; string_type format_;
bool translate_; bool translate_;
formattible_type parameters_[base_params_]; formattible_type parameters_[base_params_];
unsigned parameters_count_; unsigned parameters_count_;
std::vector<formattible_type> ext_params_; std::vector<formattible_type> ext_params_;
}; };
/// ///
/// Write formatted message to stream. /// Write formatted message to stream.
/// ///
/// This operator actually causes actual text formatting. It use lo cale and of \a out stream /// This operator actually causes actual text formatting. It uses t he locale of \a out stream
/// ///
template<typename CharType> template<typename CharType>
std::basic_ostream<CharType> &operator<<(std::basic_ostream<CharTyp e> &out,basic_format<CharType> const &fmt) std::basic_ostream<CharType> &operator<<(std::basic_ostream<CharTyp e> &out,basic_format<CharType> const &fmt)
{ {
fmt.write(out); fmt.write(out);
return out; return out;
} }
/// ///
/// Definiton of char based format /// Definition of char based format
/// ///
typedef basic_format<char> format; typedef basic_format<char> format;
/// ///
/// Definiton of wchar_t based format /// Definition of wchar_t based format
/// ///
typedef basic_format<wchar_t> wformat; typedef basic_format<wchar_t> wformat;
#ifdef BOOSTER_HAS_CHAR16_T #ifdef BOOSTER_HAS_CHAR16_T
/// ///
/// Definiton of char16_t based format /// Definition of char16_t based format
/// ///
typedef basic_format<char16_t> u16format; typedef basic_format<char16_t> u16format;
#endif #endif
#ifdef BOOSTER_HAS_CHAR32_T #ifdef BOOSTER_HAS_CHAR32_T
/// ///
/// Definiton of char32_t based format /// Definition of char32_t based format
/// ///
typedef basic_format<char32_t> u32format; typedef basic_format<char32_t> u32format;
#endif #endif
/// ///
/// @} /// @}
/// ///
} }
} }
 End of changes. 29 change blocks. 
27 lines changed or deleted 83 lines changed or added


 formatting.h   formatting.h 
skipping to change at line 17 skipping to change at line 17
// //
#ifndef BOOSTER_LOCALE_FORMATTING_H_INCLUDED #ifndef BOOSTER_LOCALE_FORMATTING_H_INCLUDED
#define BOOSTER_LOCALE_FORMATTING_H_INCLUDED #define BOOSTER_LOCALE_FORMATTING_H_INCLUDED
#include <booster/config.h> #include <booster/config.h>
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
# pragma warning(push) # pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660) # pragma warning(disable : 4275 4251 4231 4660)
#endif #endif
#include <booster/cstdint.h> #include <booster/cstdint.h>
#include <booster/locale/date_time.h> #include <booster/locale/time_zone.h>
#include <ostream> #include <ostream>
#include <istream> #include <istream>
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <typeinfo> #include <typeinfo>
namespace booster { namespace booster {
namespace locale { namespace locale {
/// ///
/// This namespace holds additional formatting /// \brief This namespace holds additional formatting
/// flags that can be set using ios_info. /// flags that can be set using ios_info.
/// ///
namespace flags { namespace flags {
/// ///
/// Formatting flags, each one of them has corresponding manipu lation /// Formatting flags, each one of them has corresponding manipu lation
/// in namespace \a as /// in namespace \a as
/// ///
typedef enum { typedef enum {
posix = 0, posix = 0,
number = 1, number = 1,
skipping to change at line 94 skipping to change at line 94
/// ///
typedef enum { typedef enum {
domain_id ///< Domain code - for message formatti ng domain_id ///< Domain code - for message formatti ng
} value_type; } value_type;
} // flags } // flags
/// ///
/// \brief This class holds an external data - beyond existing fmtf lags that std::ios_base holds /// \brief This class holds an external data - beyond existing fmtf lags that std::ios_base holds
/// ///
/// You almost never create this object directly, you rather access it via ios_info::get(stream_object) /// You should almost never create this object directly. Instead, y ou should access it via ios_info::get(stream_object)
/// static member function. It automatically creates default format ting data for that stream /// static member function. It automatically creates default format ting data for that stream
/// ///
class BOOSTER_API ios_info { class BOOSTER_API ios_info {
public: public:
/// \cond INTERNAL /// \cond INTERNAL
ios_info(); ios_info();
ios_info(ios_info const &); ios_info(ios_info const &);
ios_info const &operator=(ios_info const &); ios_info const &operator=(ios_info const &);
skipping to change at line 221 skipping to change at line 221
string_set const &date_time_pattern_set() const; string_set const &date_time_pattern_set() const;
string_set &date_time_pattern_set(); string_set &date_time_pattern_set();
class BOOSTER_API string_set { class BOOSTER_API string_set {
public: public:
string_set(); string_set();
~string_set(); ~string_set();
string_set(string_set const &other); string_set(string_set const &other);
string_set const &operator=(string_set const &other); string_set const &operator=(string_set const &other);
void swap(string_set &other);
template<typename Char> template<typename Char>
void set(Char const *s) void set(Char const *s)
{ {
delete [] ptr; delete [] ptr;
ptr = 0; ptr = 0;
type=&typeid(Char); type=&typeid(Char);
Char const *end = s; Char const *end = s;
while(*end!=0) end++; while(*end!=0) end++;
// if ptr = 0 it does not matter what is value of size
size = sizeof(Char)*(end - s+1); size = sizeof(Char)*(end - s+1);
ptr = new char[size]; ptr = new char[size];
memcpy(ptr,s,size); memcpy(ptr,s,size);
} }
template<typename Char> template<typename Char>
std::basic_string<Char> get() const std::basic_string<Char> get() const
{ {
if(type==0 || *type!=typeid(Char)) if(type==0 || *type!=typeid(Char))
throw std::bad_cast(); throw std::bad_cast();
skipping to change at line 301 skipping to change at line 303
/// ///
/// Format currency, number is treated like amount of money /// Format currency, number is treated like amount of money
/// ///
inline std::ios_base & currency(std::ios_base & ios) inline std::ios_base & currency(std::ios_base & ios)
{ {
ios_info::get(ios).display_flags(flags::currency); ios_info::get(ios).display_flags(flags::currency);
return ios; return ios;
} }
/// ///
/// Format percent, value 0.3 is treaded as 30%. /// Format percent, value 0.3 is treated as 30%.
/// ///
inline std::ios_base & percent(std::ios_base & ios) inline std::ios_base & percent(std::ios_base & ios)
{ {
ios_info::get(ios).display_flags(flags::percent); ios_info::get(ios).display_flags(flags::percent);
return ios; return ios;
} }
/// ///
/// Format a date, number is treaded as POSIX time /// Format a date, number is treated as POSIX time
/// ///
inline std::ios_base & date(std::ios_base & ios) inline std::ios_base & date(std::ios_base & ios)
{ {
ios_info::get(ios).display_flags(flags::date); ios_info::get(ios).display_flags(flags::date);
return ios; return ios;
} }
/// ///
/// Format a time, number is treaded as POSIX time /// Format a time, number is treated as POSIX time
/// ///
inline std::ios_base & time(std::ios_base & ios) inline std::ios_base & time(std::ios_base & ios)
{ {
ios_info::get(ios).display_flags(flags::time); ios_info::get(ios).display_flags(flags::time);
return ios; return ios;
} }
/// ///
/// Format a date and time, number is treaded as POSIX time /// Format a date and time, number is treated as POSIX time
/// ///
inline std::ios_base & datetime(std::ios_base & ios) inline std::ios_base & datetime(std::ios_base & ios)
{ {
ios_info::get(ios).display_flags(flags::datetime); ios_info::get(ios).display_flags(flags::datetime);
return ios; return ios;
} }
/// ///
/// Create formatted date time, Please note, this manipulator o nly changes formatting mode, /// Create formatted date time, Please note, this manipulator o nly changes formatting mode,
/// and not format itself, so you are probably looking for ftim e manipulator /// and not format itself, so you are probably looking for ftim e manipulator
skipping to change at line 549 skipping to change at line 551
/// - "%T" -- Same as "%H:%M:%S" /// - "%T" -- Same as "%H:%M:%S"
/// - "%x" -- Local date representation. **Note:** prefer usi ng "as::date" /// - "%x" -- Local date representation. **Note:** prefer usi ng "as::date"
/// - "%X" -- Local time representation. **Note:** prefer usi ng "as::time" /// - "%X" -- Local time representation. **Note:** prefer usi ng "as::time"
/// - "%y" -- Year [00,99] /// - "%y" -- Year [00,99]
/// - "%Y" -- 4 digits year. (2009) /// - "%Y" -- 4 digits year. (2009)
/// - "%Z" -- Time Zone /// - "%Z" -- Time Zone
/// - "%%" -- Percent symbol /// - "%%" -- Percent symbol
/// ///
template<typename CharType> template<typename CharType>
details::add_ftime<CharType> ftime(std::basic_string<CharType> #ifdef BOOSTER_LOCALE_DOXYGEN
const &format) unspecified_type
#else
details::add_ftime<CharType>
#endif
ftime(std::basic_string<CharType> const &format)
{ {
details::add_ftime<CharType> fmt; details::add_ftime<CharType> fmt;
fmt.ftime=format; fmt.ftime=format;
return fmt; return fmt;
} }
/// ///
/// See ftime(std::basic_string<CharType> const &format) /// See ftime(std::basic_string<CharType> const &format)
/// ///
template<typename CharType> template<typename CharType>
details::add_ftime<CharType> ftime(CharType const *format) #ifdef BOOSTER_LOCALE_DOXYGEN
unspecified_type
#else
details::add_ftime<CharType>
#endif
ftime(CharType const *format)
{ {
details::add_ftime<CharType> fmt; details::add_ftime<CharType> fmt;
fmt.ftime=format; fmt.ftime=format;
return fmt; return fmt;
} }
/// \cond INTERNAL /// \cond INTERNAL
namespace details { namespace details {
struct set_timezone { struct set_timezone {
std::string id; std::string id;
skipping to change at line 609 skipping to change at line 621
/// ///
inline std::ios_base &local_time(std::ios_base &ios) inline std::ios_base &local_time(std::ios_base &ios)
{ {
ios_info::get(ios).time_zone(time_zone::global()); ios_info::get(ios).time_zone(time_zone::global());
return ios; return ios;
} }
/// ///
/// Set time zone using \a id /// Set time zone using \a id
/// ///
inline details::set_timezone time_zone(char const *id) inline
#ifdef BOOSTER_LOCALE_DOXYGEN
unspecified_type
#else
details::set_timezone
#endif
time_zone(char const *id)
{ {
details::set_timezone tz; details::set_timezone tz;
tz.id=id; tz.id=id;
return tz; return tz;
} }
/// ///
/// Set time zone using \a id /// Set time zone using \a id
/// ///
inline details::set_timezone time_zone(std::string const &id) inline
#ifdef BOOSTER_LOCALE_DOXYGEN
unspecified_type
#else
details::set_timezone
#endif
time_zone(std::string const &id)
{ {
details::set_timezone tz; details::set_timezone tz;
tz.id=id; tz.id=id;
return tz; return tz;
} }
/// ///
/// @} /// @}
/// ///
 End of changes. 13 change blocks. 
12 lines changed or deleted 35 lines changed or added


 fstream.h   fstream.h 
#ifndef BOOSTER_NOWIDE_FSTREAM_H #ifndef BOOSTER_NOWIDE_FSTREAM_H
#define BOOSTER_NOWIDE_FSTREAM_H #define BOOSTER_NOWIDE_FSTREAM_H
#include <booster/config.h> #include <booster/config.h>
#include <booster/nowide/convert.h> #include <booster/nowide/convert.h>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#ifdef BOOSTER_WIN_NATIVE #if defined BOOSTER_WIN_NATIVE || defined BOOSTER_WORKAROUND_BROKEN_GCC_ON_ DARWIN
#include <booster/streambuf.h> #include <booster/streambuf.h>
#include <booster/nowide/cstdio.h> #include <booster/nowide/cstdio.h>
#endif #endif
namespace booster { namespace booster {
/// ///
/// \brief This namespace includes implementation of basic STL's / STDLIb's functions /// \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 a n alias /// such that they accept UTF-8 strings. on Windows. Otherwise it is just a n alias
/// of std namespace (i.e. not on Windows) /// of std namespace (i.e. not on Windows)
/// ///
namespace nowide { namespace nowide {
#ifndef BOOSTER_WIN_NATIVE #if !defined BOOSTER_WIN_NATIVE && !defined(BOOSTER_WORKAROUND_BROKEN_GCC_O N_DARWIN)
using std::basic_ifstream; using std::basic_ifstream;
using std::basic_ofstream; using std::basic_ofstream;
using std::basic_fstream; using std::basic_fstream;
using std::basic_filebuf; using std::basic_filebuf;
using std::filebuf; using std::filebuf;
using std::ifstream; using std::ifstream;
using std::ofstream; using std::ofstream;
using std::fstream; using std::fstream;
#endif #endif
#if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) #if defined(BOOSTER_WIN_NATIVE) || defined(BOOSTER_DOXYGEN_DOCS) || defined (BOOSTER_WORKAROUND_BROKEN_GCC_ON_DARWIN)
#if defined BOOSTER_MSVC #if defined BOOSTER_MSVC
template<typename CharType,typename Traits = std::char_traits<CharTy pe> > template<typename CharType,typename Traits = std::char_traits<CharTy pe> >
class basic_filebuf : public std::basic_filebuf<CharType,Traits> { class basic_filebuf : public std::basic_filebuf<CharType,Traits> {
public: public:
typedef std::basic_filebuf<CharType,Traits> my_base_type; typedef std::basic_filebuf<CharType,Traits> my_base_type;
basic_filebuf *open(char const *s,std::ios_base::openmode mo de) basic_filebuf *open(char const *s,std::ios_base::openmode mo de)
{ {
try { try {
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 function.h   function.h 
skipping to change at line 101 skipping to change at line 101
operator bool() const; operator bool() const;
/// ///
/// Swaps two functional object. Does not throw. /// Swaps two functional object. Does not throw.
/// ///
void swap(function &other); void swap(function &other);
}; };
#else #else
#define BOOSTER_FUNCTION \ #define BOOSTER_FUNCTION \
template<typename Result BOOSTER_TEMPLATE_PARAMS > \ template<typename Result BOOSTER_TEMPLATE_PARAMS > \
class function<Result(BOOSTER_TYPE_PARAMS)> \ class function<Result(BOOSTER_TEMPLATE_TYPE_PARAMS)> \
{ \ { \
public: \ public: \
typedef Result result_type; \ typedef Result result_type; \
struct callable { \ struct callable { \
virtual Result call(BOOSTER_TYPE_PARAMS) =0; \ virtual Result call(BOOSTER_TYPE_PARAMS) =0; \
virtual callable *clone() const = 0; \ virtual callable *clone() const = 0; \
virtual ~callable(){} \ virtual ~callable(){} \
}; \ }; \
\ \
template<typename R,typename F> \ template<typename R,typename F> \
skipping to change at line 160 skipping to change at line 160
return call_ptr->call(BOOSTER_CALL_PARAMS); \ return call_ptr->call(BOOSTER_CALL_PARAMS); \
} \ } \
bool empty() const { return call_ptr.get()==0; } \ bool empty() const { return call_ptr.get()==0; } \
operator bool() const { return !empty(); } \ operator bool() const { return !empty(); } \
void swap(function &other) { call_ptr.swap(other.call_ptr); } \ void swap(function &other) { call_ptr.swap(other.call_ptr); } \
private: \ private: \
clone_ptr<callable> call_ptr; \ clone_ptr<callable> call_ptr; \
}; \ }; \
#define BOOSTER_TEMPLATE_PARAMS #define BOOSTER_TEMPLATE_PARAMS
#define BOOSTER_TEMPLATE_TYPE_PARAMS
#define BOOSTER_TYPE_PARAMS #define BOOSTER_TYPE_PARAMS
#define BOOSTER_CALL_PARAMS #define BOOSTER_CALL_PARAMS
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1 #define BOOSTER_TEMPLATE_PARAMS ,typename P1
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1
#define BOOSTER_TYPE_PARAMS P1 a1 #define BOOSTER_TYPE_PARAMS P1 a1
#define BOOSTER_CALL_PARAMS a1 #define BOOSTER_CALL_PARAMS a1
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2
#define BOOSTER_CALL_PARAMS a1,a2 #define BOOSTER_CALL_PARAMS a1,a2
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3
#define BOOSTER_CALL_PARAMS a1,a2,a3 #define BOOSTER_CALL_PARAMS a1,a2,a3
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6, P7
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7,typename P8 #define BOOSTER_TEMPLATE_PARAMS ,typename P1,typename P2,typename P3 ,typename P4,typename P5,typename P6,typename P7,typename P8
#define BOOSTER_TEMPLATE_TYPE_PARAMS P1, P2, P3, P4, P5, P6, P7, P8
#define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7,P8 a8 #define BOOSTER_TYPE_PARAMS P1 a1,P2 a2,P3 a3,P4 a4,P5 a5,P6 a6,P7 a7,P8 a8
#define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7,a8 #define BOOSTER_CALL_PARAMS a1,a2,a3,a4,a5,a6,a7,a8
BOOSTER_FUNCTION BOOSTER_FUNCTION
#undef BOOSTER_TEMPLATE_PARAMS #undef BOOSTER_TEMPLATE_PARAMS
#undef BOOSTER_TEMPLATE_TYPE_PARAMS
#undef BOOSTER_TYPE_PARAMS #undef BOOSTER_TYPE_PARAMS
#undef BOOSTER_CALL_PARAMS #undef BOOSTER_CALL_PARAMS
#undef BOOSTER_FUNCTION #undef BOOSTER_FUNCTION
#endif // DOC #endif // DOC
} // booster } // booster
#endif #endif
 End of changes. 22 change blocks. 
2 lines changed or deleted 22 lines changed or added


 generator.h   generator.h 
// //
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_LOCALE_GENERATOR_HPP #ifndef BOOSTER_LOCALE_GENERATOR_HPP
#define BOOSTER_LOCALE_GENERATOR_HPP #define BOOSTER_LOCALE_GENERATOR_HPP
#include <booster/config.h> #include <booster/config.h>
#include <booster/cstdint.h>
#ifdef BOOSTER_MSVC #ifdef BOOSTER_MSVC
# pragma warning(push) # pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660) # pragma warning(disable : 4275 4251 4231 4660)
#endif #endif
#include <string> #include <string>
#include <locale> #include <locale>
#include <memory> #include <memory>
namespace booster { namespace booster {
skipping to change at line 32 skipping to change at line 33
class shared_ptr; class shared_ptr;
/// ///
/// \brief This is the main namespace that encloses all localization cl asses /// \brief This is the main namespace that encloses all localization cl asses
/// ///
namespace locale { namespace locale {
class localization_backend; class localization_backend;
class localization_backend_manager; class localization_backend_manager;
static const unsigned nochar_facet = 0; ///< Unspecified static const uint32_t nochar_facet = 0; ///< Unspecified
character category for character independed facets character category for character independent facets
static const unsigned char_facet = 1 << 0; ///< 8-bit charac static const uint32_t char_facet = 1 << 0; ///< 8-bit charac
ter facets ter facets
static const unsigned wchar_t_facet = 1 << 1; ///< wide charact static const uint32_t wchar_t_facet = 1 << 1; ///< wide charact
er facets er facets
static const unsigned char16_t_facet = 1 << 2; ///< C++0x char16 static const uint32_t char16_t_facet = 1 << 2; ///< C++0x char16
_t facets _t facets
static const unsigned char32_t_facet = 1 << 3; ///< C++0x char32 static const uint32_t char32_t_facet = 1 << 3; ///< C++0x char32
_t facets _t facets
static const unsigned character_first_facet = char_facet; ///< Fir static const uint32_t character_first_facet = char_facet; ///< Fir
st facet specific for character type st facet specific for character type
static const unsigned character_last_facet = char32_t_facet; ///< L static const uint32_t character_last_facet = char32_t_facet; ///< L
ast facet specific for character typr ast facet specific for character type
static const unsigned all_characters = 0xFFFF; ///< Special mas static const uint32_t all_characters = 0xFFFF; ///< Special mas
k -- generate all k -- generate all
typedef unsigned character_facet_type; ///<type that specifies the character type that locales can be generated for typedef uint32_t character_facet_type; ///<type that specifies the character type that locales can be generated for
static const unsigned convert_facet = 1 << 0; ///< Generate static const uint32_t convert_facet = 1 << 0; ///< Generate
convertsion facets conversion facets
static const unsigned collation_facet = 1 << 1; ///< Generate static const uint32_t collation_facet = 1 << 1; ///< Generate
collation facets collation facets
static const unsigned formatting_facet= 1 << 2; ///< Generate static const uint32_t formatting_facet= 1 << 2; ///< Generate
numbers, currency, date-time formatting facets numbers, currency, date-time formatting facets
static const unsigned parsing_facet = 1 << 3; ///< Generate static const uint32_t parsing_facet = 1 << 3; ///< Generate
numbers, currency, date-time formatting facets numbers, currency, date-time formatting facets
static const unsigned message_facet = 1 << 4; ///< Generate static const uint32_t message_facet = 1 << 4; ///< Generate
message facets message facets
static const unsigned codepage_facet = 1 << 5; ///< Generate static const uint32_t codepage_facet = 1 << 5; ///< Generate
codepage conversion facets (derived from std::codecvt) character set conversion facets (derived from std::codecvt)
static const unsigned boundary_facet = 1 << 6; ///< Generate static const uint32_t boundary_facet = 1 << 6; ///< Generate
boundary analysis facet boundary analysis facet
static const unsigned per_character_facet_first = convert_facet static const uint32_t per_character_facet_first = convert_facet
; ///< First facet specific for character ; ///< First facet specific for character
static const unsigned per_character_facet_last = boundary_facet static const uint32_t per_character_facet_last = boundary_facet
; ///< Last facet specific for character ; ///< Last facet specific for character
static const unsigned calendar_facet = 1 << 16; ///< Generat static const uint32_t calendar_facet = 1 << 16; ///< Generat
e boundary analysis facet e boundary analysis facet
static const unsigned information_facet = 1 << 17; ///< Gener static const uint32_t information_facet = 1 << 17; ///< Gener
ate general locale information facet ate general locale information facet
static const unsigned non_character_facet_first = calendar_facet static const uint32_t non_character_facet_first = calendar_facet
; ///< First character independed facet ; ///< First character independent facet
static const unsigned non_character_facet_last = information_fac static const uint32_t non_character_facet_last = information_fac
et;///< Last character independed facet et;///< Last character independent facet
static const unsigned all_categories = 0xFFFFFFFFu; ///< Gene rate all of them static const uint32_t all_categories = 0xFFFFFFFFu; ///< Gene rate all of them
typedef unsigned locale_category_type; ///< a type used for more fi ne grained generation of facets typedef uint32_t locale_category_type; ///< a type used for more fi ne grained generation of facets
/// ///
/// \brief the major class used for locale generation /// \brief the major class used for locale generation
/// ///
/// This class is used for specification of all parameters required for locale generation and /// This class is used for specification of all parameters required for locale generation and
/// caching. This class const member functions are thread safe if l ocale class implementation is thread safe. /// caching. This class const member functions are thread safe if l ocale class implementation is thread safe.
/// ///
class BOOSTER_API generator { class BOOSTER_API generator {
public: public:
skipping to change at line 89 skipping to change at line 90
/// ///
/// Create new generator using specific localization_backend_ma nager /// Create new generator using specific localization_backend_ma nager
/// ///
generator(localization_backend_manager const &); generator(localization_backend_manager const &);
~generator(); ~generator();
/// ///
/// Set types of facets that should be generated, default all /// Set types of facets that should be generated, default all
/// ///
void categories(unsigned cats); void categories(locale_category_type cats);
/// ///
/// Get types of facets that should be generated, default all /// Get types of facets that should be generated, default all
/// ///
unsigned categories() const; locale_category_type categories() const;
/// ///
/// Set the characters type for which the facets should be gene rated, default all supported /// Set the characters type for which the facets should be gene rated, default all supported
/// ///
void characters(unsigned chars); void characters(character_facet_type chars);
/// ///
/// Get the characters type for which the facets should be gene rated, default all supported /// Get the characters type for which the facets should be gene rated, default all supported
/// ///
unsigned characters() const; character_facet_type characters() const;
/// ///
/// Add a new domain of messages that would be generated. It sh ould be set in order to enable /// Add a new domain of messages that would be generated. It sh ould be set in order to enable
/// messages support. /// messages support.
/// ///
/// Messages domain has following format: "name" or "name/encod
ing"
/// where name is the base name of the "mo" file where the cata
log is stored
/// without ".mo" extension. For example for file \c /usr/share
/locale/he/LC_MESSAGES/blog.mo
/// it would be \c blog.
///
/// You can optionally specify the encoding of the keys in the
sources by adding "/encoding_name"
/// For example blog/cp1255.
///
/// If not defined all keys are assumed to be UTF-8 encoded.
///
/// \note When you select a domain for the program using dgette
xt or message API, you
/// do not specify the encoding part. So for example if the pro
vided
/// domain name was "blog/windows-1255" then for translation
/// you should use dgettext("blog","Hello")
///
///
void add_messages_domain(std::string const &domain); void add_messages_domain(std::string const &domain);
/// ///
/// Set default message domain. If this member was not called, the first added messages domain is used. /// Set default message domain. If this member was not called, the first added messages domain is used.
/// If the domain \a domain is not added yet it is added. /// If the domain \a domain is not added yet it is added.
/// ///
void set_default_messages_domain(std::string const &domain); void set_default_messages_domain(std::string const &domain);
/// ///
/// Remove all added domains from the list /// Remove all added domains from the list
/// ///
void clear_domains(); void clear_domains();
/// ///
/// Add a search path where dictionaries are looked in. /// Add a search path where dictionaries are looked in.
/// ///
/// \note /// \note
/// ///
/// - Under Windows platform the path is treated as path in loc ale's encoding so when /// - Under the Windows platform the path is treated as a path in the locale's encoding so
/// if you create locale "en_US.windows-1251" then path would be treated as cp1255, /// if you create locale "en_US.windows-1251" then path would be treated as cp1255,
/// and if it is en_US.UTF-8 it is treated as UTF-8. File nam /// and if it is en_US.UTF-8 it is treated as UTF-8. File nam
e is always opened as e is always opened with
/// wide file name as Wide file names are the native file nam /// a wide file name as wide file names are the native file n
e on Windows. ame on Windows.
/// ///
/// - Under POSIX platforms all paths passed as-is regardless o /// - Under POSIX platforms all paths passed as-is regardless o
f encoding as the narrow f encoding as narrow
/// encodings are the native encodings for POSIX platform. /// encodings are the native encodings for POSIX platforms.
/// ///
/// ///
void add_messages_path(std::string const &path); void add_messages_path(std::string const &path);
/// ///
/// Remove all added paths /// Remove all added paths
/// ///
void clear_paths(); void clear_paths();
/// ///
skipping to change at line 165 skipping to change at line 182
/// ///
/// Check if by default ANSI encoding is selected or UTF-8 once s. The default is false. /// Check if by default ANSI encoding is selected or UTF-8 once s. The default is false.
/// ///
bool use_ansi_encoding() const; bool use_ansi_encoding() const;
/// ///
/// Select ANSI encodings as default system encoding rather the n UTF-8 by default /// Select ANSI encodings as default system encoding rather the n UTF-8 by default
/// under Windows. /// under Windows.
/// ///
/// The default is the most protable and most powerful encoding /// The default is the most portable and most powerful encoding
UTF-8, but yet user , UTF-8, but the user
/// may select "system" one if it deals with legacy application /// can select "system" one if dealing with legacy applications
s
/// ///
void use_ansi_encoding(bool enc); void use_ansi_encoding(bool enc);
/// ///
/// Generate a locale with id \a id /// Generate a locale with id \a id
/// ///
std::locale generate(std::string const &id) const; std::locale generate(std::string const &id) const;
/// ///
/// Generate a locale with id \a id, use \a base as a locale fo /// Generate a locale with id \a id. Use \a base as a locale to
r which all facets are added, which all facets are added,
/// instead of std::locale::classic() one /// instead of std::locale::classic().
/// ///
std::locale generate(std::locale const &base,std::string const &id) const; std::locale generate(std::locale const &base,std::string const &id) const;
/// ///
/// Shortcut to generate(id) /// Shortcut to generate(id)
/// ///
std::locale operator()(std::string const &id) const std::locale operator()(std::string const &id) const
{ {
return generate(id); return generate(id);
} }
 End of changes. 20 change blocks. 
64 lines changed or deleted 86 lines changed or added


 gnu_gettext.h   gnu_gettext.h 
skipping to change at line 12 skipping to change at line 12
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
// //
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
// //
#ifndef BOOSTER_LOCLAE_GNU_GETTEXT_HPP #ifndef BOOSTER_LOCLAE_GNU_GETTEXT_HPP
#define BOOSTER_LOCLAE_GNU_GETTEXT_HPP #define BOOSTER_LOCLAE_GNU_GETTEXT_HPP
#include <booster/locale/message.h> #include <booster/locale/message.h>
#include <booster/function.h>
#include <booster/backtrace.h> #include <booster/backtrace.h>
namespace booster { namespace booster {
namespace locale { namespace locale {
/// \addtogroup message
/// @{
///
/// \brief This namespace holds classes that provide GNU Gettext message ca
talogs support.
///
namespace gnu_gettext { namespace gnu_gettext {
/// ///
/// \brief This structure holds all information required for creating g nu-gettext message catalogs, /// \brief This structure holds all information required for creating g nu-gettext message catalogs,
/// ///
/// User is expected to set its parameters to load these catalogs corre /// The user is expected to set its parameters to load these catalogs c
ctly. This sturcture orrectly. This structure
/// also allows to provide functions for charset conversion, note, you /// also allows providing functions for charset conversion. Note, you n
need to provide them, eed to provide them,
/// so this structure not useful for wide characters without subclassin /// so this structure is not useful for wide characters without subclas
g and it will also sing and it will also
/// ignore gettext catalogs that use charset different from \a encoding /// ignore gettext catalogs that use a charset different from \a encodi
. ng.
/// ///
struct messages_info { struct messages_info {
messages_info() : messages_info() :
language("C"), language("C"),
locale_category("LC_MESSAGES") locale_category("LC_MESSAGES")
{ {
} }
std::string language; ///< The language we load the catalog for, like "ru", "en", "de" std::string language; ///< The language we load the catalog for, like "ru", "en", "de"
std::string country; ///< The country wel load the catalog for, like "US", "IL" std::string country; ///< The country we load the catalog for, l ike "US", "IL"
std::string variant; ///< Language variant, like "euro" so it wo uld look for catalog like de_DE\@euro std::string variant; ///< Language variant, like "euro" so it wo uld look for catalog like de_DE\@euro
std::string encoding; ///< Required target charset encoding. Igro std::string encoding; ///< Required target charset encoding. Igno
nred for wide characters. red for wide characters.
///< for narror should specify correct enco ///< For narrow, should specify the correct
ding required for this catalog encoding required for this catalog
std::string locale_category; ///< Locale category, is set by defaul std::string locale_category; ///< Locale category, is set by defaul
t LC_MESSAGES, but ma t to LC_MESSAGES, but may be changed
std::vector<std::string> domains; ///< Message domains - applicat ///
ion name, like my_app. So files named my_app.mo /// \brief This type represents GNU Gettext domain name for the mes
///< would be loaded sages.
std::vector<std::string> paths; ///< Paths to seach files in. ///
///< For Unicode Path under win /// It consists of two parameters:
dows, encode the string as UTF-8 and add BOM. ///