⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic_cstring.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 2 页
字号:
template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::operator=( std_string const& s ){    return *this = self_type( s );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::operator=( pointer s ){    return *this = self_type( s );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( basic_cstring<CharT> const& s, size_type pos, size_type len ){    return *this = self_type( s.m_begin + pos, len );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( std_string const& s ){    return *this = self_type( s );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( std_string const& s, size_type pos, size_type len ){    return *this = self_type( s.c_str() + pos, len );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( pointer s ){    return *this = self_type( s );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( pointer s, size_type len ){    return *this = self_type( s, len );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>&basic_cstring<CharT>::assign( pointer f, pointer l ){    return *this = self_type( f, l );}//____________________________________________________________________________//template<typename CharT>inline voidbasic_cstring<CharT>::assign_to( std_string& target ) const{    target.assign( begin(), size() );}//____________________________________________________________________________//template<typename CharT>inline voidbasic_cstring<CharT>::swap( basic_cstring<CharT>& s ){    // do not want to include alogrithm    pointer tmp1    = m_begin;    pointer tmp2    = m_end;    m_begin         = s.m_begin;    m_end           = s.m_end;    s.m_begin       = tmp1;    s.m_end         = tmp2;}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::iteratorbasic_cstring<CharT>::begin(){    return m_begin;}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::const_iteratorbasic_cstring<CharT>::begin() const{    return m_begin;}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::iteratorbasic_cstring<CharT>::end(){    return m_end;}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::const_iteratorbasic_cstring<CharT>::end() const{    return m_end;}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::size_typebasic_cstring<CharT>::find( basic_cstring<CharT> substr ) const{    if( substr.is_empty() || substr.size() > size() )        return (size_type)npos;    const_iterator it   = begin();    const_iterator last = end() - substr.size() + 1;    while( it != last ) {        if( traits_type::compare( it, substr.begin(), substr.size() ) == 0 )            break;        ++it;    }    return it == last ? (size_type)npos : it - begin();}//____________________________________________________________________________//template<typename CharT>inline typename basic_cstring<CharT>::size_typebasic_cstring<CharT>::rfind( basic_cstring<CharT> substr ) const{    if( substr.is_empty() || substr.size() > size() )        return (size_type)npos;    const_iterator it   = end() - substr.size();    const_iterator last = begin()-1;    while( it != last ) {        if( traits_type::compare( it, substr.begin(), substr.size() ) == 0 )            break;        --it;    }    return it == last ? npos : it - begin();}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>basic_cstring<CharT>::substr( size_type beg_index, size_type end_index ) const{    return beg_index > size()            ?       self_type()            : end_index > size()                ?   self_type( m_begin + beg_index, m_end )                :   self_type( m_begin + beg_index, m_begin + end_index );}//____________________________________________________________________________//template<typename CharT>inline basic_cstring<CharT>basic_cstring<CharT>::default_trim_ex(){    static CharT ws[3] = { CharT(' '), CharT('\t'), CharT('\n') }; //!! wide case    return self_type( ws, 3 );}//____________________________________________________________________________//// ************************************************************************** //// **************             comparison operators             ************** //// ************************************************************************** //template<typename CharT1,typename CharT2>inline booloperator==( basic_cstring<CharT1> const& s1, basic_cstring<CharT2> const& s2 ){    typedef typename basic_cstring<CharT1>::traits_type traits_type;    return s1.size() == s2.size() &&                traits_type::compare( s1.begin(), s2.begin(), s1.size() ) == 0;}//____________________________________________________________________________//template<typename CharT1,typename CharT2>inline booloperator==( basic_cstring<CharT1> const& s1, CharT2* s2 ){    return s1 == basic_cstring<CharT2>( s2 );}//____________________________________________________________________________//template<typename CharT>inline booloperator==( basic_cstring<CharT> const& s1, typename basic_cstring<CharT>::std_string const& s2 ){    return s1 == basic_cstring<CharT>( s2 );}//____________________________________________________________________________//template<typename CharT1,typename CharT2>inline booloperator==( CharT1* s2, basic_cstring<CharT2> const& s1 ){    return s1 == s2;}//____________________________________________________________________________//template<typename CharT>inline booloperator==( typename basic_cstring<CharT>::std_string const& s2, basic_cstring<CharT> const& s1 ){    return s1 == s2;}//____________________________________________________________________________//template<typename CharT>inline booloperator!=( basic_cstring<CharT> const& s1, CharT* s2 ){    return !(s1 == s2);}//____________________________________________________________________________//template<typename CharT>inline booloperator!=( CharT* s2, basic_cstring<CharT> const& s1 ){    return !(s1 == s2);}//____________________________________________________________________________//template<typename CharT>inline booloperator!=( basic_cstring<CharT> const& s1, basic_cstring<CharT> const& s2 ){    return !(s1 == s2);}//____________________________________________________________________________//template<typename CharT>inline booloperator!=( basic_cstring<CharT> const& s1, typename basic_cstring<CharT>::std_string const& s2 ){    return !(s1 == s2);}//____________________________________________________________________________//template<typename CharT>inline booloperator!=( typename basic_cstring<CharT>::std_string const& s2, basic_cstring<CharT> const& s1 ){    return !(s1 == s2);}//____________________________________________________________________________//// ************************************************************************** //// **************                  first_char                  ************** //// ************************************************************************** //template<typename CharT>inline typename basic_cstring<CharT>::value_typefirst_char( basic_cstring<CharT> source ){    typedef typename basic_cstring<CharT>::value_type string_value_type;    return source.is_empty() ? (string_value_type)0 : *source.begin();}//____________________________________________________________________________//// ************************************************************************** //// **************                  last_char                   ************** //// ************************************************************************** //template<typename CharT>inline typename basic_cstring<CharT>::value_typelast_char( basic_cstring<CharT> source ){    typedef typename basic_cstring<CharT>::value_type string_value_type;    return source.is_empty() ? (string_value_type)0 : *(source.end()-1);}//____________________________________________________________________________//} // namespace unit_test} // namespace boost// ***************************************************************************//  Revision History ://  //  $Log: basic_cstring.hpp,v $//  Revision 1.1.1.1  2004/11/20 10:52:22  spion//  Import of Boost v. 1.32.0////  Revision 1.11  2004/10/05 02:17:47  rogeeff//  workaround guard rewritten////  Revision 1.10  2004/10/01 10:51:28  rogeeff//  gcc 2.95 workarounds////  Revision 1.9  2004/07/19 12:25:48  rogeeff//  guard rename//  portability fix////  Revision 1.8  2004/06/29 04:32:25  rogeeff//  no message////  Revision 1.7  2004/06/07 07:33:19  rogeeff//  amother borland patch//  detail namespace renamed////  Revision 1.6  2004/06/05 11:02:15  rogeeff//  std::traits usage reworked////  Revision 1.5  2004/06/01 11:07:53  tknapen//  port to vacpp version 6////  Revision 1.4  2004/05/27 06:24:28  rogeeff//  workaround for gcc 2.95 io//  workaround for cwpro array definition////  Revision 1.3  2004/05/25 11:01:25  rogeeff//  make npos to have a named type////  Revision 1.2  2004/05/21 06:19:35  rogeeff//  licence update////  Revision 1.1  2004/05/11 11:00:55  rogeeff//  basic_cstring introduced and used everywhere//  class properties reworked//// ***************************************************************************#endif // BASIC_CSTRING_HPP_071894GER

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -