sclang: ServerShmInterface - avoid object duplication in deepCopy
[supercollider.git] / external_libraries / boost / libs / regex / src / cpp_regex_traits.cpp
blob1d24cc1a5ffab82d5d1eeda33bccd3f73225648b
1 /*
3 * Copyright (c) 2004
4 * John Maddock
6 * Use, modification and distribution are subject to the
7 * Boost Software License, Version 1.0. (See accompanying file
8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE cpp_regex_traits.cpp
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Implements cpp_regex_traits<char> (and associated helper classes).
19 #define BOOST_REGEX_SOURCE
20 #include <boost/config.hpp>
21 #ifndef BOOST_NO_STD_LOCALE
22 #include <boost/regex/regex_traits.hpp>
23 #include <boost/regex/pattern_except.hpp>
25 #ifdef BOOST_NO_STDC_NAMESPACE
26 namespace std{
27 using ::memset;
29 #endif
31 namespace boost{ namespace re_detail{
33 void cpp_regex_traits_char_layer<char>::init()
35 // we need to start by initialising our syntax map so we know which
36 // character is used for which purpose:
37 std::memset(m_char_map, 0, sizeof(m_char_map));
38 #ifndef BOOST_NO_STD_MESSAGES
39 #ifndef __IBMCPP__
40 std::messages<char>::catalog cat = static_cast<std::messages<char>::catalog>(-1);
41 #else
42 std::messages<char>::catalog cat = reinterpret_cast<std::messages<char>::catalog>(-1);
43 #endif
44 std::string cat_name(cpp_regex_traits<char>::get_catalog_name());
45 if(cat_name.size() && (m_pmessages != 0))
47 cat = this->m_pmessages->open(
48 cat_name,
49 this->m_locale);
50 if((int)cat < 0)
52 std::string m("Unable to open message catalog: ");
53 std::runtime_error err(m + cat_name);
54 boost::re_detail::raise_runtime_error(err);
58 // if we have a valid catalog then load our messages:
60 if((int)cat >= 0)
62 #ifndef BOOST_NO_EXCEPTIONS
63 try{
64 #endif
65 for(regex_constants::syntax_type i = 1; i < regex_constants::syntax_max; ++i)
67 string_type mss = this->m_pmessages->get(cat, 0, i, get_default_syntax(i));
68 for(string_type::size_type j = 0; j < mss.size(); ++j)
70 m_char_map[static_cast<unsigned char>(mss[j])] = i;
73 this->m_pmessages->close(cat);
74 #ifndef BOOST_NO_EXCEPTIONS
76 catch(...)
78 this->m_pmessages->close(cat);
79 throw;
81 #endif
83 else
85 #endif
86 for(regex_constants::syntax_type j = 1; j < regex_constants::syntax_max; ++j)
88 const char* ptr = get_default_syntax(j);
89 while(ptr && *ptr)
91 m_char_map[static_cast<unsigned char>(*ptr)] = j;
92 ++ptr;
95 #ifndef BOOST_NO_STD_MESSAGES
97 #endif
99 // finish off by calculating our escape types:
101 unsigned char i = 'A';
104 if(m_char_map[i] == 0)
106 if(this->m_pctype->is(std::ctype_base::lower, i))
107 m_char_map[i] = regex_constants::escape_type_class;
108 else if(this->m_pctype->is(std::ctype_base::upper, i))
109 m_char_map[i] = regex_constants::escape_type_not_class;
111 }while(0xFF != i++);
114 } // re_detail
115 } // boost
116 #endif