C++ young 程序库——y_char_function.hpp 和 y_char_traits.hpp

该博客展示了Young库中字符函数的C++实现,包含了如isspace、strlen等常见字符处理函数的内联定义,还定义了不同大小写比较和复制的函数,以及针对wchar_t类型的不同大小写特性类,为字符处理提供了丰富的功能。

文件位置:young/string/y_char_function.hpp

/*
The young Library
Copyright (c) 2005 by 杨桓

Permission to use, copy, modify, distribute and sell this software for any
purpose is hereby granted without fee, provided that the above copyright
notice appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation.
The author make no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.
*/

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#ifndef __MACRO_CPLUSPLUS_YOUNG_LIBRARY_CHAR_FUNCTION_HEADER_FILE__
#define __MACRO_CPLUSPLUS_YOUNG_LIBRARY_CHAR_FUNCTION_HEADER_FILE__
//-----------------------------------------------------------------------------
#include <cctype>
#include <cstring>
//#include <wctype.h>
//#include <wchar.h>

#include "../y_define.hpp"
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_YOUNG_LIBRARY_BEGIN_NAMESPACE__
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

inline int isspace( int c )
{
    return std::isspace(c);
}

inline size_t strlen( const char* string )
{
    return std::strlen(string);
}

inline int tolower( int c )
{
    return std::tolower(c);
}

inline int toupper( int c )
{
    return std::toupper(c);
}

inline int memcmp( const void* buf1, const void* buf2, size_t count_bytes )
{
    return std::memcmp( buf1, buf2, count_bytes );
}

inline void* memcpy( void* dest, const void* src, size_t count_bytes )
{
    return std::memcpy( dest, src, count_bytes );
}

inline void* memmove( void* dest, const void* src, size_t count_bytes )
{
    return std::memmove( dest, src, count_bytes );
}

inline void* memset( void* dest, int c, size_t count )
{
    return std::memset( dest, c, count );
}

inline const void* memchr( const void* buf, int c, size_t count )
{
    return std::memchr( buf, c, count );
}

//-----------------------------------------------------------------------------

inline int iswspace( wint_t c )
{
//    return std::iswspace(c);
    return iswspace(c);
}

inline size_t wcslen( const wchar_t* string )
{
//    return std::wcslen(string);
    return wcslen(string);
}

inline int towlower( wint_t c )
{
//    return std::towlower(c);
    return towlower(c);
}

inline int towupper( wint_t c )
{
//    return std::towupper(c);
    return towupper(c);
}

inline int wmemcmp( const wchar_t* buf1, const wchar_t* buf2, size_t count )
{
//    return std::wmemcmp( buf1, buf2, count );
    return wmemcmp( buf1, buf2, count );
}

inline wchar_t* wmemcpy( wchar_t* dest, const wchar_t* src, size_t count )
{
//    return std::wmemcpy( dest, src, count );
    return wmemcpy( dest, src, count );
}

inline wchar_t* wmemmove( wchar_t* dest, const wchar_t* src, size_t count )
{
//    return std::wmemmove( dest, src, count );
    return wmemmove( dest, src, count );
}

inline wchar_t* wmemset( wchar_t* dest, wchar_t c, size_t count )
{
//    return std::wmemset( dest, c, count );
    return wmemset( dest, c, count );
}

inline const wchar_t* wmemchr( const wchar_t* buf, wchar_t c, size_t count )
{
//    return std::wmemchr( buf, c, count );
    return wmemchr( buf, c, count );
}

//-----------------------------------------------------------------------------

int charcmp_lower( const char* s1, const char* s2, size_t count )
{
    for( size_t i = 0; i < count; ++i,++s1,++s2 )
    {
        int value1 = tolower( *s1 );
        int value2 = tolower( *s2 );
        if( value1 != value2 )
            return ( value1 < value2 ? -1 : 1 );
    }
    return 0;
}

int charcmp_upper( const char* s1, const char* s2, size_t count )
{
    for( size_t i = 0; i < count; ++i,++s1,++s2 )
    {
        int value1 = toupper( *s1 );
        int value2 = toupper( *s2 );
        if( value1 != value2 )
            return ( value1 < value2 ? -1 : 1 );
    }
    return 0;
}

char* charcopy_lower( char* dest, const char* src, size_t count )
{
    for( size_t i = 0; i < count ; ++i,++dest,++src )
        *dest = tolower( *src );
    return dest;
}

char* charcopy_upper( char* dest, const char* src, size_t count )
{
    for( size_t i = 0; i < count ; ++i,++dest,++src )
        *dest = toupper( *src );
    return dest;
}

char* charmove_lower( char* dest, const char* src, size_t count )
{
    char* temp = new char[count];
    charcopy_lower( temp, src, count );
    memcpy( dest, temp, count );
    delete[] temp;
    return ( dest + count );
}

char* charmove_upper( char* dest, const char* src, size_t count )
{
    char* temp = new char[count];
    charcopy_upper( temp, src, count );
    memcpy( dest, temp, count );
    delete[] temp;
    return ( dest + count );
}

char* charset_lower( char* dest, char c, size_t count )
{
    char value = tolower(c);
    for( size_t i = 0; i < count; ++i,++dest )
        *dest = value;
    return dest;
}

char* charset_upper( char* dest, char c, size_t count )
{
    char value = toupper(c);
    for( size_t i = 0; i < count; ++i,++dest )
        *dest = value;
    return dest;
}

//-----------------------------------------------------------------------------

int wcharcmp_lower( const wchar_t* s1, const wchar_t* s2, size_t count )
{
    for( size_t i = 0; i < count; ++i,++s1,++s2 )
    {
        int value1 = towlower( *s1 );
        int value2 = towlower( *s2 );
        if( value1 != value2 )
            return ( value1 < value2 ? -1 : 1 );
    }
    return 0;
}

int wcharcmp_upper( const wchar_t* s1, const wchar_t* s2, size_t count )
{
    for( size_t i = 0; i < count; ++i,++s1,++s2 )
    {
        int value1 = towupper( *s1 );
        int value2 = towupper( *s2 );
        if( value1 != value2 )
            return ( value1 < value2 ? -1 : 1 );
    }
    return 0;
}

wchar_t* wcharcopy_lower( wchar_t* dest, const wchar_t* src, size_t count )
{
    for( size_t i = 0; i < count ; ++i,++dest,++src )
        *dest = towlower( *src );
    return dest;
}

wchar_t* wcharcopy_upper( wchar_t* dest, const wchar_t* src, size_t count )
{
    for( size_t i = 0; i < count ; ++i,++dest,++src )
        *dest = towupper( *src );
    return dest;
}

wchar_t* wcharmove_lower( wchar_t* dest, const wchar_t* src, size_t count )
{
    wchar_t* temp = new wchar_t[count];
    wcharcopy_lower( temp, src, count );
    memcpy( dest, temp, sizeof(wchar_t) * count );
    delete[] temp;
    return ( dest + count );
}

wchar_t* wcharmove_upper( wchar_t* dest, const wchar_t* src, size_t count )
{
    wchar_t* temp = new wchar_t[count];
    wcharcopy_upper( temp, src, count );
    memcpy( dest, temp, sizeof(wchar_t) * count );
    delete[] temp;
    return ( dest + count );
}

wchar_t* wcharset_lower( wchar_t* dest, wchar_t c, size_t count )
{
    int value = towlower(c);
    for( size_t i = 0; i < count; ++i,++dest )
        *dest = value;
    return dest;
}

wchar_t* wcharset_upper( wchar_t* dest, wchar_t c, size_t count )
{
    int value = towupper(c);
    for( size_t i = 0; i < count; ++i,++dest )
        *dest = value;
    return dest;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_YOUNG_LIBRARY_END_NAMESPACE__
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

文件位置:young/y_char_traits.hpp

/*
The young Library
Copyright (c) 2005 by 杨桓

Permission to use, copy, modify, distribute and sell this software for any
purpose is hereby granted without fee, provided that the above copyright
notice appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation.
The author make no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.
*/

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#ifndef __MACRO_CPLUSPLUS_YOUNG_LIBRARY_CHAR_TRAITS_HEADER_FILE__
#define __MACRO_CPLUSPLUS_YOUNG_LIBRARY_CHAR_TRAITS_HEADER_FILE__
//-----------------------------------------------------------------------------
#include "string/y_char_function.hpp"
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_YOUNG_LIBRARY_BEGIN_NAMESPACE__
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

typedef  std::mbstate_t  mbstate_t;
typedef  std::streampos  streampos;
typedef  std::streamoff  streamoff;
typedef  std::streampos  wstreampos;
typedef  std::streamoff  wstreamoff;
//typedef  std::wstreampos  wstreampos;
//typedef  std::wstreamoff  wstreamoff;

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

template< typename CharType >
class char_traits
{
public:
    typedef  CharType    char_type;
    typedef  long        int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return char_type();  }
    static bool is_del( char_type c )  {  return false;  }

    static void assign( char_type& d, const char_type& s )
        {  d = s;  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
    {
     size_type i = 0;
     while( !eq( *s++, eos() ) )
         ++i;
     return i;
    }

    // (1) < 0 : s1 < s2;  (2) = 0 : s1 = s2;  (3) > 0 : s1 > s2
    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
     for( size_type i = 0; i < count; ++i )
     {
         if( !eq( s1[i], s2[i] ) )
             return ( lt(s1[i], s2[i]) ? -1 : 1 );
     }
     return 0;
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
    {
     for( size_type i = 0; i < count ; ++i )
         assign( d[i], s[i] );
     return ( d + count );
    }

    static char_type* move( char_type* d, const char_type* s, size_type count )
    {
     char_type* temp = new char_type[count];
     copy( temp, s, count );
     copy( d, temp, count );
     delete[] temp;
     return ( d + count );
    }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
    {
     for( size_type i = 0; i < count ; ++i )
         assign( d[i], c );
     return ( d + count );
    }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
    {
        for( size_type i = 0; i < count; ++i,++buf )
        {
            if( eq( *buf, c ) )
                return buf;
        }
        return NULL_POINTER;
    }

}; //end char_traits

//-----------------------------------------------------------------------------

template<>
class char_traits<char>
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = s;  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = memcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return (char_type*)memcpy( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return (char_type*)memmove( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return (char_type*)memset( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end char_traits<char>

//-----------------------------------------------------------------------------

template<>
class char_traits<wchar_t>
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = s;  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = wmemcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wmemcpy( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wmemmove( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wmemset( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end char_traits<wchar_t>

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class cmp_no_case_char_traits  //比较时不区分大小写char的traits
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = s;  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( tolower(c1) == tolower(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( tolower(c1) < tolower(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return charcmp_lower( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return (char_type*)memcpy( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return (char_type*)memmove( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return (char_type*)memset( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end cmp_no_case_char_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class lower_char_traits  //全部是小写char的traits
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = tolower(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = memcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return charcopy_lower( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return charmove_lower( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return charset_lower( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end lower_char_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class upper_char_traits  //全部是大写char的traits
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = toupper(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = memcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return charcopy_upper( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return charmove_upper( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return charset_upper( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end upper_char_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

//字符串内全部是小写char并且和其他字符串进行比较时不区分大小写的traits
class cmp_no_case_lower_char_traits
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = tolower(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( tolower(c1) == tolower(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( tolower(c1) < tolower(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return charcmp_lower( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return charcopy_lower( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return charmove_lower( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return charset_lower( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end cmp_no_case_lower_char_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

//字符串内全部是大写char并且和其他字符串进行比较时不区分大小写的traits
class cmp_no_case_upper_char_traits
{
public:
    typedef  char        char_type;
    typedef  int         int_type;
    typedef  streampos   pos_type;
    typedef  streamoff   off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return isspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = toupper(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( toupper(c1) == toupper(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( toupper(c1) < toupper(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( static_cast<unsigned char>(c) );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( EOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return strlen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return charcmp_upper( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return charcopy_upper( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return charmove_upper( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return charset_upper( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return (char_type*)memchr( buf, c, count );  }

}; //end cmp_no_case_upper_char_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class cmp_no_case_wchar_traits  //比较时不区分大小写wchar_t的traits
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = s;  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( towlower(c1) == towlower(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( towlower(c1) < towlower(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return wcharcmp_lower( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wmemcpy( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wmemmove( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wmemset( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end cmp_no_case_wchar_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class lower_wchar_traits  //全部是小写wchar_t的traits
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = towlower(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = wmemcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wcharcopy_lower( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wcharmove_lower( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wcharset_lower( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end lower_wchar_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

class upper_wchar_traits  //全部是大写wchar_t的traits
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = towupper(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( c1 == c2 );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( c1 < c2 );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
    {
        int result = wmemcmp( s1, s2, count );
        if( result == 0 )
            return 0;
        else
            return ( result < 0 ? -1 : 1 );
    }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wcharcopy_upper( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wcharmove_upper( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wcharset_upper( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end upper_wchar_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

//字符串内全部是小写wchar_t并且和其他字符串进行比较时不区分大小写的traits
class cmp_no_case_lower_wchar_traits
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = towlower(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( towlower(c1) == towlower(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( towlower(c1) < towlower(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return wcharcmp_lower( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wcharcopy_lower( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wcharmove_lower( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wcharset_lower( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end cmp_no_case_lower_wchar_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

//字符串内全部是大写wchar_t并且和其他字符串进行比较时不区分大小写的traits
class cmp_no_case_upper_wchar_traits
{
public:
    typedef  wchar_t     char_type;
    typedef  wint_t      int_type;
    typedef  wstreamoff  pos_type;
    typedef  wstreampos  off_type;
    typedef  mbstate_t   state_type;
    typedef  def_size_t  size_type;

    static char_type eos()             {  return 0;  }
    static bool is_del( char_type c )  {  return iswspace(c);  }

    static void assign( char_type& d, const char_type& s )
        {  d = towupper(s);  }
    static bool eq( const char_type& c1, const char_type& c2 )
        {  return ( towupper(c1) == towupper(c2) );  }
    static bool lt( const char_type& c1, const char_type& c2 )
        {  return ( towupper(c1) < towupper(c2) );  }

    static char_type to_char_type( const int_type& i )
        {  return static_cast<char_type>( i );  }
    static int_type to_int_type( const char_type& c )
        {  return static_cast<int_type>( c );  }
    static bool eq_int_type( const int_type& i1, const int_type& i2 )
        {  return ( i1 == i2 );  }

    static int_type eof()
        {  return static_cast<int_type>( WEOF );  }
    static int_type not_eof( const int_type& i )
        {  return ( i == eof() ? 0 : i );  }

    static size_type length( const char_type* s )
        {  return wcslen(s);  }

    static int compare( const char_type* s1, const char_type* s2, size_type count )
        {  return wcharcmp_upper( s1, s2, count );  }

    static char_type* copy( char_type* d, const char_type* s, size_type count )
        {  return wcharcopy_upper( d, s, count );  }

    static char_type* move( char_type* d, const char_type* s, size_type count )
        {  return wcharmove_upper( d, s, count );  }

    static char_type* assign( char_type* d, size_type count, const char_type& c )
        {  return wcharset_upper( d, c, count );  }

    static const char_type*
    find( const char_type* buf, size_type count, const char_type& c )
        {  return wmemchr( buf, c, count );  }

}; //end cmp_no_case_upper_wchar_traits

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_YOUNG_LIBRARY_END_NAMESPACE__
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------



你不要再写代码了 你为什么不早说 现在它已经再编译了啊“C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\__msvc_ostream.hpp(781): note: 模板实例化上下文(最早的实例化上下文)为 E:\PyTorch_Build\pytorch\third_party\ideep\mkl-dnn\src\common\profiler.hpp(147): note: 查看对正在编译的函数 模板 实例化“std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)”的引用 [1639/7457] Building CXX object third_party\ideep\mkl-dnn\...MakeFiles\dnnl_cpu_x64.dir\injectors\injector_utils.cpp.ob cl: 命令行 warning D9025 :正在重写“/MT”(用“/MD”) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\__msvc_ostream.hpp(781): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\__msvc_ostream.hpp(781): note: 模板实例化上下文(最早的实例化上下文)为 E:\PyTorch_Build\pytorch\third_party\ideep\mkl-dnn\src\common\profiler.hpp(147): note: 查看对正在编译的函数 模板 实例化“std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)”的引用 [1640/7457] Building CXX object third_party\ideep\mkl-dnn\src\cpu\x64\CMakeFiles\dnnl_cpu_x64.dir\ip_convolution.cpp.ob cl: 命令行 warning D9025 :正在重写“/MT”(用“/MD”) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\ppltasks.h(1580): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc [1641/7457] Building CXX object third_party\ideep\mkl-dnn\...nnl_cpu_x64.dir\jit_avx512_core_amx_1x1_convolution.cpp.ob cl: 命令行 warning D9025 :正在重写“/MT”(用“/MD”) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\ppltasks.h(1580): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc [1642/7457] Building CXX object third_party\ideep\mkl-dnn\...64\CMakeFiles\dnnl_cpu_x64.dir\jit_avx2_convolution.cpp.ob cl: 命令行 warning D9025 :正在重写“/MT”(用“/MD”) C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\ppltasks.h(1580): warning C4530: 使用了 C++ 异常处理程序,但未启用展开语义。请指定 /EHsc”你要我怎么做 停下来吗
最新发布
09-01
FAILED: CMakeFiles/gazebo_aruco_plugin.dir/src/gazebo_aruco_plugin.cpp.o /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_TEST_DYN_LINK -DBOOST_THREAD_DYN_LINK -DLIBBULLET_VERSION=3.05 -DLIBBULLET_VERSION_GT_282 -Dgazebo_aruco_plugin_EXPORTS -I/home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include -I/home/yxz/PX4_Firmware/build/px4_sitl_default/build_gazebo-classic -I/usr/include/eigen3/eigen3 -I/usr/include/gazebo-11/gazebo/msgs -I/home/yxz/PX4_Firmware/build/px4_sitl_default/mavlink -I/home/yxz/PX4_Firmware/build/px4_sitl_default/mavlink/mavlink/v2.0 -I/home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/external/OpticalFlow/include -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem /usr/include/gazebo-11 -isystem /usr/include/bullet -isystem /usr/include/simbody -isystem /usr/include/sdformat-9.7 -isystem /usr/include/ignition/math6 -isystem /usr/include/OGRE -isystem /usr/include/OGRE/Terrain -isystem /usr/include/OGRE/Paging -isystem /usr/include/ignition/transport8 -isystem /usr/include/ignition/msgs5 -isystem /usr/include/ignition/common3 -isystem /usr/include/ignition/fuel_tools4 -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -isystem /usr/include/eigen3 -isystem /usr/local/include/opencv4 -isystem /usr/include/sdformat-9.7/sdf/.. -isystem /usr/include/ignition/cmake2 -isystem /usr/include/uuid -O2 -g -DNDEBUG -fPIC -Wno-deprecated-declarations -Wno-address-of-packed-member -I/usr/include/uuid -MD -MT CMakeFiles/gazebo_aruco_plugin.dir/src/gazebo_aruco_plugin.cpp.o -MF CMakeFiles/gazebo_aruco_plugin.dir/src/gazebo_aruco_plugin.cpp.o.d -o CMakeFiles/gazebo_aruco_plugin.dir/src/gazebo_aruco_plugin.cpp.o -c /home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp In file included from /home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/gazebo_aruco_plugin.cpp:31: /home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/gazebo_aruco_plugin.h:41: fatal error: opencv2/aruco.hpp: No such file or directory 41 | #include <opencv2/aruco.hpp> | compilation terminated. [72/142] Building CXX object CMakeFile...erface.dir/src/mavlink_interface.cpp.o In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22, from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23, from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14, from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42, from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25, from /usr/include/boost/smart_ptr/shared_ptr.hpp:29, from /usr/include/boost/shared_ptr.hpp:17, from /usr/include/boost/date_time/time_clock.hpp:17, from /usr/include/boost/date_time/posix_time/posix_time_types.hpp:10, from /usr/include/boost/asio/time_traits.hpp:23, from /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22, from /usr/include/boost/asio/detail/deadline_timer_service.hpp:29, from /usr/include/boost/asio/basic_deadline_timer.hpp:25, from /usr/include/boost/asio.hpp:25, from /home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/include/mavlink_interface.h:36, from /home/yxz/PX4_Firmware/Tools/simulation/gazebo-classic/sitl_gazebo-classic/src/mavlink_interface.cpp:1: /usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’ 36 | BOOST_PRAGMA_MESSAGE( | ^~~~~~~~~~~~~~~~~~~~ [77/142] Building CXX object CMakeFile...src/gazebo_camera_manager_plugin.cpp.o ninja: build stopped: subcommand failed. [899/903] Linking CXX executable bin/px4 FAILED: external/Stamp/sitl_gazebo-classic/sitl_gazebo-classic-build /home/yxz/PX4_Firmware/build/px4_sitl_default/external/Stamp/sitl_gazebo-classic/sitl_gazebo-classic-build cd /home/yxz/PX4_Firmware/build/px4_sitl_default/build_gazebo-classic && /usr/bin/cmake --build /home/yxz/PX4_Firmware/build/px4_sitl_default/build_gazebo-classic -- -j 7 ninja: build stopped: subcommand failed. make: *** [Makefile:227: px4_sitl_default] Error 1
07-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值