void format_parser::restore() { ios_info::get(ios_) = d->info; ios_.width(0); ios_.flags(d->flags); if(d->restore_locale) imbue(d->saved_locale); }
void wpath_traits::imbue( const std::locale & new_loc ) { if ( locked ) boost::throw_exception( wfilesystem_error( "boost::filesystem::wpath_traits::imbue() after lockdown", make_error_code( system::posix::not_supported ) ) ); imbue( new_loc, std::nothrow ); }
Query::Query(const Query & other) : std::ostream(0), conn(other.conn) { /// Важно в случае, если Query используется не из того же потока, что Connection. mysql_thread_init(); init(&query_buf); imbue(std::locale::classic()); *this << other.str(); }
Query::Query(Connection * conn_, const std::string & query_string) : std::ostream(0), conn(conn_) { /// Важно в случае, если Query используется не из того же потока, что Connection. mysql_thread_init(); init(&query_buf); if (!query_string.empty()) { query_buf.str(query_string); seekp(0, std::ios::end); } imbue(std::locale::classic()); }
w32_regex_traits_base(lcid_type l) { imbue(l); }
void format_parser::set_one_flag(std::string const &key,std::string const &value) { if(key.empty()) return; unsigned i; for(i=0;i<key.size();i++) { if(key[i] < '0' || '9'< key[i]) break; } if(i==key.size()) { d->position=atoi(key.c_str()) - 1; return; } if(key=="num" || key=="number") { as::number(ios_); if(value=="hex") ios_.setf(std::ios_base::hex,std::ios_base::basefield); else if(value=="oct") ios_.setf(std::ios_base::oct,std::ios_base::basefield); else if(value=="sci" || value=="scientific") ios_.setf(std::ios_base::scientific,std::ios_base::floatfield); else if(value=="fix" || value=="fixed") ios_.setf(std::ios_base::fixed,std::ios_base::floatfield); } else if(key=="cur" || key=="currency") { as::currency(ios_); if(value=="iso") as::currency_iso(ios_); else if(value=="nat" || value=="national") as::currency_national(ios_); } else if(key=="per" || key=="percent") { as::percent(ios_); } else if(key=="date") { as::date(ios_); if(value=="s" || value=="short") as::date_short(ios_); else if(value=="m" || value=="medium") as::date_medium(ios_); else if(value=="l" || value=="long") as::date_long(ios_); else if(value=="f" || value=="full") as::date_full(ios_); } else if(key=="time") { as::time(ios_); if(value=="s" || value=="short") as::time_short(ios_); else if(value=="m" || value=="medium") as::time_medium(ios_); else if(value=="l" || value=="long") as::time_long(ios_); else if(value=="f" || value=="full") as::time_full(ios_); } else if(key=="dt" || key=="datetime") { as::datetime(ios_); if(value=="s" || value=="short") { as::date_short(ios_); as::time_short(ios_); } else if(value=="m" || value=="medium") { as::date_medium(ios_); as::time_medium(ios_); } else if(value=="l" || value=="long") { as::date_long(ios_); as::time_long(ios_); } else if(value=="f" || value=="full") { as::date_full(ios_); as::time_full(ios_); } } else if(key=="spell" || key=="spellout") { as::spellout(ios_); } else if(key=="ord" || key=="ordinal") { as::ordinal(ios_); } else if(key=="left" || key=="<") ios_.setf(std::ios_base::left,std::ios_base::adjustfield); else if(key=="right" || key==">") ios_.setf(std::ios_base::right,std::ios_base::adjustfield); else if(key=="gmt") as::gmt(ios_); else if(key=="local") as::local_time(ios_); else if(key=="timezone" || key=="tz") ios_info::get(ios_).time_zone(value); else if(key=="w" || key=="width") ios_.width(atoi(value.c_str())); else if(key=="p" || key=="precision") ios_.precision(atoi(value.c_str())); else if(key=="locale") { if(!d->restore_locale) { d->saved_locale=ios_.getloc(); d->restore_locale=true; } std::string encoding=std::use_facet<info>(d->saved_locale).encoding(); generator gen; gen.categories(formatting_facet); std::locale new_loc; if(value.find('.')==std::string::npos) new_loc = gen(value + "." + encoding); else new_loc = gen(value); imbue(new_loc); } }
cpp_regex_traits_base(const std::locale& l) { imbue(l); }
static_ostream(char* data, std::size_t size) : std::basic_ostream<char>(&this->osb_) , osb_(data, size) { imbue(std::locale::classic()); }
//Defines a global logger initialization routine BOOST_LOG_GLOBAL_LOGGER_INIT(my_logger, logger_t) { logger_t lg; logging::add_common_attributes(); #if 0 auto flsink = logging::add_file_log( boost::log::keywords::file_name = SYS_LOGFILE, boost::log::keywords::format = ( expr::stream << expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S") << " [" << expr::attr< boost::log::trivial::severity_level >("Severity") << "]: " << expr::wmessage ) ); flsink->imbue(std::locale(std::locale(), new std::codecvt_utf8_utf16<wchar_t>)); #endif boost::shared_ptr<logging::core> core = logging::core::get(); #if 0 boost::shared_ptr<sinks::text_ostream_backend> ostream_backend = boost::make_shared<sinks::text_ostream_backend>(); ostream_backend->add_stream( boost::shared_ptr<std::ostream>(&std::clog, logging::empty_deleter())); ostream_backend->auto_flush(true); typedef sinks::synchronous_sink<sinks::text_ostream_backend> sink_ostream_t; boost::shared_ptr<sink_ostream_t> sink_ostream(new sink_ostream_t(ostream_backend)); sink_ostream->set_formatter( expr::format("[%1%] [%2%]\t%3%") % expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S.%f") % logging::trivial::severity % expr::message); core->add_sink(sink_ostream); #endif // ログのファイル出力を設定 auto text_backend = boost::make_shared<sinks::text_file_backend>( boost::log::keywords::file_name = static_cast<LPCWSTR>(Misc::GetExeDirectory() + SYS_LOGFILE) ); text_backend->auto_flush(true); typedef sinks::synchronous_sink<sinks::text_file_backend> sink_text_t; boost::shared_ptr<sink_text_t> sink_text(new sink_text_t(text_backend)); sink_text->set_formatter( expr::format("%1% [%2%]: %3%") % expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S") % logging::trivial::severity % expr::wmessage); sink_text->imbue(std::locale(std::locale(), new std::codecvt_utf8_utf16<wchar_t>)); core->add_sink(sink_text); #ifdef _DEBUG // ログのコンソール出力を設定 ::AllocConsole(); //::SetConsoleOutputCP(CP_UTF8); FILE* out = nullptr; freopen_s(&out, "CON", "w", stdout); auto console_sink = logging::add_console_log(std::wcout); console_sink->set_formatter( expr::format(L"%1% [%2%]: %3%") % expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S") % logging::trivial::severity % expr::wmessage); //console_sink->imbue(std::locale(std::locale(), new std::codecvt_utf8_utf16<wchar_t>)); #endif logging::core::get()->set_filter ( #ifdef _DEBUG logging::trivial::severity >= logging::trivial::info #else logging::trivial::severity >= logging::trivial::error #endif ); return lg; }
ostream (const std::wstring &file) : _Tbase(file, std::ios::binary) { cvt_utf8 *cvt = new cvt_utf8; imbue(std::locale(getloc(), cvt)); };