DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2003-2007 Jonathan Turkanis // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) // See http://www.boost.org/libs/iostreams for documentation. // Contains machinery for performing code conversion. #ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED #define BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include
#if defined(BOOST_IOSTREAMS_NO_WIDE_STREAMS) || \ defined(BOOST_IOSTREAMS_NO_LOCALE) \ /**/ # error code conversion not supported on this platform #endif #include
// max. #include
// memcpy. #include
#include
// DEDUCED_TYPENAME, #include
#include
// default_filter_buffer_size. #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// failure, openmode, int types. #include
#include
#include
#include
#include
#include
#include
#include
// Must come last. #include
// Borland 5.x namespace boost { namespace iostreams { struct code_conversion_error : BOOST_IOSTREAMS_FAILURE { code_conversion_error() : BOOST_IOSTREAMS_FAILURE("code conversion error") { } }; namespace detail { //--------------Definition of strncpy_if_same---------------------------------// // Helper template for strncpy_if_same, below. template
struct strncpy_if_same_impl; template<> struct strncpy_if_same_impl
{ template
static Ch* copy(Ch* tgt, const Ch* src, std::streamsize n) { return BOOST_IOSTREAMS_CHAR_TRAITS(Ch)::copy(tgt, src, n); } }; template<> struct strncpy_if_same_impl
{ template
static Tgt* copy(Tgt* tgt, const Src*, std::streamsize) { return tgt; } }; template
Tgt* strncpy_if_same(Tgt* tgt, const Src* src, std::streamsize n) { typedef strncpy_if_same_impl
::value> impl; return impl::copy(tgt, src, n); } //--------------Definition of conversion_buffer-------------------------------// // Buffer and conversion state for reading. template
class conversion_buffer : public buffer< BOOST_DEDUCED_TYPENAME detail::codecvt_extern
::type, Alloc > { public: typedef typename Codecvt::state_type state_type; conversion_buffer() : buffer< BOOST_DEDUCED_TYPENAME detail::codecvt_extern
::type, Alloc >(0) { reset(); } state_type& state() { return state_; } void reset() { if (this->size()) this->set(0, 0); state_ = state_type(); } private: state_type state_; }; //--------------Definition of converter_impl----------------------------------// // Contains member data, open/is_open/close and buffer management functions. template
struct code_converter_impl { typedef typename codecvt_extern
::type extern_type; typedef typename category_of
::type device_category; typedef is_convertible
can_read; typedef is_convertible
can_write; typedef is_convertible
is_bidir; typedef typename iostreams::select< // Disambiguation for Tru64. is_bidir, bidirectional, can_read, input, can_write, output >::type mode; typedef typename mpl::if_< is_direct
, direct_adapter
, Device >::type policy_type; typedef optional< concept_adapter
> storage_type; typedef is_convertible
is_double; typedef conversion_buffer
buffer_type; code_converter_impl() : cvt_(), flags_(0) { } ~code_converter_impl() { try { if (flags_ & f_open) close(); } catch (...) { /* */ } } void open(const Device& dev, int buffer_size) { if (flags_ & f_open) throw BOOST_IOSTREAMS_FAILURE("already open"); if (buffer_size == -1) buffer_size = default_filter_buffer_size; int max_length = cvt_.get().max_length(); buffer_size = (std::max)(buffer_size, 2 * max_length); if (can_read::value) { buf_.first().resize(buffer_size); buf_.first().set(0, 0); } if (can_write::value && !is_double::value) { buf_.second().resize(buffer_size); buf_.second().set(0, 0); } dev_.reset(concept_adapter
(dev)); flags_ = f_open; } void close() { detail::execute_all( detail::call_member_close(*this, BOOST_IOS::in), detail::call_member_close(*this, BOOST_IOS::out) ); } void close(BOOST_IOS::openmode which) { if (which == BOOST_IOS::in && (flags_ & f_input_closed) == 0) { flags_ |= f_input_closed; iostreams::close(dev(), BOOST_IOS::in); } if (which == BOOST_IOS::out && (flags_ & f_output_closed) == 0) { flags_ |= f_output_closed; detail::execute_all( detail::flush_buffer(buf_.second(), dev(), can_write::value), detail::call_close(dev(), BOOST_IOS::out), detail::call_reset(dev_), detail::call_reset(buf_.first()), detail::call_reset(buf_.second()) ); } } bool is_open() const { return (flags_ & f_open) != 0;} policy_type& dev() { return **dev_; } enum flag_type { f_open = 1, f_input_closed = f_open << 1, f_output_closed = f_input_closed << 1 }; codecvt_holder
cvt_; storage_type dev_; double_object< buffer_type, is_double > buf_; int flags_; }; } // End namespace detail. //--------------Definition of converter---------------------------------------// #define BOOST_IOSTREAMS_CONVERTER_PARAMS() , int buffer_size = -1 #define BOOST_IOSTREAMS_CONVERTER_ARGS() , buffer_size template
struct code_converter_base { typedef detail::code_converter_impl< Device, Codecvt, Alloc > impl_type; code_converter_base() : pimpl_(new impl_type) { } shared_ptr
pimpl_; }; template< typename Device, typename Codecvt = detail::default_codecvt, typename Alloc = std::allocator
> class code_converter : protected code_converter_base
{ private: typedef detail::code_converter_impl< Device, Codecvt, Alloc > impl_type; typedef typename impl_type::policy_type policy_type; typedef typename impl_type::buffer_type buffer_type; typedef typename detail::codecvt_holder
::codecvt_type codecvt_type; typedef typename detail::codecvt_intern
::type intern_type; typedef typename detail::codecvt_extern
::type extern_type; typedef typename detail::codecvt_state
::type state_type; public: typedef intern_type char_type; struct category : impl_type::mode, device_tag, closable_tag, localizable_tag { }; BOOST_STATIC_ASSERT(( is_same< extern_type, BOOST_DEDUCED_TYPENAME char_type_of
::type >::value )); public: code_converter() { } #if BOOST_WORKAROUND(__GNUC__, < 3) code_converter(code_converter& rhs) : code_converter_base
(rhs) { } code_converter(const code_converter& rhs) : code_converter_base
(rhs) { } #endif BOOST_IOSTREAMS_FORWARD( code_converter, open_impl, Device, BOOST_IOSTREAMS_CONVERTER_PARAMS, BOOST_IOSTREAMS_CONVERTER_ARGS ) // fstream-like interface. bool is_open() const { return this->pimpl_->is_open(); } void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out ) { impl().close(which); } // Device interface. std::streamsize read(char_type*, std::streamsize); std::streamsize write(const char_type*, std::streamsize); void imbue(const std::locale& loc) { impl().cvt_.imbue(loc); } // Direct device access. Device& operator*() { return detail::unwrap_direct(dev()); } Device* operator->() { return &detail::unwrap_direct(dev()); } private: template
// Used for forwarding. void open_impl(const T& t BOOST_IOSTREAMS_CONVERTER_PARAMS()) { impl().open(t BOOST_IOSTREAMS_CONVERTER_ARGS()); } const codecvt_type& cvt() { return impl().cvt_.get(); } policy_type& dev() { return impl().dev(); } buffer_type& in() { return impl().buf_.first(); } buffer_type& out() { return impl().buf_.second(); } impl_type& impl() { return *this->pimpl_; } }; //--------------Implementation of converter-----------------------------------// // Implementation note: if end of stream contains a partial character, // it is ignored. template
std::streamsize code_converter
::read (char_type* s, std::streamsize n) { const extern_type* next; // Next external char. intern_type* nint; // Next internal char. std::streamsize total = 0; // Characters read. int status = iostreams::char_traits
::good(); bool partial = false; buffer_type& buf = in(); do { // Fill buffer. if (buf.ptr() == buf.eptr() || partial) { status = buf.fill(dev()); if (buf.ptr() == buf.eptr()) break; partial = false; } // Convert. std::codecvt_base::result result = cvt().in( buf.state(), buf.ptr(), buf.eptr(), next, s + total, s + n, nint ); buf.ptr() += next - buf.ptr(); total = static_cast
(nint - s); switch (result) { case std::codecvt_base::partial: partial = true; break; case std::codecvt_base::ok: break; case std::codecvt_base::noconv: { std::streamsize amt = std::min
(next - buf.ptr(), n - total); detail::strncpy_if_same(s + total, buf.ptr(), amt); total += amt; } break; case std::codecvt_base::error: default: buf.state() = state_type(); throw code_conversion_error(); } } while (total < n && status != EOF && status != WOULD_BLOCK); return total == 0 && status == EOF ? -1 : total; } template
std::streamsize code_converter
::write (const char_type* s, std::streamsize n) { buffer_type& buf = out(); extern_type* next; // Next external char. const intern_type* nint; // Next internal char. std::streamsize total = 0; // Characters written. bool partial = false; while (total < n) { // Empty buffer. if (buf.eptr() == buf.end() || partial) { if (!buf.flush(dev())) break; partial = false; } // Convert. std::codecvt_base::result result = cvt().out( buf.state(), s + total, s + n, nint, buf.eptr(), buf.end(), next ); int progress = (int) (next - buf.eptr()); buf.eptr() += progress; switch (result) { case std::codecvt_base::partial: partial = true; // Fall through. case std::codecvt_base::ok: total = static_cast
(nint - s); break; case std::codecvt_base::noconv: { std::streamsize amt = std::min
( nint - total - s, buf.end() - buf.eptr() ); detail::strncpy_if_same(buf.eptr(), s + total, amt); total += amt; } break; case std::codecvt_base::error: default: buf.state() = state_type(); throw code_conversion_error(); } } return total; } //----------------------------------------------------------------------------// } } // End namespaces iostreams, boost. #include
// Borland 5.x #endif // #ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED
code_converter.hpp
Page URL
File URL
Prev
6/37
Next
Download
( 14 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.