1 // 2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh) 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See 5 // accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt) 7 // 8 #define BOOST_LOCALE_SOURCE 9 #include <boost/locale/formatting.hpp> 10 #include <boost/locale/date_time.hpp> 11 #include <typeinfo> 12 #include <algorithm> 13 #include "ios_prop.hpp" 14 15 namespace boost { 16 namespace locale { 17 string_set()18 ios_info::string_set::string_set() : 19 type(0), 20 size(0), 21 ptr(0) 22 { 23 } ~string_set()24 ios_info::string_set::~string_set() 25 { 26 delete [] ptr; 27 } string_set(string_set const & other)28 ios_info::string_set::string_set(string_set const &other) 29 { 30 if(other.ptr!=0) { 31 ptr=new char[other.size]; 32 size=other.size; 33 type=other.type; 34 memcpy(ptr,other.ptr,size); 35 } 36 else { 37 ptr=0; 38 size=0; 39 type=0; 40 } 41 } 42 swap(string_set & other)43 void ios_info::string_set::swap(string_set &other) 44 { 45 std::swap(type,other.type); 46 std::swap(size,other.size); 47 std::swap(ptr,other.ptr); 48 } 49 operator =(string_set const & other)50 ios_info::string_set const &ios_info::string_set::operator=(string_set const &other) 51 { 52 if(this!=&other) { 53 string_set tmp(other); 54 swap(tmp); 55 } 56 return *this; 57 } 58 59 struct ios_info::data {}; 60 ios_info()61 ios_info::ios_info() : 62 flags_(0), 63 domain_id_(0), 64 d(0) 65 { 66 time_zone_ = time_zone::global(); 67 } ~ios_info()68 ios_info::~ios_info() 69 { 70 } 71 ios_info(ios_info const & other)72 ios_info::ios_info(ios_info const &other) 73 { 74 flags_ = other.flags_; 75 domain_id_ = other.domain_id_; 76 time_zone_ = other.time_zone_; 77 datetime_ = other.datetime_; 78 } 79 80 operator =(ios_info const & other)81 ios_info const &ios_info::operator=(ios_info const &other) 82 { 83 if(this!=&other) { 84 flags_ = other.flags_; 85 domain_id_ = other.domain_id_; 86 time_zone_ = other.time_zone_; 87 datetime_ = other.datetime_; 88 } 89 return *this; 90 } 91 display_flags(uint64_t f)92 void ios_info::display_flags(uint64_t f) 93 { 94 flags_ = (flags_ & ~uint64_t(flags::display_flags_mask)) | f; 95 } currency_flags(uint64_t f)96 void ios_info::currency_flags(uint64_t f) 97 { 98 flags_ = (flags_ & ~uint64_t(flags::currency_flags_mask)) | f; 99 } date_flags(uint64_t f)100 void ios_info::date_flags(uint64_t f) 101 { 102 flags_ = (flags_ & ~uint64_t(flags::date_flags_mask)) | f; 103 } time_flags(uint64_t f)104 void ios_info::time_flags(uint64_t f) 105 { 106 flags_ = (flags_ & ~uint64_t(flags::time_flags_mask)) | f; 107 } 108 domain_id(int id)109 void ios_info::domain_id(int id) 110 { 111 domain_id_ = id; 112 } 113 time_zone(std::string const & tz)114 void ios_info::time_zone(std::string const &tz) 115 { 116 time_zone_ = tz; 117 } 118 display_flags() const119 uint64_t ios_info::display_flags() const 120 { 121 return flags_ & flags::display_flags_mask; 122 } 123 currency_flags() const124 uint64_t ios_info::currency_flags() const 125 { 126 return flags_ & flags::currency_flags_mask; 127 } 128 date_flags() const129 uint64_t ios_info::date_flags() const 130 { 131 return flags_ & flags::date_flags_mask; 132 } 133 time_flags() const134 uint64_t ios_info::time_flags() const 135 { 136 return flags_ & flags::time_flags_mask; 137 } 138 domain_id() const139 int ios_info::domain_id() const 140 { 141 return domain_id_; 142 } 143 time_zone() const144 std::string ios_info::time_zone() const 145 { 146 return time_zone_; 147 } 148 date_time_pattern_set() const149 ios_info::string_set const &ios_info::date_time_pattern_set() const 150 { 151 return datetime_; 152 } 153 154 date_time_pattern_set()155 ios_info::string_set &ios_info::date_time_pattern_set() 156 { 157 return datetime_; 158 } 159 get(std::ios_base & ios)160 ios_info &ios_info::get(std::ios_base &ios) 161 { 162 return impl::ios_prop<ios_info>::get(ios); 163 } 164 on_imbue()165 void ios_info::on_imbue() 166 { 167 } 168 169 namespace { 170 struct initializer { initializerboost::locale::__anona52139790111::initializer171 initializer() { 172 impl::ios_prop<ios_info>::global_init(); 173 } 174 } initializer_instance; 175 } // namespace 176 177 } // locale 178 } // boost 179 180 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 181