regex_traits.hpp

来自「CGAL is a collaborative effort of severa」· HPP 代码 · 共 1,199 行 · 第 1/3 页

HPP
1,199
字号
   }   static int BOOST_REGEX_CALL toi(unsigned short c)   {       return c_regex_traits<regex_wchar_type>::toi(c);    }   static int BOOST_REGEX_CALL toi(const unsigned short*& first, const unsigned short* last, int radix)   {       return c_regex_traits<regex_wchar_type>::toi(         reinterpret_cast<const regex_wchar_type*&>(first),          reinterpret_cast<const regex_wchar_type*>(last),          radix);    }   static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const unsigned short* first, const unsigned short* last)   {      return c_regex_traits<regex_wchar_type>::lookup_classname(         reinterpret_cast<const regex_wchar_type*>(first),          reinterpret_cast<const regex_wchar_type*>(last));   }   static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string<unsigned short>& s, const unsigned short* first, const unsigned short* last)   {      return c_regex_traits<regex_wchar_type>::lookup_collatename(         reinterpret_cast<std::basic_string<regex_wchar_type>&>(s),          reinterpret_cast<const regex_wchar_type*>(first),          reinterpret_cast<const regex_wchar_type*>(last));   }   static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; }   locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); }   struct sentry   {      sentry(const c_regex_traits<unsigned short>&)      { c_regex_traits<unsigned short>::update(); }      ~sentry(){}      operator void*() { return this; }   };   static void BOOST_REGEX_CALL update()   {       c_regex_traits<regex_wchar_type>::update();    }   void swap(c_regex_traits&){}   c_regex_traits(){};   ~c_regex_traits(){};   static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const unsigned short *s2)   {       return c_regex_traits<regex_wchar_type>::strnarrow(         s1,          len,          reinterpret_cast<const regex_wchar_type *>(s2));    }   static std::size_t BOOST_REGEX_CALL strwiden(unsigned short *s1, std::size_t len, const char *s2)   {       return c_regex_traits<regex_wchar_type>::strwiden(         reinterpret_cast<regex_wchar_type *>(s1), len, s2);    }private:   c_regex_traits<regex_wchar_type> m_init;};#endif // BOOST_REGEX_HAS_SHORT_WCHAR_T#endif // wide characters#if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32)namespace re_detail{struct BOOST_REGEX_DECL w32_traits_base : public regex_traits_base{   enum{   char_class_none = 0,   char_class_alnum = C1_ALPHA | C1_DIGIT,   char_class_alpha = C1_ALPHA,   char_class_cntrl = C1_CNTRL,   char_class_digit = C1_DIGIT,   char_class_graph = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_ALPHA,   char_class_lower = C1_LOWER,   char_class_print = C1_UPPER | C1_LOWER | C1_DIGIT | C1_PUNCT | C1_BLANK | C1_ALPHA,   char_class_punct = C1_PUNCT,   char_class_space = C1_SPACE,   char_class_upper = C1_UPPER,   char_class_xdigit = C1_XDIGIT,   char_class_blank = C1_BLANK,   char_class_underscore = 0x4000,   char_class_word = C1_ALPHA | C1_DIGIT | char_class_underscore,   char_class_unicode = 0x8000,   char_class_win = 0x01FF   };public:   static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s);protected:   static char regex_message_catalogue[BOOST_REGEX_MAX_PATH];   enum syntax_map_size   {      map_size = UCHAR_MAX + 1   };   static unsigned char syntax_map[map_size];   static unsigned short class_map[map_size];   static char lower_case_map[map_size];   static boost::uint_fast32_t BOOST_REGEX_CALL do_lookup_class(const char* p);   static bool BOOST_REGEX_CALL do_lookup_collate(std::string& buf, const char* p);   static void BOOST_REGEX_CALL do_free();   static void BOOST_REGEX_CALL do_init();public:   static std::string BOOST_REGEX_CALL error_string(unsigned id);   static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; }};} // namespace re_detailtemplate<class charT>class w32_regex_traits;template<>class BOOST_REGEX_DECL w32_regex_traits<char> : public re_detail::w32_traits_base{   typedef re_detail::w32_traits_base base_type;public:   typedef char char_type;   typedef unsigned char uchar_type;   typedef unsigned int size_type;   typedef std::string string_type;   typedef int locale_type;   static std::size_t BOOST_REGEX_CALL length(const char_type* p)   {      return std::strlen(p);   }   static unsigned int BOOST_REGEX_CALL syntax_type(size_type c)   {      return syntax_map[c];   }   static char BOOST_REGEX_CALL translate(char c, bool icase)   {      return icase ? lower_case_map[(size_type)(uchar_type)c] : c;   }   static void BOOST_REGEX_CALL transform(std::string& out, const std::string& in);   static void BOOST_REGEX_CALL transform_primary(std::string& out, const std::string& in);   static bool BOOST_REGEX_CALL is_separator(char c)   {      return BOOST_REGEX_MAKE_BOOL((c == '\n') || (c == '\r'));   }   static bool BOOST_REGEX_CALL is_combining(char)   {      return false;   }      static bool BOOST_REGEX_CALL is_class(char c, boost::uint_fast32_t f)   {      return BOOST_REGEX_MAKE_BOOL(class_map[(size_type)(uchar_type)c] & f);   }   static int BOOST_REGEX_CALL toi(char c);   static int BOOST_REGEX_CALL toi(const char*& first, const char* last, int radix);   static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const char* first, const char* last)   {      std::string s(first, last);      return do_lookup_class(s.c_str());   }   static bool BOOST_REGEX_CALL lookup_collatename(std::string& buf, const char* first, const char* last)   {      std::string s(first, last);      return do_lookup_collate(buf, s.c_str());   }   static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; }   locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); }   struct sentry   {      sentry(const w32_regex_traits<char>&)      { w32_regex_traits<char>::update(); }      ~sentry(){}      operator void*() { return this; }   };   static void BOOST_REGEX_CALL update();   void swap(w32_regex_traits&){}   w32_regex_traits();   ~w32_regex_traits();private:   static w32_regex_traits<char> i;};#ifndef BOOST_NO_WREGEXtemplate<>class BOOST_REGEX_DECL w32_regex_traits<regex_wchar_type> : public re_detail::w32_traits_base{   typedef re_detail::w32_traits_base base_type;public:   typedef regex_wchar_type char_type;   typedef unsigned short uchar_type;   typedef unsigned int size_type;   typedef std::basic_string<regex_wchar_type> string_type;   typedef int locale_type; #ifndef BOOST_REGEX_HAS_SHORT_WCHAR_T   static std::size_t BOOST_REGEX_CALL length(const char_type* p)   {      return std::wcslen(p);   }#else   static std::size_t BOOST_REGEX_CALL length(const char_type* p)   {      return std::wcslen(reinterpret_cast<const wchar_t*>(p));   }#endif   static unsigned int BOOST_REGEX_CALL syntax_type(size_type c);   static regex_wchar_type BOOST_REGEX_CALL translate(regex_wchar_type c, bool icase)   {      return icase ? ((c < 256) ? re_detail::wide_lower_case_map[(uchar_type)c] : wtolower(c)) : c;   }   static void BOOST_REGEX_CALL transform(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in);   static void BOOST_REGEX_CALL transform_primary(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in);   static bool BOOST_REGEX_CALL is_separator(regex_wchar_type c)   {      return BOOST_REGEX_MAKE_BOOL((c == L'\n') || (c == L'\r') || (c == (regex_wchar_type)0x2028) || (c == (regex_wchar_type)0x2029));   }   static bool BOOST_REGEX_CALL is_combining(regex_wchar_type c)   { return re_detail::is_combining(c); }      static bool BOOST_REGEX_CALL is_class(regex_wchar_type c, boost::uint_fast32_t f)   {      return BOOST_REGEX_MAKE_BOOL(((uchar_type)c < 256) ? (wide_unicode_classes[(size_type)(uchar_type)c] & f) : do_iswclass(c, f));   }   static int BOOST_REGEX_CALL toi(regex_wchar_type c);   static int BOOST_REGEX_CALL toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix);   static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last);   static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string<regex_wchar_type>& s, const regex_wchar_type* first, const regex_wchar_type* last);   static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; }   locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); }   struct sentry   {      sentry(const w32_regex_traits<regex_wchar_type>&)      { w32_regex_traits<regex_wchar_type>::update(); }      ~sentry(){}      operator void*() { return this; }   };   static void BOOST_REGEX_CALL update();   void swap(w32_regex_traits&){}   w32_regex_traits();   ~w32_regex_traits();   static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2);   static std::size_t BOOST_REGEX_CALL strwiden(regex_wchar_type *s1, std::size_t len, const char *s2);private:   static bool BOOST_REGEX_CALL do_iswclass(regex_wchar_type c, boost::uint_fast32_t f);   static bool BOOST_REGEX_CALL do_lookup_collate(std::basic_string<regex_wchar_type>& out, const regex_wchar_type* first, const regex_wchar_type* last);   static w32_regex_traits<regex_wchar_type> init_;   static regex_wchar_type BOOST_REGEX_CALL wtolower(regex_wchar_type c);   static unsigned short wide_unicode_classes[];};#ifdef BOOST_REGEX_HAS_SHORT_WCHAR_T//// What follows here is Visual Studio specific - it is a thin wrapper// that redirects calls to w32_regex_traits<unsigned short> to// w32_regex_traits<__wchar_t>.  This allows the library to be built// so that it supports programs built both with and without /Zc:wchar_t.//template<>class w32_regex_traits<unsigned short> : public re_detail::w32_traits_base{   typedef re_detail::w32_traits_base base_type;public:   typedef unsigned short char_type;   typedef unsigned short uchar_type;   typedef unsigned int size_type;   typedef std::basic_string<unsigned short> string_type;   typedef int locale_type;    static std::size_t BOOST_REGEX_CALL length(const char_type* p)   {      return w32_regex_traits<regex_wchar_type>::length(         reinterpret_cast<const regex_wchar_type*>(p));   }   static unsigned int BOOST_REGEX_CALL syntax_type(size_type c)   {       return w32_regex_traits<regex_wchar_type>::syntax_type(c);    }   static unsigned short BOOST_REGEX_CALL translate(unsigned short c, bool icase)   {      return w32_regex_traits<regex_wchar_type>::translate(c, icase);   }   static void BOOST_REGEX_CALL transform(std::basic_string<unsigned short>& out, const std::basic_string<unsigned short>& in)   {       w32_regex_traits<regex_wchar_type>::transform(         reinterpret_cast<std::basic_string<regex_wchar_type>&>(out),          reinterpret_cast<const std::basic_string<regex_wchar_type>&>(in));    }   static void BOOST_REGEX_CALL transform_primary(std::basic_string<unsigned short>& out, const std::basic_string<unsigned short>& in)   {       w32_regex_traits<regex_wchar_type>::transform_primary(         reinterpret_cast<std::basic_string<regex_wchar_type>&>(out),          reinterpret_cast<const std::basic_string<regex_wchar_type>&>(in)); }   static bool BOOST_REGEX_CALL is_separator(unsigned short c)   {      return w32_regex_traits<regex_wchar_type>::is_separator(c);   }   static bool BOOST_REGEX_CALL is_combining(unsigned short c)   {       return w32_regex_traits<regex_wchar_type>::is_combining(c);    }      static bool BOOST_REGEX_CALL is_class(unsigned short c, boost::uint_fast32_t f)   {      return w32_regex_traits<regex_wchar_type>::is_class(c, f);   }   static int BOOST_REGEX_CALL toi(unsigned short c)   {       return w32_regex_traits<regex_wchar_type>::toi(c);    }   static int BOOST_REGEX_CALL toi(const unsigned short*& first, const unsigned short* last, int radix)   {       return w32_regex_traits<regex_wchar_type>::toi(         reinterpret_cast<const regex_wchar_type*&>(first),          reinterpret_cast<const regex_wchar_type*>(last),          radix);    }   static boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const unsigned short* first, const unsigned short* last)   {      return w32_regex_traits<regex_wchar_type>::lookup_classname(         reinterpret_cast<const regex_wchar_type*>(first),          reinterpret_cast<const regex_wchar_type*>(last));   }   static bool BOOST_REGEX_CALL lookup_collatename(std::basic_string<unsigned short>& s, const unsigned short* first, const unsigned short* last)   {      return w32_regex_traits<regex_wchar_type>::lookup_collatename(         reinterpret_cast<std::basic_string<regex_wchar_type>&>(s),          reinterpret_cast<const regex_wchar_type*>(first),          reinterpret_cast<const regex_wchar_type*>(last));   }   static locale_type BOOST_REGEX_CALL imbue(locale_type l){ return l; }   locale_type BOOST_REGEX_CALL getloc()const{ return locale_type(); }   struct sentry   {      sentry(const w32_regex_traits<unsigned short>&)      { w32_regex_traits<unsigned short>::update(); }      ~sentry(){}      operator void*() { return this; }   };   static void BOOST_REGEX_CALL update()   {       w32_regex_traits<regex_wchar_type>::update();    }   void swap(w32_regex_traits&){}   w32_regex_traits(){};   ~w32_regex_traits(){};   static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const unsigned short *s2)   {       return w32_regex_traits<regex_wchar_type>::strnarrow(         s1,          len,          reinterpret_cast<const regex_wchar_type *>(s2));    }   static std::size_t BOOST_REGEX_CALL strwiden(unsigned short *s1, std::size_t len, const char *s2)   {       return w32_regex_traits<regex_wchar_type>::strwiden(         reinterpret_cast<regex_wchar_type *>(s1), len, s2);    }private:   w32_regex_traits<regex_wchar_type> m_init;};#endif // BOOST_REGEX_HAS_SHORT_WCHAR_T#endif // Wide strings#endif // Win32

⌨️ 快捷键说明

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