x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
posix_time_io.hpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\date_time\posix_time\posix_time_io.hpp
Girar
Efecto
Propiedad
Historial
#ifndef DATE_TIME_POSIX_TIME_IO_HPP__ #define DATE_TIME_POSIX_TIME_IO_HPP__ /* Copyright (c) 2004-2005 CrystalClear Software, Inc. * Use, modification and distribution is subject to the * Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) * Author: Jeff Garland, Bart Garst * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ */ #include "boost/date_time/time_facet.hpp" #include "boost/date_time/period_formatter.hpp" #include "boost/date_time/posix_time/time_period.hpp" #include "boost/date_time/posix_time/posix_time_duration.hpp" //#include "boost/date_time/gregorian/gregorian_io.hpp" #include "boost/io/ios_state.hpp" #include
#include
namespace boost { namespace posix_time { //! wptime_facet is depricated and will be phased out. use wtime_facet instead //typedef boost::date_time::time_facet
wptime_facet; //! ptime_facet is depricated and will be phased out. use time_facet instead //typedef boost::date_time::time_facet
ptime_facet; //! wptime_input_facet is depricated and will be phased out. use wtime_input_facet instead //typedef boost::date_time::time_input_facet
wptime_input_facet; //! ptime_input_facet is depricated and will be phased out. use time_input_facet instead //typedef boost::date_time::time_input_facet
ptime_input_facet; typedef boost::date_time::time_facet
wtime_facet; typedef boost::date_time::time_facet
time_facet; typedef boost::date_time::time_input_facet
wtime_input_facet; typedef boost::date_time::time_input_facet
time_input_facet; template
inline std::basic_ostream
& operator<<(std::basic_ostream
& os, const ptime& p) { boost::io::ios_flags_saver iflags(os); typedef boost::date_time::time_facet
custom_ptime_facet; typedef std::time_put
std_ptime_facet; std::ostreambuf_iterator
oitr(os); if (std::has_facet
(os.getloc())) std::use_facet
(os.getloc()).put(oitr, os, os.fill(), p); else { //instantiate a custom facet for dealing with times since the user //has not put one in the stream so far. This is for efficiency //since we would always need to reconstruct for every time period //if the locale did not already exist. Of course this will be overridden //if the user imbues as some later point. std::ostreambuf_iterator
oitr(os); custom_ptime_facet* f = new custom_ptime_facet(); std::locale l = std::locale(os.getloc(), f); os.imbue(l); f->put(oitr, os, os.fill(), p); } return os; } //! input operator for ptime template
inline std::basic_istream
& operator>>(std::basic_istream
& is, ptime& pt) { boost::io::ios_flags_saver iflags(is); typename std::basic_istream
::sentry strm_sentry(is, false); if (strm_sentry) { try { typedef typename date_time::time_input_facet
time_input_facet; std::istreambuf_iterator
sit(is), str_end; if(std::has_facet
(is.getloc())) { std::use_facet
(is.getloc()).get(sit, str_end, is, pt); } else { time_input_facet* f = new time_input_facet(); std::locale l = std::locale(is.getloc(), f); is.imbue(l); f->get(sit, str_end, is, pt); } } catch(...) { // mask tells us what exceptions are turned on std::ios_base::iostate exception_mask = is.exceptions(); // if the user wants exceptions on failbit, we'll rethrow our // date_time exception & set the failbit if(std::ios_base::failbit & exception_mask) { try { is.setstate(std::ios_base::failbit); } catch(std::ios_base::failure&) {} // ignore this one throw; // rethrow original exception } else { // if the user want's to fail quietly, we simply set the failbit is.setstate(std::ios_base::failbit); } } } return is; } template
inline std::basic_ostream
& operator<<(std::basic_ostream
& os, const boost::posix_time::time_period& p) { boost::io::ios_flags_saver iflags(os); typedef boost::date_time::time_facet
custom_ptime_facet; typedef std::time_put
std_time_facet; std::ostreambuf_iterator
oitr(os); if (std::has_facet
(os.getloc())) { std::use_facet
(os.getloc()).put(oitr, os, os.fill(), p); } else { //instantiate a custom facet for dealing with periods since the user //has not put one in the stream so far. This is for efficiency //since we would always need to reconstruct for every time period //if the local did not already exist. Of course this will be overridden //if the user imbues as some later point. std::ostreambuf_iterator
oitr(os); custom_ptime_facet* f = new custom_ptime_facet(); std::locale l = std::locale(os.getloc(), f); os.imbue(l); f->put(oitr, os, os.fill(), p); } return os; } //! input operator for time_period template
inline std::basic_istream
& operator>>(std::basic_istream
& is, time_period& tp) { boost::io::ios_flags_saver iflags(is); typename std::basic_istream
::sentry strm_sentry(is, false); if (strm_sentry) { try { typedef typename date_time::time_input_facet
time_input_facet; std::istreambuf_iterator
sit(is), str_end; if(std::has_facet
(is.getloc())) { std::use_facet
(is.getloc()).get(sit, str_end, is, tp); } else { time_input_facet* f = new time_input_facet(); std::locale l = std::locale(is.getloc(), f); is.imbue(l); f->get(sit, str_end, is, tp); } } catch(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { try { is.setstate(std::ios_base::failbit); } catch(std::ios_base::failure&) {} throw; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } } return is; } //! ostream operator for posix_time::time_duration // todo fix to use facet -- place holder for now... template
inline std::basic_ostream
& operator<<(std::basic_ostream
& os, const time_duration& td) { boost::io::ios_flags_saver iflags(os); typedef boost::date_time::time_facet
custom_ptime_facet; typedef std::time_put
std_ptime_facet; std::ostreambuf_iterator
oitr(os); if (std::has_facet
(os.getloc())) std::use_facet
(os.getloc()).put(oitr, os, os.fill(), td); else { //instantiate a custom facet for dealing with times since the user //has not put one in the stream so far. This is for efficiency //since we would always need to reconstruct for every time period //if the locale did not already exist. Of course this will be overridden //if the user imbues as some later point. std::ostreambuf_iterator
oitr(os); custom_ptime_facet* f = new custom_ptime_facet(); std::locale l = std::locale(os.getloc(), f); os.imbue(l); f->put(oitr, os, os.fill(), td); } return os; } //! input operator for time_duration template
inline std::basic_istream
& operator>>(std::basic_istream
& is, time_duration& td) { boost::io::ios_flags_saver iflags(is); typename std::basic_istream
::sentry strm_sentry(is, false); if (strm_sentry) { try { typedef typename date_time::time_input_facet
time_input_facet; std::istreambuf_iterator
sit(is), str_end; if(std::has_facet
(is.getloc())) { std::use_facet
(is.getloc()).get(sit, str_end, is, td); } else { time_input_facet* f = new time_input_facet(); std::locale l = std::locale(is.getloc(), f); is.imbue(l); f->get(sit, str_end, is, td); } } catch(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { try { is.setstate(std::ios_base::failbit); } catch(std::ios_base::failure&) {} throw; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } } return is; } } } // namespaces #endif // DATE_TIME_POSIX_TIME_IO_HPP__
posix_time_io.hpp
Dirección de la página
Dirección del archivo
Anterior
6/15
Siguiente
Descargar
( 9 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.