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
// ---------------------------------------------------------------------------- // format_implementation.hpp Implementation of the basic_format class // ---------------------------------------------------------------------------- // Copyright Samuel Krempp 2003. Use, modification, and distribution are // subject to 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/format for library home page // ---------------------------------------------------------------------------- #ifndef BOOST_FORMAT_IMPLEMENTATION_HPP #define BOOST_FORMAT_IMPLEMENTATION_HPP #include
#include
#include
#include
#include
// std::swap namespace boost { // --- basic_format implementation -----------------------------------------// template< class Ch, class Tr, class Alloc> basic_format
:: basic_format(const Ch* s) : style_(0), cur_arg_(0), num_args_(0), dumped_(false), exceptions_(io::all_error_bits) { if( s) parse( s ); } #if !defined(BOOST_NO_STD_LOCALE) template< class Ch, class Tr, class Alloc> basic_format
:: basic_format(const Ch* s, const std::locale & loc) : style_(0), cur_arg_(0), num_args_(0), dumped_(false), loc_(loc), exceptions_(io::all_error_bits) { if(s) parse( s ); } template< class Ch, class Tr, class Alloc> basic_format
:: basic_format(const string_type& s, const std::locale & loc) : style_(0), cur_arg_(0), num_args_(0), dumped_(false), loc_(loc), exceptions_(io::all_error_bits) { parse(s); } #endif // ! BOOST_NO_STD_LOCALE template< class Ch, class Tr, class Alloc> io::detail::locale_t basic_format
:: getloc() const { return loc_ ? loc_.get() : io::detail::locale_t(); } template< class Ch, class Tr, class Alloc> basic_format
:: basic_format(const string_type& s) : style_(0), cur_arg_(0), num_args_(0), dumped_(false), exceptions_(io::all_error_bits) { parse(s); } template< class Ch, class Tr, class Alloc> // just don't copy the buf_ member basic_format
:: basic_format(const basic_format& x) : items_(x.items_), bound_(x.bound_), style_(x.style_), cur_arg_(x.cur_arg_), num_args_(x.num_args_), dumped_(false), prefix_(x.prefix_), exceptions_(x.exceptions_), loc_(x.loc_) { } template< class Ch, class Tr, class Alloc> // just don't copy the buf_ member basic_format
& basic_format
:: operator= (const basic_format& x) { if(this == &x) return *this; (basic_format
(x)).swap(*this); return *this; } template< class Ch, class Tr, class Alloc> void basic_format
:: swap (basic_format & x) { std::swap(exceptions_, x.exceptions_); std::swap(style_, x.style_); std::swap(cur_arg_, x.cur_arg_); std::swap(num_args_, x.num_args_); std::swap(dumped_, x.dumped_); items_.swap(x.items_); prefix_.swap(x.prefix_); bound_.swap(x.bound_); } template< class Ch, class Tr, class Alloc> unsigned char basic_format
:: exceptions() const { return exceptions_; } template< class Ch, class Tr, class Alloc> unsigned char basic_format
:: exceptions(unsigned char newexcept) { unsigned char swp = exceptions_; exceptions_ = newexcept; return swp; } template
void basic_format
:: make_or_reuse_data (std::size_t nbitems) { #if !defined(BOOST_NO_STD_LOCALE) Ch fill = ( BOOST_USE_FACET(std::ctype
, getloc()) ). widen(' '); #else Ch fill = ' '; #endif if(items_.size() == 0) items_.assign( nbitems, format_item_t(fill) ); else { if(nbitems>items_.size()) items_.resize(nbitems, format_item_t(fill)); bound_.resize(0); for(std::size_t i=0; i < nbitems; ++i) items_[i].reset(fill); // strings are resized, instead of reallocated } prefix_.resize(0); } template< class Ch, class Tr, class Alloc> basic_format
& basic_format
:: clear () { // empty the string buffers (except bound arguments) // and make the format object ready for formatting a new set of arguments BOOST_ASSERT( bound_.size()==0 || num_args_ == static_cast
(bound_.size()) ); for(unsigned long i=0; i
basic_format
& basic_format
:: clear_binds () { // remove all binds, then clear() bound_.resize(0); clear(); return *this; } template< class Ch, class Tr, class Alloc> basic_format
& basic_format
:: clear_bind (int argN) { // remove the bind of ONE argument then clear() if(argN<1 || argN > num_args_ || bound_.size()==0 || !bound_[argN-1] ) { if( exceptions() & io::out_of_range_bit) boost::throw_exception(io::out_of_range(argN, 1, num_args_+1 ) ); else return *this; } bound_[argN-1]=false; clear(); return *this; } template< class Ch, class Tr, class Alloc> typename basic_format
::string_type basic_format
:: str () const { if(items_.size()==0) return prefix_; if( cur_arg_ < num_args_) if( exceptions() & io::too_few_args_bit ) // not enough variables supplied boost::throw_exception(io::too_few_args(cur_arg_, num_args_)); unsigned long i; string_type res; res.reserve(size()); res += prefix_; for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; res += item.res_; if( item.argN_ == format_item_t::argN_tabulation) { BOOST_ASSERT( item.pad_scheme_ & format_item_t::tabulation); if( static_cast
(item.fmtstate_.width_) > res.size() ) res.append( static_cast
(item.fmtstate_.width_) - res.size(), item.fmtstate_.fill_ ); } res += item.appendix_; } dumped_=true; return res; } template< class Ch, class Tr, class Alloc> typename std::basic_string
::size_type basic_format
:: size () const { #ifdef BOOST_MSVC // If std::min
or std::max
are already instantiated // at this point then we get a blizzard of warning messages when we call // those templates with std::size_t as arguments. Weird and very annoyning... #pragma warning(push) #pragma warning(disable:4267) #endif BOOST_USING_STD_MAX(); size_type sz = prefix_.size(); unsigned long i; for(i=0; i < items_.size(); ++i) { const format_item_t& item = items_[i]; sz += item.res_.size(); if( item.argN_ == format_item_t::argN_tabulation) sz = max BOOST_PREVENT_MACRO_SUBSTITUTION (sz, static_cast
(item.fmtstate_.width_) ); sz += item.appendix_.size(); } return sz; #ifdef BOOST_MSVC #pragma warning(pop) #endif } namespace io { namespace detail { template
basic_format
& bind_arg_body (basic_format
& self, int argN, const T& val) { // bind one argument to a fixed value // this is persistent over clear() calls, thus also over str() and << if(self.dumped_) self.clear(); // needed because we will modify cur_arg_ if(argN<1 || argN > self.num_args_) { if( self.exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range(argN, 1, self.num_args_+1 ) ); else return self; } if(self.bound_.size()==0) self.bound_.assign(self.num_args_,false); else BOOST_ASSERT( self.num_args_ == static_cast
(self.bound_.size()) ); int o_cur_arg = self.cur_arg_; self.cur_arg_ = argN-1; // arrays begin at 0 self.bound_[self.cur_arg_]=false; // if already set, we unset and re-sets.. self.operator%(val); // put val at the right place, because cur_arg is set // Now re-position cur_arg before leaving : self.cur_arg_ = o_cur_arg; self.bound_[argN-1]=true; if(self.cur_arg_ == argN-1 ) { // hum, now this arg is bound, so move to next free arg while(self.cur_arg_ < self.num_args_ && self.bound_[self.cur_arg_]) ++self.cur_arg_; } // In any case, we either have all args, or are on a non-binded arg : BOOST_ASSERT( self.cur_arg_ >= self.num_args_ || ! self.bound_[self.cur_arg_]); return self; } template
basic_format
& modify_item_body (basic_format
& self, int itemN, T manipulator) { // applies a manipulator to the format_item describing a given directive. // this is a permanent change, clear or reset won't cancel that. if(itemN<1 || itemN > static_cast
(self.items_.size() )) { if( self.exceptions() & io::out_of_range_bit ) boost::throw_exception(io::out_of_range(itemN, 1, static_cast
(self.items_.size()) )); else return self; } self.items_[itemN-1].fmtstate_. template apply_manip
( manipulator ); return self; } } // namespace detail } // namespace io } // namespace boost #endif // BOOST_FORMAT_IMPLEMENTATION_HPP
format_implementation.hpp
Page URL
File URL
Prev
7/12
Next
Download
( 10 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.