当前位置: 首页>>代码示例>>C++>>正文


C++ string_type::size方法代码示例

本文整理汇总了C++中string_type::size方法的典型用法代码示例。如果您正苦于以下问题:C++ string_type::size方法的具体用法?C++ string_type::size怎么用?C++ string_type::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在string_type的用法示例。


在下文中一共展示了string_type::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: consume

	void backend::consume(string_type const& formatted_message)
	{
		if (!impl_)
			return;

		if((impl_->file_.is_open() && (impl_->written_ + formatted_message.size() >= 512*1024) )
			|| !impl_->file_.good()
			)
		{
			rotate_file();
		}

		if (!impl_->file_.is_open())
		{
			fs::create_directories(impl_->root_);
			impl_->file_.open((impl_->root_ / (impl_->name_ + L".log")).c_str(), std::ios_base::app | std::ios_base::out);
			if (!impl_->file_.is_open())
			{
				throw bee::exception("Failed to open file '%s' for writing.", (impl_->root_ / (impl_->name_ + L".log")).string().c_str());
			}

			impl_->written_ = static_cast<std::streamoff>(impl_->file_.tellp());
		}

		impl_->file_.write(formatted_message.data(), static_cast<std::streamsize>(formatted_message.size()));
		impl_->file_.put(static_cast<string_type::value_type>('\n'));
		impl_->written_ += formatted_message.size() + 1;
		impl_->file_.flush();
	}
开发者ID:actboy168,项目名称:YDWE,代码行数:29,代码来源:logging_backend.cpp

示例2: compare

	int compare(string_type const& a, string_type const& b) const
	{
		return collate_.compare(
			a.data(), a.data() + a.size(), 
			b.data(), b.data() + b.size()
			);
	}
开发者ID:chanchancl,项目名称:YDWE,代码行数:7,代码来源:YDWEHook.cpp

示例3: insert

 void insert(const string_type& s, unsigned short value)
 {
   unsigned int i = 0;
   iterator ti;
   while(i < s.size()) {
     if (i==0) {
       if (i == (s.size()-1)) {
         ti = m_next_chars.insert(value_type(s[i], 
                                             string_parse_tree<charT>(value)));
       }
       else {
         ti = m_next_chars.insert(value_type(s[i], 
                                             string_parse_tree<charT>()));
       }
     }
     else {
       if (i == (s.size()-1)) {
         ti = ti->second.m_next_chars.insert(value_type(s[i], 
                                                        string_parse_tree<charT>(value)));
       }
       
       else {
         ti = ti->second.m_next_chars.insert(value_type(s[i], 
                                                        string_parse_tree<charT>()));
       }
     
     } 
     i++;
   }
 }
开发者ID:Ezeer,项目名称:VegaStrike_win32FR,代码行数:30,代码来源:string_parse_tree.hpp

示例4: endsOn

			static bool endsOn(string_type const & name, string_type const & suffix)
			{
				if ( name.size() < suffix.size() )
					return false;
				for ( unsigned int i = 0; i < suffix.size(); ++i )
					if ( name[ name.size()-suffix.size()+i ] != suffix[i] )
						return false;
				return true;
			}
开发者ID:gt1,项目名称:libmaus2,代码行数:9,代码来源:stringFunctions.hpp

示例5: equals

 static bool equals(const string_type& str1, const string_type& str2) {
     if(str1.size() != str2.size()) {
         return false;
     } else if(str1.empty() && str2.empty()) {
         return true;
     } else {
         return std::equal(
             str1.begin(),
             str1.end(),
             str2.begin()
         );
     }
     
 }
开发者ID:soareschen,项目名称:boost.ustr,代码行数:14,代码来源:string_traits.hpp

示例6: append_string

        /**
            @brief appends a string (inserts it at the end)
        */
        void append_string(const string_type & str) {
            if ( m_reserve_append < str.size()) {
                std::size_t new_reserve_append = str.size() + m_grow_size ;
                resize_string( m_reserve_prepend, new_reserve_append);
            }

            BOOST_ASSERT(m_reserve_append >= str.size());

            typename string_type::difference_type start_idx = static_cast<typename string_type::difference_type>(m_str.size() - m_reserve_append);

            std::copy(str.begin(), str.end(), m_str.begin() + start_idx);
            m_reserve_append -= str.size();
            m_full_msg_computed = false;
        }
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:17,代码来源:optimize.hpp

示例7: append_string

        /** 
            @brief appends a string (inserts it at the end)
        */
        void append_string(const string_type & str) {
            if ( m_reserve_append < (int)str.size()) {
                int new_reserve_append = (int)str.size() + m_grow_size ;
                resize_string( m_reserve_prepend, new_reserve_append);
            }

            BOOST_ASSERT(m_reserve_append >= (int)str.size() );

            int start_idx = (int)m_str.size() - m_reserve_append;

            std::copy(str.begin(), str.end(), m_str.begin() + start_idx);
            m_reserve_append -= (int)str.size();
            m_full_msg_computed = false;
        }
开发者ID:cargabsj175,项目名称:bombono-dvd,代码行数:17,代码来源:optimize.hpp

示例8: post

 response post(request request, string_type const& body = string_type(),
               string_type const& content_type = string_type(),
               body_callback_function_type body_handler =
                   body_callback_function_type(),
               body_generator_function_type body_generator =
                   body_generator_function_type()) {
   if (body != string_type()) {
     request << remove_header("Content-Length")
             << header("Content-Length",
                       boost::lexical_cast<string_type>(body.size()))
             << boost::network::body(body);
   }
   typename headers_range<basic_request<Tag> >::type content_type_headers =
       headers(request)["Content-Type"];
   if (content_type != string_type()) {
     if (!boost::empty(content_type_headers))
       request << remove_header("Content-Type");
     request << header("Content-Type", content_type);
   } else {
     if (boost::empty(content_type_headers)) {
       typedef typename char_<Tag>::type char_type;
       static char_type content_type[] = "x-application/octet-stream";
       request << header("Content-Type", content_type);
     }
   }
   return pimpl->request_skeleton(request, "POST", true, body_handler,
                                  body_generator);
 }
开发者ID:ahamez,项目名称:netexplorer,代码行数:28,代码来源:facade.hpp

示例9: move

filter default_filter_factory< CharT >::parse_argument(attribute_name const& name, string_type const& arg)
{
    typedef log::aux::encoding_specific< typename log::aux::encoding< char_type >::type > encoding_specific;
    const qi::real_parser< double, qi::strict_real_policies< double > > real_;

    filter f;
    const on_fp_argument< RelationT > on_fp(name, f);
    const on_integral_argument< RelationT > on_int(name, f);
    const on_string_argument< RelationT > on_str(name, f);

    const bool res = qi::parse
    (
        arg.c_str(), arg.c_str() + arg.size(),
        (
            real_[boost::log::as_action(on_fp)] |
            qi::long_[boost::log::as_action(on_int)] |
            qi::as< string_type >()[ +encoding_specific::print ][boost::log::as_action(on_str)]
        ) >> qi::eoi
    );

    if (!res)
        BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");

    return boost::move(f);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例10: testbuf

 testbuf(const string_type& str)
     : str_(str)
 {
     base::setg(const_cast<CharT*>(str_.data()),
                const_cast<CharT*>(str_.data()),
                const_cast<CharT*>(str_.data()) + str_.size());
 }
开发者ID:32bitmicro,项目名称:libcxx,代码行数:7,代码来源:tellg.pass.cpp

示例11: error_code

pfs::error_code ubjson_ostream<OStreamType, JsonType>::write_string (string_type const & s, bool with_prefix)
{
    if (with_prefix) {
        // Using size is safe here (no matter the string encoding)
        if (s.size() == 1 && *s.cbegin() <= numeric_limits<int8_t>::max()) {
            _os << static_cast<int8_t>('C');
            _os << static_cast<int8_t>(*s.cbegin());
        } else {
            _os << static_cast<int8_t>('S');
            write_integer(static_cast<typename json_type::integer_type>(s.size()), true);
            _os << s.utf8();
        }
    } else {
        write_integer(static_cast<typename json_type::integer_type>(s.size()), true);
        _os << s;
    }

    return pfs::error_code();
}
开发者ID:semenovf,项目名称:pfs,代码行数:19,代码来源:ubjson_ostream.hpp

示例12: xsputn

    std::streamsize xsputn(const char_type* s, std::streamsize n) {
        typedef typename string_type::size_type size_type;
        BOOST_ASSERT(string != nullptr);

        basic_ostringstreambuf::sync();
        const size_type max_size_left = string->max_size() - string->size();
        if (static_cast<size_type>(n) < max_size_left) {
            string->append(s, static_cast<size_type>(n));
            return n;
        }

        string->append(s, max_size_left);
        return static_cast<std::streamsize>(max_size_left);
    }
开发者ID:Alukardd,项目名称:blackhole,代码行数:14,代码来源:streambuf.hpp

示例13: make_request

			std::stringstream make_request( const string_type& method, const string_type& path, const string_type& auth_header, const string_type& body ) const
			{
				std::stringstream ss;
				ss << method << " " << path << " HTTP/1.1\r\n";
				ss << "Host: " << Policy::get_domain() << "\r\n";
				ss << "Accept-Charset: utf-8\r\n";
				ss << "User-Agent: " << Policy::get_user_agent() << "\r\n";
				ss << "Content-type: application/x-www-form-urlencoded\r\n";
				ss << "Authorization: " << auth_header << "\r\n";
				ss << "Content-Length: " << body.size() << "\r\n";
				ss << "Connection: close\r\n";
				ss << "\r\n";
				ss << body << std::flush;

				return ss;
			}
开发者ID:yutopp,项目名称:oauth-lib-cpp,代码行数:16,代码来源:basic_authenticator.hpp

示例14:

typename default_filter_factory< CharT >::filter_type
default_filter_factory< CharT >::parse_argument(string_type const& name, string_type const& arg)
{
    filter_type filter;
    const bool full = bsc::parse(arg.c_str(), arg.c_str() + arg.size(),
        (
            bsc::strict_real_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_fp_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
            bsc::int_p[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_integral_argument< RelationT >, boost::cref(name), _1, boost::ref(filter))] |
            (+bsc::print_p)[boost::bind(&this_type::BOOST_NESTED_TEMPLATE on_string_argument< RelationT >, boost::cref(name), _1, _2, boost::ref(filter))]
        )
    ).full;

    if (!full || filter.empty())
        BOOST_LOG_THROW_DESCR(parse_error, "Failed to parse relation operand");

    return filter;
}
开发者ID:nairboon,项目名称:anarchnet,代码行数:17,代码来源:default_filter_factory.cpp

示例15: xsputn

 //! Puts a character sequence to the string
 std::streamsize xsputn(const char_type* s, std::streamsize n)
 {
     BOOST_ASSERT(m_Storage != 0);
     basic_ostringstreambuf::sync();
     typedef typename string_type::size_type string_size_type;
     register const string_size_type max_storage_left =
         m_Storage->max_size() - m_Storage->size();
     if (static_cast< string_size_type >(n) < max_storage_left)
     {
         m_Storage->append(s, static_cast< string_size_type >(n));
         return n;
     }
     else
     {
         m_Storage->append(s, max_storage_left);
         return static_cast< std::streamsize >(max_storage_left);
     }
 }
开发者ID:nairboon,项目名称:anarchnet,代码行数:19,代码来源:attachable_sstream_buf.hpp


注:本文中的string_type::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。